Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Henri Bonamy commited on
Commit ·
a82c70a
1
Parent(s): ff2fb51
small param / docs change to improve reliability of job scheduling by the agent
Browse files- agent/tools/jobs_tool.py +17 -5
agent/tools/jobs_tool.py
CHANGED
|
@@ -313,6 +313,7 @@ Call this tool with:
|
|
| 313 |
"operation": "uv",
|
| 314 |
"args": {{
|
| 315 |
"script": "import random\\nprint(42 + random.randint(1, 5))",
|
|
|
|
| 316 |
}}
|
| 317 |
}}
|
| 318 |
```
|
|
@@ -344,6 +345,7 @@ Call this tool with:
|
|
| 344 |
- Jobs default to non-detached mode (stream logs until completion). Set `detach: true` to return immediately.
|
| 345 |
- Prefer array commands to avoid shell parsing surprises
|
| 346 |
- To access private Hub assets, include `secrets: {{ "HF_TOKEN": "$HF_TOKEN" }}` to inject your auth token.
|
|
|
|
| 347 |
"""
|
| 348 |
return {"formatted": usage_text, "totalResults": 1, "resultsShared": 1}
|
| 349 |
|
|
@@ -442,7 +444,9 @@ To inspect, call this tool with `{{"operation": "inspect", "args": {{"job_id": "
|
|
| 442 |
# Resolve the command based on script type (URL, inline, or file)
|
| 443 |
command = _resolve_uv_command(
|
| 444 |
script=script,
|
| 445 |
-
with_deps=args.get("with_deps")
|
|
|
|
|
|
|
| 446 |
python=args.get("python"),
|
| 447 |
script_args=args.get("script_args"),
|
| 448 |
)
|
|
@@ -454,7 +458,7 @@ To inspect, call this tool with `{{"operation": "inspect", "args": {{"job_id": "
|
|
| 454 |
command=command,
|
| 455 |
env=args.get("env"),
|
| 456 |
secrets=args.get("secrets"),
|
| 457 |
-
flavor=args.get("flavor"
|
| 458 |
timeout=args.get("timeout", "30m"),
|
| 459 |
namespace=args.get("namespace") or self.namespace,
|
| 460 |
)
|
|
@@ -679,7 +683,9 @@ To list all, call this tool with `{{"operation": "scheduled ps"}}`"""
|
|
| 679 |
# Resolve the command based on script type
|
| 680 |
command = _resolve_uv_command(
|
| 681 |
script=script,
|
| 682 |
-
with_deps=args.get("with_deps")
|
|
|
|
|
|
|
| 683 |
python=args.get("python"),
|
| 684 |
script_args=args.get("script_args"),
|
| 685 |
)
|
|
@@ -692,7 +698,7 @@ To list all, call this tool with `{{"operation": "scheduled ps"}}`"""
|
|
| 692 |
schedule=schedule,
|
| 693 |
env=args.get("env"),
|
| 694 |
secrets=args.get("secrets"),
|
| 695 |
-
flavor=args.get("flavor"
|
| 696 |
timeout=args.get("timeout", "30m"),
|
| 697 |
namespace=args.get("namespace") or self.namespace,
|
| 698 |
)
|
|
@@ -851,6 +857,7 @@ HF_JOBS_TOOL_SPEC = {
|
|
| 851 |
"description": (
|
| 852 |
"Manage Hugging Face CPU/GPU compute jobs. Run commands in Docker containers, "
|
| 853 |
"execute Python scripts with UV. List, schedule and monitor jobs/logs. "
|
|
|
|
| 854 |
"Call this tool with no operation for full usage instructions and examples."
|
| 855 |
),
|
| 856 |
"parameters": {
|
|
@@ -881,7 +888,12 @@ HF_JOBS_TOOL_SPEC = {
|
|
| 881 |
},
|
| 882 |
"args": {
|
| 883 |
"type": "object",
|
| 884 |
-
"description":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 885 |
"additionalProperties": True,
|
| 886 |
},
|
| 887 |
},
|
|
|
|
| 313 |
"operation": "uv",
|
| 314 |
"args": {{
|
| 315 |
"script": "import random\\nprint(42 + random.randint(1, 5))",
|
| 316 |
+
"dependencies" : ["torch", "huggingface_hub"]
|
| 317 |
}}
|
| 318 |
}}
|
| 319 |
```
|
|
|
|
| 345 |
- Jobs default to non-detached mode (stream logs until completion). Set `detach: true` to return immediately.
|
| 346 |
- Prefer array commands to avoid shell parsing surprises
|
| 347 |
- To access private Hub assets, include `secrets: {{ "HF_TOKEN": "$HF_TOKEN" }}` to inject your auth token.
|
| 348 |
+
- Before calling a job, think about dependencies (they must be specified), which hardware flavor to run on (choose simplest for task), and whether to include secrets.
|
| 349 |
"""
|
| 350 |
return {"formatted": usage_text, "totalResults": 1, "resultsShared": 1}
|
| 351 |
|
|
|
|
| 444 |
# Resolve the command based on script type (URL, inline, or file)
|
| 445 |
command = _resolve_uv_command(
|
| 446 |
script=script,
|
| 447 |
+
with_deps=args.get("with_deps")
|
| 448 |
+
or args.get("dependencies")
|
| 449 |
+
or args.get("packages"),
|
| 450 |
python=args.get("python"),
|
| 451 |
script_args=args.get("script_args"),
|
| 452 |
)
|
|
|
|
| 458 |
command=command,
|
| 459 |
env=args.get("env"),
|
| 460 |
secrets=args.get("secrets"),
|
| 461 |
+
flavor=args.get("flavor") or args.get("hardware") or "cpu-basic",
|
| 462 |
timeout=args.get("timeout", "30m"),
|
| 463 |
namespace=args.get("namespace") or self.namespace,
|
| 464 |
)
|
|
|
|
| 683 |
# Resolve the command based on script type
|
| 684 |
command = _resolve_uv_command(
|
| 685 |
script=script,
|
| 686 |
+
with_deps=args.get("with_deps")
|
| 687 |
+
or args.get("dependencies")
|
| 688 |
+
or args.get("packages"),
|
| 689 |
python=args.get("python"),
|
| 690 |
script_args=args.get("script_args"),
|
| 691 |
)
|
|
|
|
| 698 |
schedule=schedule,
|
| 699 |
env=args.get("env"),
|
| 700 |
secrets=args.get("secrets"),
|
| 701 |
+
flavor=args.get("flavor") or args.get("hardware") or "cpu-basic",
|
| 702 |
timeout=args.get("timeout", "30m"),
|
| 703 |
namespace=args.get("namespace") or self.namespace,
|
| 704 |
)
|
|
|
|
| 857 |
"description": (
|
| 858 |
"Manage Hugging Face CPU/GPU compute jobs. Run commands in Docker containers, "
|
| 859 |
"execute Python scripts with UV. List, schedule and monitor jobs/logs. "
|
| 860 |
+
"Example hardware/flavor: cpu-basic, cpu-performance, t4-medium. "
|
| 861 |
"Call this tool with no operation for full usage instructions and examples."
|
| 862 |
),
|
| 863 |
"parameters": {
|
|
|
|
| 888 |
},
|
| 889 |
"args": {
|
| 890 |
"type": "object",
|
| 891 |
+
"description": (
|
| 892 |
+
"Operation-specific arguments as a JSON object. "
|
| 893 |
+
"Common args: script (for uv), packages/dependencies (array), "
|
| 894 |
+
"flavor/hardware (e.g., a10g-large, cpu-basic), command (array), "
|
| 895 |
+
"image (string), env (object), secrets (object)."
|
| 896 |
+
),
|
| 897 |
"additionalProperties": True,
|
| 898 |
},
|
| 899 |
},
|