Skip to content

Commit

Permalink
fix(cli): change raw url to markdown format (#701)
Browse files Browse the repository at this point in the history
* fix(cli): change raw url to markdown format

* fix(cos): set download uri's expired time 3600
  • Loading branch information
Kaikaikaifang committed Sep 8, 2024
1 parent 0e80b60 commit 0afc276
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion swanlab/cli/commands/task/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ def table(self):
output_url = tlm.output.output_url
if output_url is not None:
output_url = Markdown(f"[{tlm.output.path}]({output_url})", justify="center")
url = tlm.url
if url is not None:
url = Markdown(f"[{tlm.project_name}]({url})", justify="center")
st.add_row(
tlm.cuid,
tlm.name,
status,
tlm.url,
url,
output_url,
tlm.output.size,
tlm.started_at,
Expand Down
2 changes: 1 addition & 1 deletion swanlab/cli/commands/task/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def search(cuid):
for dataset in data.get("datasets", []):
console.print(f"[bold]Dataset ID:[/bold] [white]{dataset['cuid']}[/white]")

tm.url is not None and console.print(f"[bold]SwanLab URL:[/bold] {tm.url}")
tm.url is not None and console.print(Markdown(f"**SwanLab URL:** [{tm.project_name}]({tm.url})"))
if tm.output.path is not None:
console.print(Markdown(f"**Output URL**: [{tm.output.path}]({tm.output.output_url})"))
console.print(f"[bold]Output Size:[/bold] {tm.output.size}")
Expand Down
4 changes: 2 additions & 2 deletions swanlab/cli/commands/task/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def __init__(self, cuid: str, output: dict):

@property
def output_url(self):
"""获取预签名的输出下载 url"""
"""获取预签名的输出下载 url (过期时间 1 小时)"""
if self.path is None:
return None
uploader = CosUploader()
key = f"{uploader.prefix}/outputs/{self.path}"
return uploader.client.get_presigned_download_url(
Bucket=uploader.bucket, Key=key, Params={'x-cos-security-token': uploader.token}
Bucket=uploader.bucket, Key=key, Params={'x-cos-security-token': uploader.token}, Expired=3600
)

@staticmethod
Expand Down

0 comments on commit 0afc276

Please sign in to comment.