-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beta version fix some bugs new cli: task stop
- Loading branch information
1 parent
f74e89b
commit b0e26f6
Showing
7 changed files
with
156 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
r""" | ||
@DATE: 2024/7/30 16:13 | ||
@File: stop.py | ||
@IDE: pycharm | ||
@Description: | ||
停止任务 | ||
""" | ||
import click | ||
from .utils import login_init_sid, UseTaskHttp, validate_six_char_string | ||
from swanlab.error import ApiError | ||
|
||
|
||
@click.command() | ||
@click.argument("cuid", type=str, callback=validate_six_char_string) | ||
def stop(cuid): | ||
""" | ||
Stop a task by cuid | ||
""" | ||
login_init_sid() | ||
with UseTaskHttp() as http: | ||
try: | ||
http.patch(f"/task/status", {"cuid": cuid, "status": "STOPPED", "msg": "User stopped by sdk"}) | ||
except ApiError as e: | ||
if e.resp.status_code == 404: | ||
raise click.BadParameter("Task not found") | ||
click.echo("Task stopped successfully, there may be a few minutes of delay online.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "swanlab", | ||
"version": "0.3.15-alpha.4", | ||
"version": "0.3.15-beta", | ||
"description": "", | ||
"python": "true" | ||
} |