envloop-cli 1.28.0__py3-none-any.whl → 1.30.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- envloop/_optional.py +1 -1
- envloop/auth_cli.py +3 -0
- envloop/auth_login.py +4 -1
- envloop/cli_errors.py +8 -4
- envloop/cli_output.py +2 -1
- envloop/lifecycle_cli.py +3 -1
- envloop/terminal.py +8 -5
- {envloop_cli-1.28.0.dist-info → envloop_cli-1.30.0.dist-info}/METADATA +3 -3
- {envloop_cli-1.28.0.dist-info → envloop_cli-1.30.0.dist-info}/RECORD +26 -25
- envloop_data/cli_output.py +5 -4
- envloop_data/client.py +2 -2
- envloop_data/data.py +35 -35
- envloop_data/data_cli.py +14 -10
- envloop_data/data_publications.py +6 -6
- envloop_data/data_upload.py +1 -1
- envloop_data/navigation_resources.py +7 -5
- envloop_data/resource_cli.py +12 -11
- envloop_experiment/cli.py +48 -9
- envloop_experiment/job_cost.py +10 -7
- envloop_experiment/job_spec_cli.py +34 -3
- envloop_experiment/train.py +7 -2
- envloop_experiment/train_log_cli.py +5 -2
- envloop_experiment/train_metrics_cli.py +146 -0
- envloop_experiment/train_progress.py +1 -1
- {envloop_cli-1.28.0.dist-info → envloop_cli-1.30.0.dist-info}/WHEEL +0 -0
- {envloop_cli-1.28.0.dist-info → envloop_cli-1.30.0.dist-info}/entry_points.txt +0 -0
envloop/_optional.py
CHANGED
|
@@ -30,7 +30,7 @@ FEATURE_COMMANDS = {
|
|
|
30
30
|
|
|
31
31
|
MODULES: dict[str, str] = {
|
|
32
32
|
**dict.fromkeys('data data_publications data_upload data_cli profile_updates recipes'.split(), 'data'),
|
|
33
|
-
**dict.fromkeys('train train_progress train_runner_cli train_log_cli job_logs job_cost inference decision sandbox runtime_params job_spec_cli training'.split(), 'experiment'),
|
|
33
|
+
**dict.fromkeys('train train_progress train_metrics_cli train_runner_cli train_log_cli job_logs job_cost inference decision sandbox runtime_params job_spec_cli training'.split(), 'experiment'),
|
|
34
34
|
**dict.fromkeys('agent_runs rsi_cli'.split(), 'rsi-loop'),
|
|
35
35
|
}
|
|
36
36
|
CLIENTS = {
|
envloop/auth_cli.py
CHANGED
|
@@ -20,6 +20,9 @@ def add_auth_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParse
|
|
|
20
20
|
login.add_argument("--no-browser", action="store_true", help="Print the login link without opening a browser")
|
|
21
21
|
login.add_argument("--timeout-seconds", type=int, choices=range(1, 601), metavar="SECONDS", default=300,
|
|
22
22
|
help="Wait up to 1–600 seconds (default: 300)")
|
|
23
|
+
login.add_argument("--read-only", action="store_true",
|
|
24
|
+
help="Issue a read-only key, for example for CI that only reads results. "
|
|
25
|
+
"Without it the key follows your project role")
|
|
23
26
|
configure = commands.add_parser("config", help="Save Base URL and API key for CLI and SDK")
|
|
24
27
|
configure.add_argument("--no-check", action="store_true", help="Save without API verification (offline; key remains unverified)")
|
|
25
28
|
actions = configure.add_subparsers(dest="config_action")
|
envloop/auth_login.py
CHANGED
|
@@ -76,7 +76,8 @@ def login(args: argparse.Namespace, store: Any) -> int:
|
|
|
76
76
|
def digest(value: str) -> str:
|
|
77
77
|
return hashlib.sha256(value.encode()).hexdigest()
|
|
78
78
|
response = _request(url, 'start', {'key_hash': digest(key), 'poll_hash': digest(poll_token),
|
|
79
|
-
'code_hash': digest(code)
|
|
79
|
+
'code_hash': digest(code), **({'read_only': True} if args.read_only else {})},
|
|
80
|
+
min(5, args.timeout_seconds))
|
|
80
81
|
identifier, uri = _verification_url(url, response)
|
|
81
82
|
interval, expires = response.get('interval'), response.get('expires_in')
|
|
82
83
|
if (isinstance(interval, bool) or not isinstance(interval, (int, float)) or not 0 < interval <= 10 or
|
|
@@ -88,6 +89,8 @@ def login(args: argparse.Namespace, store: Any) -> int:
|
|
|
88
89
|
try:
|
|
89
90
|
print(f'Base URL: {url}\nConfirmation code: {code}\nOpen: {uri}', flush=True)
|
|
90
91
|
print('Sign in with Clerk, enter this code, and authorize your workspace/project.', flush=True)
|
|
92
|
+
print('The key will be read only.' if args.read_only else
|
|
93
|
+
'The key follows your project role. The page lists its permissions before you authorize.', flush=True)
|
|
91
94
|
if not args.no_browser:
|
|
92
95
|
try:
|
|
93
96
|
opened = webbrowser.open(uri, new=1)
|
envloop/cli_errors.py
CHANGED
|
@@ -27,10 +27,10 @@ def _register(codes: str, message: str) -> None:
|
|
|
27
27
|
_MESSAGES[code] = message
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
_register("
|
|
30
|
+
_register("DATA_ACCESS_REQUIRED", "This key lacks the permission named above on the Dataset, Runner, Profile, Checkpoint or Trial artifact. Run el auth login to issue a new key that follows your project role: every role can read, and Developer or Admin can also write and delete (create, update, delete, upload, runner register). A key from el auth login --read-only cannot write; log in again without --read-only. Or give a key Read or Edit on that page in the Console under CONFIGURE > API Keys. Existing keys never gain permissions.")
|
|
31
31
|
_register("DATA_NATIVE_INCOMPLETE DATA_NATIVE_UNAVAILABLE", "Native catalog registration is incomplete. Retry the same input after the platform is ready.")
|
|
32
32
|
_register("DATA_DEPENDENCIES_ACTIVE DATA_DEPENDENCIES_UNKNOWN DATA_DEPENDENCIES_CHANGED DATA_DELETE_CONFLICT", "Retirement requires a complete, current dependency check. Resolve active or unknown dependencies, then retry the same resource.")
|
|
33
|
-
_register("DATA_PUBLICATION_INVALID", "Check the immutable ANS URI, native manifest and exact file sizes and SHA-256 values.")
|
|
33
|
+
_register("DATA_PUBLICATION_INVALID", "Check the immutable ANS URI, native manifest and exact file sizes and SHA-256 values. A record Dataset source is https://github.com/OWNER/REPO or https://huggingface.co/datasets/ORG/NAME with the full commit, not a branch or tag.")
|
|
34
34
|
_register("DATA_PIN_CONFLICT DATA_REVISION_REQUIRED", "Publish a new immutable revision; existing and revoked references cannot be overwritten.")
|
|
35
35
|
_register("DATA_QUOTA_EXCEEDED DATA_QUOTA_UNCONFIGURED", "Ask a project administrator to configure publication storage quota. Revoking publications does not free retained content.")
|
|
36
36
|
_register("DATA_UPLOAD_CONFLICT DATA_UPLOAD_INCOMPLETE DATA_UPLOAD_RATE_LIMITED", "Inspect the upload with data upload get; resume matching parts or explicitly abort it.")
|
|
@@ -182,7 +182,7 @@ TASK_REQUEST_CONFLICT TEMPORARY_DEPENDENCY_REQUIRES_RETAIN TEMPORARY_RESOURCE_RE
|
|
|
182
182
|
TEMPORARY_SCOPE_CONFLICT TEMPORARY_SCOPE_EXPIRED TRIAL_IDEMPOTENCY_CONFLICT TRIAL_VERSION_CONFLICT USAGE_EVENT_CONFLICT
|
|
183
183
|
PROFILE_CORRUPT ADAPTER_STORAGE_UNAVAILABLE INSUFFICIENT_BALANCE METHOD_NOT_ALLOWED REQUEST_TOO_LARGE
|
|
184
184
|
BATCH_POLICY_NOT_APPROVED BATCH_PROVIDER_UNAVAILABLE CHECKPOINT_ACCESS_DENIED CHECKPOINT_DOWNLOAD_UNAVAILABLE
|
|
185
|
-
CHECKPOINT_MANAGEMENT_UNAVAILABLE CHECKPOINT_MANAGEMENT_UNSUPPORTED CHECKPOINT_NOT_DURABLE
|
|
185
|
+
CHECKPOINT_MANAGEMENT_UNAVAILABLE CHECKPOINT_MANAGEMENT_UNSUPPORTED CHECKPOINT_NOT_DURABLE CHECKPOINT_TRIAL_REQUIRED
|
|
186
186
|
CHECKPOINT_SIGNER_UNAVAILABLE INVALID_CHECKPOINT_CURSOR INVALID_CHECKPOINT_TTL INVALID_CHECKPOINT_VISIBILITY
|
|
187
187
|
INVALID_EXECUTION_CONFIG INVALID_METRICS_RANGE INVALID_TRAIN_JOB_CURSOR INVALID_TRAIN_JOB_LIST_LIMIT
|
|
188
188
|
INVALID_TRAIN_JOB_METADATA INVALID_TRAIN_JOB_SPEC INVALID_TRAIN_JOB_STATUS LOG_RETENTION_EXPIRED
|
|
@@ -329,7 +329,11 @@ def upload_recovery(error: BaseException) -> str:
|
|
|
329
329
|
if isinstance(upload_id, str) and re.fullmatch(r'upload_[a-f0-9]{32}', upload_id):
|
|
330
330
|
lines.extend([f' Upload retained: {upload_id}', f' Inspect with: el data upload get {upload_id}'])
|
|
331
331
|
generated = getattr(error, 'generated_idempotency_key', None)
|
|
332
|
-
|
|
332
|
+
# A definite refusal (permission, validation, not found) fails the same way again; offer the key only
|
|
333
|
+
# when the outcome is unknown or retryable.
|
|
334
|
+
status = getattr(error, 'status_code', None)
|
|
335
|
+
retryable = not isinstance(status, int) or status >= 500 or status in {408, 429}
|
|
336
|
+
if retryable and isinstance(generated, str) and re.fullmatch(r'[a-f0-9]{32}', generated):
|
|
333
337
|
lines.append(f' Retry the same input with --idempotency-key {generated}')
|
|
334
338
|
return '\n'.join(lines)
|
|
335
339
|
|
envloop/cli_output.py
CHANGED
|
@@ -38,7 +38,8 @@ def table(headers: Sequence[object], rows: Sequence[Sequence[object]]) -> str:
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def timestamp(value: object) -> str:
|
|
41
|
-
|
|
41
|
+
"""Table and summary times: UTC to seconds, labelled; --json keeps the original value."""
|
|
42
|
+
return compact_time(value, utc=True)
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def next_page(args: argparse.Namespace, cursor: object, program: str) -> str:
|
envloop/lifecycle_cli.py
CHANGED
|
@@ -18,7 +18,9 @@ def add_management_commands(settings: "argparse._SubParsersAction[argparse.Argum
|
|
|
18
18
|
if action == 'wait':
|
|
19
19
|
command.add_argument('--timeout-seconds', type=float, default=600)
|
|
20
20
|
cleanup = settings.add_parser('cleanup', help='Clean an explicit set of Project resource IDs')
|
|
21
|
-
cleanup.add_argument('--file', type=Path, required=True,
|
|
21
|
+
cleanup.add_argument('--file', type=Path, required=True,
|
|
22
|
+
help='JSON array of {"kind": KIND, "id": ID} objects; KIND is job (a Train Job), endpoint, adapter '
|
|
23
|
+
'or checkpoint, for example [{"kind": "job", "id": "job_..."}]')
|
|
22
24
|
cleanup.add_argument('--request-id', required=True)
|
|
23
25
|
wait_options(cleanup)
|
|
24
26
|
scopes = settings.add_parser('resource-scope', help='Manage temporary resources with server TTL').add_subparsers(dest='scope_action', required=True)
|
envloop/terminal.py
CHANGED
|
@@ -6,7 +6,7 @@ import sys
|
|
|
6
6
|
import unicodedata
|
|
7
7
|
from contextlib import contextmanager
|
|
8
8
|
from contextvars import ContextVar
|
|
9
|
-
from datetime import datetime
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
10
|
from typing import Any, TextIO
|
|
11
11
|
|
|
12
12
|
_NO_COLOR = ContextVar("envloop_cli_no_color", default=False)
|
|
@@ -47,15 +47,18 @@ def status_text(text: str) -> str:
|
|
|
47
47
|
return style(text, code) if code else text
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def compact_time(value: Any, *,
|
|
51
|
-
"""Render aware times to seconds; preserve unknown or timezone-free values.
|
|
50
|
+
def compact_time(value: Any, *, utc: bool = False) -> Any:
|
|
51
|
+
"""Render aware times to seconds; preserve unknown or timezone-free values.
|
|
52
|
+
|
|
53
|
+
``utc`` converts to UTC and labels it, so a table read on any machine means the same instant.
|
|
54
|
+
"""
|
|
52
55
|
if not isinstance(value, str):
|
|
53
56
|
return value
|
|
54
57
|
try:
|
|
55
58
|
parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
56
59
|
if parsed.tzinfo is not None:
|
|
57
|
-
if
|
|
58
|
-
|
|
60
|
+
if utc:
|
|
61
|
+
return parsed.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
|
59
62
|
return parsed.strftime("%Y-%m-%d %H:%M:%S")
|
|
60
63
|
except ValueError:
|
|
61
64
|
pass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: envloop-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.30.0
|
|
4
4
|
Summary: EnvLoop CLI and Python SDK for jobs, training, checkpoints and inference
|
|
5
5
|
Project-URL: Homepage, https://envloop.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.envloop.ai
|
|
@@ -249,7 +249,7 @@ The platform starts the published Revision’s `main.sh` / `main.py` using the R
|
|
|
249
249
|
CLI output uses compact timestamps and highlights statuses and log levels by default on terminals.
|
|
250
250
|
Use `el --no-color job list` or append `--no-color` to a command to disable highlighting, including errors.
|
|
251
251
|
`NO_COLOR=1`, `TERM=dumb`, pipes, and redirected output also disable colors. JSON preserves original values.
|
|
252
|
-
List times
|
|
252
|
+
List and table times are UTC with a `UTC` label; Job logs retain the recorded timezone and mark lines collected only after the Job ended with `(backfilled)`. Full precision, offsets and the `backfilled` field are available through `--json`.
|
|
253
253
|
`el job run live RUN --follow --json` emits complete response frames as NDJSON; Ctrl-C stops reading without stopping the Run.
|
|
254
254
|
|
|
255
255
|
## Job-bound decision plugins
|
|
@@ -283,7 +283,7 @@ download a complete registered ANS object directory through EnvHub. Datasets req
|
|
|
283
283
|
authorization the SDK uses GET URLs valid for up to five minutes, verifies file size/SHA-256,
|
|
284
284
|
and installs the directory atomically. Matching platform support is required.
|
|
285
285
|
|
|
286
|
-
A compatible server
|
|
286
|
+
A compatible server is required. Data uses the permission of the resource it touches: read (for example `datasets.read`) to query and download, write to publish and upload, delete to retire; a key from `el auth login` follows your project role. The current login selects the base URL, workspace and project; there is no `--env` flag. After configuring the Key using `el auth config`:
|
|
287
287
|
|
|
288
288
|
```bash
|
|
289
289
|
el data list --type dataset --json
|
|
@@ -1,55 +1,56 @@
|
|
|
1
1
|
envloop/__init__.py,sha256=tX06Gh2EmufRr0J_3YKtjDeNrJ30auR3y3BJ3N3FHJY,421
|
|
2
|
-
envloop/_optional.py,sha256=
|
|
3
|
-
envloop/auth_cli.py,sha256=
|
|
4
|
-
envloop/auth_login.py,sha256=
|
|
2
|
+
envloop/_optional.py,sha256=d2Ebq9g0JTKjiq3fuGobG4XjXc6MCogZ5X7uXQDaqak,8981
|
|
3
|
+
envloop/auth_cli.py,sha256=Yjwy1eLyrKfGPOA2vx6q5ZyMyrCNuUh5Xkn7d9-4IvM,15681
|
|
4
|
+
envloop/auth_login.py,sha256=uOqPHqgzi0Y5eDMiZJH-EI_HxY55F9bRr8CoBb8OHfk,7231
|
|
5
5
|
envloop/auth_workspace.py,sha256=g92Dok4eSp6P-Du5qkwzZG4JDeSrdYTXJbn5WCzCFMo,14927
|
|
6
6
|
envloop/cli.py,sha256=Vafivql1JBrlIrfJOD-XAw6AevQKIasmvDHmcazIzqo,15010
|
|
7
|
-
envloop/cli_errors.py,sha256=
|
|
8
|
-
envloop/cli_output.py,sha256=
|
|
7
|
+
envloop/cli_errors.py,sha256=tPqZFFjW-XMvIq4Vxzbn1D5LbIM6BMHKRkl4nKleeS8,31622
|
|
8
|
+
envloop/cli_output.py,sha256=UkcEMqxpzMUSYaxTQMJR1WQ8nqsoq-piPNyPrCMR5dQ,6025
|
|
9
9
|
envloop/client.py,sha256=TdTUhHwtK0FL6xzIz4moaNdIPlC-TkisPvU4zNPnaTA,3270
|
|
10
10
|
envloop/config.py,sha256=1Wr2lNdNNZzsQDPNGsk-TsnEUvDqOtocy9TgUpmOZO0,22494
|
|
11
11
|
envloop/downloads.py,sha256=ktL-hz9HWPGNuQX_N5RmLyt16qbooArljW9z80XYmTo,3253
|
|
12
12
|
envloop/http.py,sha256=2mu5yIgQDESC0y2LvdE53d7fPfSzT0oXVjlY25qwGkY,16479
|
|
13
|
-
envloop/lifecycle_cli.py,sha256=
|
|
13
|
+
envloop/lifecycle_cli.py,sha256=AiiNK7fueIw2Y5HP-OcIKMDUjIXZrUZiFASHfRNkk5Q,3349
|
|
14
14
|
envloop/navigation_resources.py,sha256=3PeZiYtXHXPMwuCLRdw1mUnZDTDJUYthUhsiJkHtI_g,10378
|
|
15
15
|
envloop/profile_secrets.py,sha256=5QpHRV_Gy1MxObR62SX4nNblqk7gWqQZNtzy6wZNV0s,6325
|
|
16
16
|
envloop/resource_cli.py,sha256=JUMpptd3VvCas0D3cdS5p8_iHVCkiaiIqqGLeFdCnws,13371
|
|
17
17
|
envloop/resources.py,sha256=V5nDuM8QgE52V9slSj2ywmhZqwgMKFosm4o5naFaEJo,3025
|
|
18
|
-
envloop/terminal.py,sha256=
|
|
18
|
+
envloop/terminal.py,sha256=AtScg4nUo6wMQO7LNCnypUV9wWB62baBXO7YGpA3jV8,2771
|
|
19
19
|
envloop/utils/__init__.py,sha256=huB3qPQuKNr3JxfH3Ys09YWFtHiDamCHFsBa4epANgQ,25
|
|
20
20
|
envloop/utils/logging.py,sha256=rXN0qyxhfGEq4vWXxjwfaczPPZf_7atnOkkBTgNNRPc,1017
|
|
21
21
|
envloop_data/__init__.py,sha256=nKDGmzFNAQv2mq16YijiI3Q-gDL_smNyZD-AQaqoz7Y,68
|
|
22
22
|
envloop_data/cli.py,sha256=5J_pS5jf65gyaRpE2EV4jDfDUZ1oEsK0iHAmhJlk-oU,9023
|
|
23
|
-
envloop_data/cli_output.py,sha256=
|
|
24
|
-
envloop_data/client.py,sha256=
|
|
25
|
-
envloop_data/data.py,sha256=
|
|
26
|
-
envloop_data/data_cli.py,sha256=
|
|
27
|
-
envloop_data/data_publications.py,sha256=
|
|
28
|
-
envloop_data/data_upload.py,sha256=
|
|
23
|
+
envloop_data/cli_output.py,sha256=3ZuAXJiXs1wVxIthHMpRgn-VVC4PatSUAWZDCgldrhQ,4414
|
|
24
|
+
envloop_data/client.py,sha256=M1NxvQiiNWq3CByW7AehEOfpkfBrC7ysSDAPkeccCaA,12515
|
|
25
|
+
envloop_data/data.py,sha256=VWmdQbOlXOaQZdPqcTQLk0Di0HeMSLARxAfntwh2RWo,27610
|
|
26
|
+
envloop_data/data_cli.py,sha256=NtJ-Bpw2fnSOCWy3bsgdUMLKUc8z1wrB1NqiOvHMsSw,13623
|
|
27
|
+
envloop_data/data_publications.py,sha256=_Z64X9CCHz1c2AhtcbRIQuROiJ2jTLw6dA3nn1PyHek,6885
|
|
28
|
+
envloop_data/data_upload.py,sha256=b9hf-MwWHtrZW-9U9WyxJxX89SRsEHXCPcSQIy6SVMM,14270
|
|
29
29
|
envloop_data/http.py,sha256=adbMFCUsS1YYanzdCoqM4HIgIOxjgXoHKOkxSwUuvW4,6726
|
|
30
|
-
envloop_data/navigation_resources.py,sha256=
|
|
30
|
+
envloop_data/navigation_resources.py,sha256=V3JtSXYqXk1e0ke1nEdBHcZtUHNqHu9mJd4BfN9y4zg,12553
|
|
31
31
|
envloop_data/profile_updates.py,sha256=FB3Huf0AIlqg6CUC0TcrEeWCF5GH1Z6iJN5Wkq8KcYg,3126
|
|
32
32
|
envloop_data/recipes.py,sha256=JH0bvM0LCH_iN4p4ONfTSF53eSHAVLUQNFLueOx07UA,1301
|
|
33
|
-
envloop_data/resource_cli.py,sha256=
|
|
33
|
+
envloop_data/resource_cli.py,sha256=E1CW0Toe_uw07WEV2B6ZkbUWc4w7Md5Hv7bboUGGxZI,7230
|
|
34
34
|
envloop_data/runner_packages.py,sha256=Xi50hZbdoew9DJ8iYQevMo2jv3qgR3iT50wtV04rFfQ,3424
|
|
35
35
|
envloop_experiment/__init__.py,sha256=nKDGmzFNAQv2mq16YijiI3Q-gDL_smNyZD-AQaqoz7Y,68
|
|
36
|
-
envloop_experiment/cli.py,sha256=
|
|
36
|
+
envloop_experiment/cli.py,sha256=Tc1irMierk-_6Yl8cyJc_xVPelE21X7bjacK8fDaJlM,31119
|
|
37
37
|
envloop_experiment/cli_output.py,sha256=-FojsqOMIIQuOnfhk2AaqMtwUz5skoWvLeNASm8An6Y,2689
|
|
38
38
|
envloop_experiment/client.py,sha256=VKKqI9IDazxaN7-coP48DvXcz6SqjZ8ScM4O6plBNWI,25122
|
|
39
39
|
envloop_experiment/decision.py,sha256=HJTj-jSJJ5kcxQQzFXwrA9IICWXA6zSNBFL9EbbrxqI,918
|
|
40
40
|
envloop_experiment/http.py,sha256=A_PHWVr7PV4eiP30lXmOITiljXf6GEIYGkJlr1KFz-Q,6110
|
|
41
41
|
envloop_experiment/inference.py,sha256=74MZDs0lqqqNwgdvj58rs-D3emDj4iHv1W-copc5PYA,2134
|
|
42
|
-
envloop_experiment/job_cost.py,sha256=
|
|
42
|
+
envloop_experiment/job_cost.py,sha256=gZB69-pdsJM4wManw44AIS9T3ZtsxxQTqrJs-cHjwJU,2214
|
|
43
43
|
envloop_experiment/job_logs.py,sha256=RLipbj89e5hQdBeXtszsxSYYw7By1hscwSTGFQzQ3Qw,1340
|
|
44
|
-
envloop_experiment/job_spec_cli.py,sha256=
|
|
44
|
+
envloop_experiment/job_spec_cli.py,sha256=qyt0hZMAVqOCoRSzEuO2mQ8f8ro5cLiY5eRdAWGQbOM,9753
|
|
45
45
|
envloop_experiment/navigation_resources.py,sha256=xoI4VFmd0dzviKvzndwKAoWdfbaL_f50cnXRxPkfoo4,1832
|
|
46
46
|
envloop_experiment/resource_cli.py,sha256=MCFWHl4iCNe1UiGyHcvMM67LOHQ7MZl3joFtftQwqLk,2083
|
|
47
47
|
envloop_experiment/resources.py,sha256=4guXzssv7XhYkn8ESH-79DIMWUyKDIg70uOa-KoNvp0,7236
|
|
48
48
|
envloop_experiment/runtime_params.py,sha256=ITF6hDuhfdChnWo3e8NW27WxEoNoCuOTww-Hz60zqQU,3608
|
|
49
49
|
envloop_experiment/sandbox.py,sha256=sTpAWbcs2jAPfb7gILK4MTJSmcpSeZG3anFkLA5TgdQ,1274
|
|
50
|
-
envloop_experiment/train.py,sha256=
|
|
51
|
-
envloop_experiment/train_log_cli.py,sha256=
|
|
52
|
-
envloop_experiment/
|
|
50
|
+
envloop_experiment/train.py,sha256=S0nkTjfbXJnDL1uxPeOIcfHF3Zxc3jqO6O2_UcNjcr0,5472
|
|
51
|
+
envloop_experiment/train_log_cli.py,sha256=jCu7c0DGzy0La8tigJVDjuQHROaw6kfclU64QYsRVj0,6622
|
|
52
|
+
envloop_experiment/train_metrics_cli.py,sha256=AXq5UPf_Xa4RCxAwZNvz8VZKghN1k3dhxbAXXxMmLlY,6522
|
|
53
|
+
envloop_experiment/train_progress.py,sha256=XrF6g1XNtGReuIfFdfXTvD4XwvS-bDcFZNHzTCCfYa0,2546
|
|
53
54
|
envloop_experiment/train_runner_cli.py,sha256=OiHv7Dp2VPoQVmFR0vgJoAd5Ni0uQvtCyNf5Lk4AFfc,3154
|
|
54
55
|
envloop_experiment/training/__init__.py,sha256=IEQWbCHe-zZ2e7JQxOrFOdYlSQxMfOceCZUf_KeszBk,221
|
|
55
56
|
envloop_rsi_loop/__init__.py,sha256=nKDGmzFNAQv2mq16YijiI3Q-gDL_smNyZD-AQaqoz7Y,68
|
|
@@ -57,7 +58,7 @@ envloop_rsi_loop/agent_runs.py,sha256=GrXSfnQ8MchA9i8UI3LWJiTninpI0PeTm0hgz2TJ0N
|
|
|
57
58
|
envloop_rsi_loop/cli.py,sha256=Kqearg20Mvfyj62r2mibVdWEMo1NHjthgvS-Tl7SC-A,3047
|
|
58
59
|
envloop_rsi_loop/cli_output.py,sha256=GxM4UiL4NzzSyjRrikai6ROW-1WPjFtwrIfpnE8GZ4U,3173
|
|
59
60
|
envloop_rsi_loop/rsi_cli.py,sha256=e9XHeIPwMz1dZ6NhK3UIETCdy7LbIWgFosF1FnKVUQk,2580
|
|
60
|
-
envloop_cli-1.
|
|
61
|
-
envloop_cli-1.
|
|
62
|
-
envloop_cli-1.
|
|
63
|
-
envloop_cli-1.
|
|
61
|
+
envloop_cli-1.30.0.dist-info/METADATA,sha256=ku-cMRnCnhzCW4sa4kW-wFyyhH__GtXzdUI6qTEHe7A,15810
|
|
62
|
+
envloop_cli-1.30.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
63
|
+
envloop_cli-1.30.0.dist-info/entry_points.txt,sha256=8aXOpgtVk4GndhChA4XNecShkb1w0xGHBHrKla78ofI,67
|
|
64
|
+
envloop_cli-1.30.0.dist-info/RECORD,,
|
envloop_data/cli_output.py
CHANGED
|
@@ -38,9 +38,10 @@ def list_layout(items: list[dict[str, Any]], args: argparse.Namespace) -> tuple[
|
|
|
38
38
|
render = dataset_row
|
|
39
39
|
empty = 'No datasets found.'
|
|
40
40
|
elif args.group == 'checkpoint':
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
# The checkpoint ID is the resource_id (cp_…); the save name (adapter-final) repeats across Jobs.
|
|
42
|
+
headers = ('CHECKPOINT ID', 'NAME', 'TYPE', 'MODEL', 'JOB ID', 'URI')
|
|
43
|
+
render = lambda item: (item.get('resource_id'), item.get('checkpoint_id'), item.get('checkpoint_type'),
|
|
44
|
+
item.get('base_model'), item.get('job_id'), item.get('uri'))
|
|
44
45
|
empty = 'No checkpoints found.'
|
|
45
46
|
elif args.group == "profile" and args.name is None:
|
|
46
47
|
headers = ("NAME", "VERSIONS", "DEFAULT", "UPDATED AT")
|
|
@@ -64,7 +65,7 @@ def pagination(command: list[str], args: argparse.Namespace, cursor: object) ->
|
|
|
64
65
|
command.extend(['--limit', str(args.limit), '--cursor=' + str(cursor)])
|
|
65
66
|
fields = {'dataset': ('type', 'query'),
|
|
66
67
|
'data': ('type', 'ref', 'job_id', 'trial_id'),
|
|
67
|
-
'checkpoint': ('job_id', '
|
|
68
|
+
'checkpoint': ('job_id', 'trial_id'), 'profile': ('name',)}
|
|
68
69
|
for field in fields.get(args.group, ()):
|
|
69
70
|
if getattr(args, field, None) is not None:
|
|
70
71
|
if field == 'query':
|
envloop_data/client.py
CHANGED
|
@@ -194,7 +194,7 @@ class Runners:
|
|
|
194
194
|
source_ref_kind: str = 'branch', dry_run: bool = False):
|
|
195
195
|
"""Publish a Runner package directory as the immutable revision NAME@REVISION.
|
|
196
196
|
|
|
197
|
-
This is `client.data.create(
|
|
197
|
+
This is `client.data.create(type='runner', ...)` with the native manifest built
|
|
198
198
|
from `directory` (runner.toml plus its main.py or main.sh entrypoint): the
|
|
199
199
|
platform stores the bytes, derives the package and index SHA-256, creates the
|
|
200
200
|
Runner asset on first use and registers the revision. `revision` is the full
|
|
@@ -219,7 +219,7 @@ class Runners:
|
|
|
219
219
|
raise RemoteError('RUNNER_SOURCE_REF_INVALID')
|
|
220
220
|
name, manifest, files, executables = runner_package(directory, name=name, executables=executables)
|
|
221
221
|
ref = f'envloop://runners/{name}@{revision}'
|
|
222
|
-
publication = Data(self._server).create(
|
|
222
|
+
publication = Data(self._server).create(type='runner', ref=ref, manifest=manifest, files=files,
|
|
223
223
|
executables=executables, dry_run=dry_run)
|
|
224
224
|
if dry_run:
|
|
225
225
|
return publication
|
envloop_data/data.py
CHANGED
|
@@ -114,10 +114,10 @@ class Data:
|
|
|
114
114
|
raise ValueError('limit must be between 1 and 100')
|
|
115
115
|
return path + '?' + urlencode({key: value for key, value in params.items() if value is not None})
|
|
116
116
|
|
|
117
|
-
def list(self, *,
|
|
118
|
-
if
|
|
119
|
-
raise ValueError('select a Data
|
|
120
|
-
return self.transport.request('GET', self._query(self._path(),
|
|
117
|
+
def list(self, *, type: Literal['dataset', 'artifact', 'checkpoint', 'runner', 'recipe'], ref: str | None = None, job_id: str | None = None, trial_id: str | None = None, limit: int = 25, cursor: str | None = None) -> dict[str, Any]:
|
|
118
|
+
if type not in ('dataset', 'artifact', 'checkpoint', 'runner', 'recipe') or (type != 'artifact' and (job_id or trial_id)):
|
|
119
|
+
raise ValueError('select a Data type and appropriate owner filters')
|
|
120
|
+
return self.transport.request('GET', self._query(self._path(), type=type, ref=ref, job_id=job_id, trial_id=trial_id, limit=limit, cursor=cursor))
|
|
121
121
|
|
|
122
122
|
def get(self, data_id: str) -> dict[str, Any]:
|
|
123
123
|
return self.transport.request('GET', self._path(data_id))
|
|
@@ -131,16 +131,16 @@ class Data:
|
|
|
131
131
|
from envhub.ans.proto import ANSError, DatasetRef, InvalidManifest, parse_uri
|
|
132
132
|
|
|
133
133
|
reference = parse_uri(uri)
|
|
134
|
-
|
|
134
|
+
data_types = {'datasets':'dataset', 'artifacts':'artifact', 'model':'checkpoint',
|
|
135
135
|
'runners':'runner', 'recipes':'recipe'}
|
|
136
|
-
if reference.kind not in
|
|
136
|
+
if reference.kind not in data_types or reference.uri != uri:
|
|
137
137
|
raise ValueError('select a complete resource ANS URI')
|
|
138
138
|
if isinstance(reference, DatasetRef) and (not isinstance(split, str) or not split):
|
|
139
139
|
raise ValueError('Dataset download requires a split')
|
|
140
140
|
if not isinstance(reference, DatasetRef) and split is not None:
|
|
141
141
|
raise ValueError('split is only supported for Dataset')
|
|
142
142
|
endpoint = self._path() + '/download'
|
|
143
|
-
parameters = {'
|
|
143
|
+
parameters = {'type': data_types[reference.kind], 'ref': uri, 'split': split}
|
|
144
144
|
plan = self.transport.request('GET', self._query(endpoint, **parameters))
|
|
145
145
|
from envhub.ans.client import validate_download_plan
|
|
146
146
|
try:
|
|
@@ -179,36 +179,36 @@ class Data:
|
|
|
179
179
|
return {'ref': uri, 'split': split, 'content_digest': plan['content_digest'],
|
|
180
180
|
'directory': str(target), 'verified': True}
|
|
181
181
|
|
|
182
|
-
def create(self, *,
|
|
182
|
+
def create(self, *, type: str, ref: str | None = None, manifest: dict[str, Any] | None = None, files: dict[str, Any] | None = None, model: str | None = None, revision: str | None = None,
|
|
183
183
|
executables: Sequence[str] = (), dry_run: bool = False, idempotency_key: str | None = None):
|
|
184
184
|
"""Register native content or frozen public-HF metadata in this project."""
|
|
185
185
|
from envloop_data.data_publications import hf_source
|
|
186
186
|
|
|
187
|
-
source = hf_source(
|
|
187
|
+
source = hf_source(type, model, revision, ref=ref, manifest=manifest, files=files,
|
|
188
188
|
executables=executables, dry_run=dry_run)
|
|
189
189
|
if source is not None:
|
|
190
190
|
result = self.transport.request('POST', self._path(), source)
|
|
191
|
-
return result if dry_run else self._native_result(result,
|
|
192
|
-
return self._publish(
|
|
191
|
+
return result if dry_run else self._native_result(result, type)
|
|
192
|
+
return self._publish(type, ref, manifest, files, dry_run,
|
|
193
193
|
executables=executables, idempotency_key=idempotency_key)
|
|
194
194
|
|
|
195
195
|
def update(self, data_id: str, *, ref: str | None = None, manifest: dict[str, Any] | None = None, files: dict[str, Any] | None = None, model: str | None = None, revision: str | None = None,
|
|
196
|
-
executables: Sequence[str] = (),
|
|
196
|
+
executables: Sequence[str] = (), type: str | None = None, dry_run: bool = False, idempotency_key: str | None = None):
|
|
197
197
|
"""Publish a new revision of the same asset, preserving its previous revision."""
|
|
198
198
|
from envloop_data.data_publications import hf_source
|
|
199
199
|
|
|
200
|
-
source = hf_source('checkpoint' if
|
|
200
|
+
source = hf_source('checkpoint' if type is None else type, model, revision, ref=ref, manifest=manifest, files=files,
|
|
201
201
|
executables=executables, dry_run=dry_run)
|
|
202
202
|
resource = self.get(data_id)
|
|
203
|
-
if
|
|
204
|
-
raise ValueError('update must preserve the publication
|
|
203
|
+
if type is not None and type != resource['type']:
|
|
204
|
+
raise ValueError('update must preserve the publication type')
|
|
205
205
|
if source is not None:
|
|
206
|
-
if (resource['
|
|
206
|
+
if (resource['type'] != 'checkpoint' or resource.get('metadata_only') is not True
|
|
207
207
|
or resource.get('name') != model or not resource.get('model_uri')):
|
|
208
208
|
raise ValueError('HF update must preserve the native model identity')
|
|
209
209
|
result = self.transport.request('POST', self._path(data_id) + '/revisions', source)
|
|
210
|
-
return result if dry_run else self._native_result(result, resource['
|
|
211
|
-
return self._publish(resource['
|
|
210
|
+
return result if dry_run else self._native_result(result, resource['type'])
|
|
211
|
+
return self._publish(resource['type'], ref, manifest, files, dry_run,
|
|
212
212
|
parent_id=data_id, executables=executables, idempotency_key=idempotency_key)
|
|
213
213
|
|
|
214
214
|
def delete(self, data_id: str, *, dry_run: bool = False):
|
|
@@ -217,9 +217,9 @@ class Data:
|
|
|
217
217
|
return self.transport.request('DELETE', self._path(data_id) + ('?dry_run=true' if dry_run else ''))
|
|
218
218
|
|
|
219
219
|
@staticmethod
|
|
220
|
-
def _native_result(result: Any,
|
|
220
|
+
def _native_result(result: Any, data_type: str):
|
|
221
221
|
resource = result.get('resource', result) if isinstance(result, dict) else None
|
|
222
|
-
if (isinstance(resource, dict) and resource.get('
|
|
222
|
+
if (isinstance(resource, dict) and resource.get('type') == data_type
|
|
223
223
|
and resource.get('native_registered') is True and resource.get('native_ready') is True
|
|
224
224
|
and isinstance(resource.get('data_id', resource.get('id')), str)
|
|
225
225
|
and re.fullmatch(r'ans_[A-Za-z0-9_-]+', resource.get('data_id', resource.get('id')))):
|
|
@@ -231,37 +231,37 @@ class Data:
|
|
|
231
231
|
error.staging_id = staging
|
|
232
232
|
raise error
|
|
233
233
|
|
|
234
|
-
def _publish(self,
|
|
234
|
+
def _publish(self, data_type: str, ref: str | None, manifest: dict[str, Any] | None, files: dict[str, Any] | None, dry_run: bool, *, parent_id: str | None = None, executables: Sequence[str] = (), idempotency_key: str | None = None):
|
|
235
235
|
from envloop_data.data_publications import (
|
|
236
236
|
INLINE_BYTES,
|
|
237
|
-
|
|
237
|
+
TYPES,
|
|
238
238
|
executable_files,
|
|
239
239
|
prepare,
|
|
240
240
|
)
|
|
241
241
|
|
|
242
|
-
if
|
|
243
|
-
raise ValueError('select a publication
|
|
244
|
-
executables = executable_files(
|
|
242
|
+
if data_type not in TYPES or not isinstance(ref, str) or not ref or type(dry_run) is not bool:
|
|
243
|
+
raise ValueError('select a publication type, immutable ANS ref and boolean dry_run')
|
|
244
|
+
executables = executable_files(data_type, manifest, executables)
|
|
245
245
|
with prepare(manifest, files) as (manifest, entries, payload, total, digest):
|
|
246
246
|
if total <= INLINE_BYTES and len(entries) <= 100:
|
|
247
247
|
encoded = {entry['path']: base64.b64encode(payload.read(cast(int, entry['size']))).decode() for entry in entries}
|
|
248
|
-
body: dict[str, Any] = {'
|
|
248
|
+
body: dict[str, Any] = {'type': data_type, 'ref': ref, 'manifest': manifest, 'files': encoded, 'dry_run': dry_run}
|
|
249
249
|
if executables:
|
|
250
250
|
body['executables'] = executables
|
|
251
251
|
path = self._path(parent_id) + '/revisions' if parent_id else self._path()
|
|
252
252
|
result = self.transport.request('POST', path, body)
|
|
253
|
-
return result if dry_run else self._native_result(result,
|
|
253
|
+
return result if dry_run else self._native_result(result, data_type)
|
|
254
254
|
request_key = uuid4().hex if idempotency_key is None else idempotency_key
|
|
255
255
|
identifier = None
|
|
256
256
|
try:
|
|
257
|
-
upload = self.create_upload(
|
|
257
|
+
upload = self.create_upload(type=data_type, ref=ref, manifest=manifest, payload_sha256=digest,
|
|
258
258
|
idempotency_key=request_key, parent_id=parent_id,
|
|
259
259
|
executables=executables, dry_run=dry_run)
|
|
260
260
|
if dry_run:
|
|
261
261
|
return upload
|
|
262
262
|
identifier = upload.get('upload_id')
|
|
263
263
|
if upload.get('state') == 'committed':
|
|
264
|
-
return self._native_result(upload,
|
|
264
|
+
return self._native_result(upload, data_type)
|
|
265
265
|
identifier = upload['upload_id']
|
|
266
266
|
part_bytes = upload['limits']['part_bytes']
|
|
267
267
|
if type(part_bytes) is not int or not 0 < part_bytes <= INLINE_BYTES:
|
|
@@ -278,7 +278,7 @@ class Data:
|
|
|
278
278
|
self.upload_part(identifier, number, chunk)
|
|
279
279
|
if existing:
|
|
280
280
|
raise RemoteError('DATA_UPLOAD_CONFLICT')
|
|
281
|
-
return self._native_result(self.complete_upload(identifier),
|
|
281
|
+
return self._native_result(self.complete_upload(identifier), data_type)
|
|
282
282
|
except BaseException as error:
|
|
283
283
|
# Keep server state recoverable; do not silently abort another
|
|
284
284
|
# process's resumable upload or lose its reservation identifier.
|
|
@@ -289,16 +289,16 @@ class Data:
|
|
|
289
289
|
cast(Any, error).upload_id = identifier
|
|
290
290
|
raise
|
|
291
291
|
|
|
292
|
-
def create_upload(self, *,
|
|
292
|
+
def create_upload(self, *, type: str, ref: str | None, manifest: dict[str, Any] | None, payload_sha256: str, idempotency_key: str, parent_id: str | None = None,
|
|
293
293
|
executables: Sequence[str] = (), dry_run: bool = False):
|
|
294
|
-
from envloop_data.data_publications import
|
|
294
|
+
from envloop_data.data_publications import TYPES, executable_files
|
|
295
295
|
|
|
296
|
-
if (
|
|
296
|
+
if (type not in TYPES or not isinstance(ref, str) or not ref or not isinstance(dry_run, bool)
|
|
297
297
|
or not isinstance(payload_sha256, str) or not re.fullmatch(r'[a-f0-9]{64}', payload_sha256)
|
|
298
298
|
or not isinstance(idempotency_key, str) or not re.fullmatch(r'[A-Za-z0-9_.:-]{1,128}', idempotency_key)):
|
|
299
299
|
raise ValueError('invalid upload metadata or idempotency key')
|
|
300
|
-
executables = executable_files(
|
|
301
|
-
body: dict[str, Any] = dict(
|
|
300
|
+
executables = executable_files(type, manifest, executables)
|
|
301
|
+
body: dict[str, Any] = dict(type=type, ref=ref, manifest=manifest, payload_sha256=payload_sha256, dry_run=dry_run)
|
|
302
302
|
if executables:
|
|
303
303
|
body['executables'] = executables
|
|
304
304
|
if parent_id is not None:
|
envloop_data/data_cli.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from envloop_data.data_publications import (
|
|
12
12
|
INLINE_BYTES,
|
|
13
|
-
|
|
13
|
+
TYPES,
|
|
14
14
|
open_file,
|
|
15
15
|
prepare,
|
|
16
16
|
storage_files,
|
|
@@ -20,7 +20,7 @@ from envloop_data.data_publications import (
|
|
|
20
20
|
def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]", listing: Callable[[Any], argparse.ArgumentParser]):
|
|
21
21
|
data = groups.add_parser('data', help='Manage Project ANS resources and verified downloads').add_subparsers(dest='action', required=True)
|
|
22
22
|
command = listing(data)
|
|
23
|
-
command.add_argument('--type', required=True, choices=[*
|
|
23
|
+
command.add_argument('--type', required=True, choices=[*TYPES, 'artifact'])
|
|
24
24
|
for option in ('ref', 'job-id', 'trial-id'):
|
|
25
25
|
command.add_argument('--' + option)
|
|
26
26
|
for action in ('get', 'files'):
|
|
@@ -33,7 +33,7 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]",
|
|
|
33
33
|
command.set_defaults(_list_view=True)
|
|
34
34
|
for action in ('create', 'update'):
|
|
35
35
|
command = data.add_parser(action, help='Register native content or HF metadata' if action == 'create' else 'Register a new immutable revision')
|
|
36
|
-
command.add_argument('--type', required=action == 'create', choices=
|
|
36
|
+
command.add_argument('--type', required=action == 'create', choices=TYPES)
|
|
37
37
|
if action == 'update':
|
|
38
38
|
command.add_argument('data_id', metavar='DATA_ID')
|
|
39
39
|
publication_arguments(command, source=True)
|
|
@@ -51,7 +51,7 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]",
|
|
|
51
51
|
command.add_argument('--json', action='store_true')
|
|
52
52
|
uploads = data.add_parser('upload', help='Explicit resumable upload lifecycle').add_subparsers(dest='upload_action', required=True)
|
|
53
53
|
command = uploads.add_parser('create', help='Verify local input and reserve a multipart upload')
|
|
54
|
-
command.add_argument('--type', choices=
|
|
54
|
+
command.add_argument('--type', choices=TYPES, required=True)
|
|
55
55
|
publication_arguments(command)
|
|
56
56
|
command.add_argument('--idempotency-key', required=True)
|
|
57
57
|
command.add_argument('--parent-id', help='Existing publication when creating a new revision')
|
|
@@ -83,15 +83,19 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]",
|
|
|
83
83
|
command.add_argument('--json', action='store_true')
|
|
84
84
|
|
|
85
85
|
|
|
86
|
+
MANIFEST_HELP = ('Native JSON content manifest; a record Dataset source.repository is https://github.com/OWNER/REPO '
|
|
87
|
+
'or https://huggingface.co/datasets/ORG/NAME, with source.commit the full commit')
|
|
88
|
+
|
|
89
|
+
|
|
86
90
|
def publication_arguments(command: argparse.ArgumentParser, *, source: bool = False):
|
|
87
91
|
command.add_argument('--ref', required=not source, help='Exact immutable ANS URI')
|
|
88
92
|
if source:
|
|
89
93
|
inputs = command.add_mutually_exclusive_group(required=True)
|
|
90
|
-
inputs.add_argument('--manifest', type=Path, help=
|
|
94
|
+
inputs.add_argument('--manifest', type=Path, help=MANIFEST_HELP)
|
|
91
95
|
inputs.add_argument('--model', help='Public Hugging Face model namespace/name; metadata only')
|
|
92
96
|
command.add_argument('--revision', help='Explicit HF source ref; the server freezes its full commit')
|
|
93
97
|
else:
|
|
94
|
-
command.add_argument('--manifest', type=Path, required=True, help=
|
|
98
|
+
command.add_argument('--manifest', type=Path, required=True, help=MANIFEST_HELP)
|
|
95
99
|
command.add_argument('--directory', type=Path, required=not source, help='Directory containing exactly the declared files')
|
|
96
100
|
command.add_argument('--executable', action='append', dest='executables', default=[],
|
|
97
101
|
help='Declared Runner file that must be executable; repeat for each path')
|
|
@@ -128,7 +132,7 @@ def publication_input(args: argparse.Namespace):
|
|
|
128
132
|
|
|
129
133
|
def execute(data: Any, args: argparse.Namespace):
|
|
130
134
|
if args.action == 'list':
|
|
131
|
-
return data.list(
|
|
135
|
+
return data.list(type=args.type, ref=args.ref, job_id=args.job_id, trial_id=args.trial_id, limit=args.limit, cursor=args.cursor)
|
|
132
136
|
if args.action == 'get':
|
|
133
137
|
return {'resource': data.get(args.data_id), 'files': data.files(args.data_id, limit=args.limit, cursor=args.cursor)}
|
|
134
138
|
if args.action == 'files':
|
|
@@ -148,8 +152,8 @@ def execute(data: Any, args: argparse.Namespace):
|
|
|
148
152
|
manifest, files = publication_input(args)
|
|
149
153
|
options.update(ref=args.ref, manifest=manifest, files=files, executables=args.executables)
|
|
150
154
|
if args.action == 'create':
|
|
151
|
-
return data.create(
|
|
152
|
-
return data.update(args.data_id,
|
|
155
|
+
return data.create(type=args.type, **options)
|
|
156
|
+
return data.update(args.data_id, type=args.type, **options)
|
|
153
157
|
if args.action == 'register':
|
|
154
158
|
return register(data, args)
|
|
155
159
|
if args.action == 'registration':
|
|
@@ -160,7 +164,7 @@ def execute(data: Any, args: argparse.Namespace):
|
|
|
160
164
|
if args.upload_action == 'create':
|
|
161
165
|
manifest, files = publication_input(args)
|
|
162
166
|
with prepare(manifest, files) as (manifest, _, _, _, digest):
|
|
163
|
-
return data.create_upload(
|
|
167
|
+
return data.create_upload(type=args.type, ref=args.ref, manifest=manifest, payload_sha256=digest,
|
|
164
168
|
idempotency_key=args.idempotency_key, parent_id=args.parent_id,
|
|
165
169
|
executables=args.executables, dry_run=args.dry_run)
|
|
166
170
|
if args.upload_action == 'part':
|
|
@@ -11,7 +11,7 @@ from contextlib import contextmanager
|
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from typing import Any
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
TYPES = ('dataset', 'checkpoint', 'runner', 'recipe')
|
|
15
15
|
INLINE_BYTES = 8 * 1024 * 1024
|
|
16
16
|
MAX_FILE = 512 * 1024 * 1024
|
|
17
17
|
MAX_TOTAL = 1024 * 1024 * 1024
|
|
@@ -50,23 +50,23 @@ def storage_files(manifest: dict[str, Any]) -> list[dict[str, Any]]:
|
|
|
50
50
|
return sorted(projected, key=lambda item: item['path'])
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def executable_files(
|
|
53
|
+
def executable_files(data_type: str, manifest: Any, executables: Sequence[str]) -> list[str]:
|
|
54
54
|
"""Explicit Runner inventory; do not modify its immutable native manifest."""
|
|
55
55
|
if not isinstance(executables, (tuple, list)):
|
|
56
56
|
raise ValueError('executables must be a sequence of declared Runner paths')
|
|
57
57
|
entries = storage_files(manifest)
|
|
58
58
|
paths = {entry['path'] for entry in entries}
|
|
59
59
|
if (any(not isinstance(path, str) or path not in paths for path in executables)
|
|
60
|
-
or len(set(executables)) != len(executables) or executables and
|
|
60
|
+
or len(set(executables)) != len(executables) or executables and data_type != 'runner'):
|
|
61
61
|
raise ValueError('executables must select distinct declared Runner files')
|
|
62
62
|
return sorted(executables)
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def hf_source(
|
|
65
|
+
def hf_source(data_type: str, model: str | None, revision: str | None, *, ref: Any, manifest: Any, files: Any, executables: Any,
|
|
66
66
|
dry_run: bool):
|
|
67
67
|
if model is None and revision is None:
|
|
68
68
|
return None
|
|
69
|
-
if (
|
|
69
|
+
if (data_type != 'checkpoint' or ref is not None or manifest is not None or files is not None
|
|
70
70
|
or executables or type(dry_run) is not bool
|
|
71
71
|
or not isinstance(model, str) or len(model) > 193
|
|
72
72
|
or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9._-]{0,95}/[A-Za-z0-9][A-Za-z0-9._-]{0,95}', model)
|
|
@@ -74,7 +74,7 @@ def hf_source(kind: str, model: str | None, revision: str | None, *, ref: Any, m
|
|
|
74
74
|
or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9._/-]*', revision) or '..' in revision
|
|
75
75
|
or any(part in ('', '.') for part in revision.split('/'))):
|
|
76
76
|
raise ValueError('HF metadata requires checkpoint model and explicit revision, without content inputs')
|
|
77
|
-
return {'
|
|
77
|
+
return {'type': 'checkpoint', 'source': {'type': 'hf', 'model': model, 'revision': revision}, 'dry_run': dry_run}
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
@contextmanager
|
envloop_data/data_upload.py
CHANGED
|
@@ -234,7 +234,7 @@ class Registrations:
|
|
|
234
234
|
if identity.get('name') != dataset or identity.get('version') != version:
|
|
235
235
|
raise _invalid(f'dataset.toml declares {identity.get("name")}@{identity.get("version")}, not {dataset}@{version}')
|
|
236
236
|
size, sha256 = _digest(bundle)
|
|
237
|
-
body = {'
|
|
237
|
+
body = {'type': 'dataset', 'ref': f'envloop://datasets/{dataset}@{version}', 'payload_sha256': sha256,
|
|
238
238
|
'manifest': {'schema': 'envhub.artifact/v1', 'kind': 'file', 'metadata': BUNDLE,
|
|
239
239
|
'files': [{'path': name, 'size': size, 'sha256': sha256}]}}
|
|
240
240
|
workspace, project = self.data._scope()
|
|
@@ -62,7 +62,7 @@ class Datasets:
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
def _checkpoint_matches(checkpoint: str, item: dict[str, Any]) -> bool:
|
|
65
|
-
if checkpoint in {item.get('checkpoint_id'), item.get('uri'), item.get('model_uri')}:
|
|
65
|
+
if checkpoint in {item.get('resource_id'), item.get('checkpoint_id'), item.get('uri'), item.get('model_uri')}:
|
|
66
66
|
return True
|
|
67
67
|
parsed = urlsplit(checkpoint)
|
|
68
68
|
if parsed.scheme not in {'envloop', 'tinker'} or parsed.query or parsed.fragment:
|
|
@@ -133,13 +133,13 @@ class Checkpoints:
|
|
|
133
133
|
def delete(self, checkpoint_id: str) -> Any:
|
|
134
134
|
return self.transport.request('DELETE', f"/v1/checkpoints/{quote(checkpoint_id, safe='')}")
|
|
135
135
|
|
|
136
|
-
def download(self, checkpoint: str, directory: str | Path, *, job_id: str | None = None,
|
|
136
|
+
def download(self, checkpoint: str, directory: str | Path, *, job_id: str | None = None, trial_id: str | None = None) -> dict[str, Any]:
|
|
137
137
|
from pathlib import Path
|
|
138
138
|
|
|
139
139
|
directory = Path(directory)
|
|
140
140
|
matches, cursor, seen = cast(list[dict[str, Any]], []), None, set()
|
|
141
141
|
while True:
|
|
142
|
-
page = self.list(job_id=job_id,
|
|
142
|
+
page = self.list(job_id=job_id, trial_id=trial_id, cursor=cursor, limit=100)
|
|
143
143
|
for item in page['items']:
|
|
144
144
|
if _checkpoint_matches(checkpoint, item):
|
|
145
145
|
matches.append(item)
|
|
@@ -166,14 +166,16 @@ class Checkpoints:
|
|
|
166
166
|
if urlsplit(item.get('uri', '')).scheme == 'mock' and item.get('validation_mode') == 'mock':
|
|
167
167
|
return self._download_archive(item, files, directory)
|
|
168
168
|
transport = self.transport
|
|
169
|
+
# The checkpoint ID (resource_id) and a uri are both accepted; sign with the reference the caller gave.
|
|
170
|
+
reference = {'resource_id': checkpoint} if checkpoint == item.get('resource_id') else {'uri': checkpoint}
|
|
169
171
|
|
|
170
172
|
class Content:
|
|
171
173
|
urls: dict[str, Any] | None = None
|
|
172
174
|
|
|
173
175
|
def refresh(self) -> None:
|
|
174
176
|
# Keep the original authorized identity and file hashes across refreshes.
|
|
175
|
-
signed = transport.request('GET', query('/v1/checkpoints/download',
|
|
176
|
-
job_id=item['job_id'],
|
|
177
|
+
signed = transport.request('GET', query('/v1/checkpoints/download', **reference,
|
|
178
|
+
job_id=item['job_id'], trial_id=item.get('trial_id')))
|
|
177
179
|
urls = signed.get('urls', {})
|
|
178
180
|
if (set(names) != set(urls)
|
|
179
181
|
or signed.get('checkpoint_id', item['checkpoint_id']) != item['checkpoint_id']):
|
envloop_data/resource_cli.py
CHANGED
|
@@ -33,8 +33,8 @@ def add_resource_commands(groups: "argparse._SubParsersAction[argparse.ArgumentP
|
|
|
33
33
|
'immutable Runner revision NAME@REVISION. The platform stores the bytes, computes the package and index '
|
|
34
34
|
'SHA-256, creates the Runner on first use and registers the revision; identical retries are idempotent and '
|
|
35
35
|
'changed content for an existing revision is refused. This is el data create --type runner with the native '
|
|
36
|
-
'manifest built for you; use that command to publish an existing manifest. The key needs
|
|
37
|
-
'
|
|
36
|
+
'manifest built for you; use that command to publish an existing manifest. The key needs runners.write '
|
|
37
|
+
'(el auth login issues it to a Developer or Admin), and publish permission on a Runner owned by another Project.')
|
|
38
38
|
register.add_argument('directory', metavar='DIRECTORY', type=Path, help='Runner package directory; every file in it is published')
|
|
39
39
|
register.add_argument('--revision', required=True, help='Full 40- or 64-character source commit, for example $(git rev-parse HEAD)')
|
|
40
40
|
register.add_argument('--name', help='NAMESPACE/NAME; must equal [runner] name in runner.toml (default: that name)')
|
|
@@ -47,12 +47,12 @@ def add_resource_commands(groups: "argparse._SubParsersAction[argparse.ArgumentP
|
|
|
47
47
|
checkpoints = groups.add_parser('checkpoint', help='List and download saved training Checkpoints').add_subparsers(dest='action', required=True)
|
|
48
48
|
command = listing(checkpoints)
|
|
49
49
|
command.add_argument('--job-id', help='Only Checkpoints of this Train Job')
|
|
50
|
-
command.add_argument('--
|
|
50
|
+
command.add_argument('--trial-id', help='Only Checkpoints of this Trial')
|
|
51
51
|
download = checkpoints.add_parser('download', help='Download files and verify their sizes and SHA-256 hashes')
|
|
52
|
-
download.add_argument('checkpoint', metavar='CHECKPOINT', help='Checkpoint ID or uri from `checkpoint list`')
|
|
52
|
+
download.add_argument('checkpoint', metavar='CHECKPOINT', help='Checkpoint ID (cp_…) or uri from `checkpoint list`')
|
|
53
53
|
download.add_argument('directory', metavar='DIRECTORY', type=Path)
|
|
54
54
|
download.add_argument('--job-id')
|
|
55
|
-
download.add_argument('--
|
|
55
|
+
download.add_argument('--trial-id')
|
|
56
56
|
from envloop.lifecycle_cli import wait_options
|
|
57
57
|
delete = checkpoints.add_parser('delete', help='Remove an unreferenced Checkpoint and stored files')
|
|
58
58
|
delete.add_argument('identifier', metavar='CHECKPOINT_ID')
|
|
@@ -83,14 +83,15 @@ def execute(args: argparse.Namespace, client: Any):
|
|
|
83
83
|
result = client.checkpoints.delete(args.identifier)
|
|
84
84
|
return client.operations.wait(result['operation_id'], timeout=args.timeout_seconds) if args.wait else result
|
|
85
85
|
if action == 'download':
|
|
86
|
-
return client.checkpoints.download(args.checkpoint, args.directory, job_id=args.job_id,
|
|
87
|
-
return client.checkpoints.list(job_id=args.job_id,
|
|
86
|
+
return client.checkpoints.download(args.checkpoint, args.directory, job_id=args.job_id, trial_id=args.trial_id)
|
|
87
|
+
return client.checkpoints.list(job_id=args.job_id, trial_id=args.trial_id,
|
|
88
88
|
cursor=args.cursor, limit=args.limit)
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
RUNNER_WRITE_HINT = ('Registering a Runner revision needs a project key with
|
|
92
|
-
'
|
|
93
|
-
'
|
|
91
|
+
RUNNER_WRITE_HINT = ('Registering a Runner revision needs a project key with Runners write (runners.write), and '
|
|
92
|
+
'publish or admin permission when another project owns the Runner. Existing keys keep their '
|
|
93
|
+
'original capabilities; run el auth login without --read-only (Developer or Admin role) to issue '
|
|
94
|
+
'a new key with it.')
|
|
94
95
|
|
|
95
96
|
|
|
96
97
|
def register_runner(client: Any, args: argparse.Namespace):
|
|
@@ -102,7 +103,7 @@ def register_runner(client: Any, args: argparse.Namespace):
|
|
|
102
103
|
executables=args.executables, source_ref=args.source_ref,
|
|
103
104
|
source_ref_kind=args.source_ref_kind, dry_run=args.dry_run)
|
|
104
105
|
except RemoteError as error:
|
|
105
|
-
if error.code
|
|
106
|
+
if error.code in {'ACCESS_DENIED', 'DATA_ACCESS_REQUIRED'} and not error.hint:
|
|
106
107
|
error.hint = RUNNER_WRITE_HINT
|
|
107
108
|
raise
|
|
108
109
|
if not args.dry_run:
|
envloop_experiment/cli.py
CHANGED
|
@@ -5,6 +5,9 @@ import sys
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
|
+
# Single-resource reads and actions print the response as JSON already; scripts may still pass --json.
|
|
9
|
+
JSON_DEFAULT_HELP = "Output the complete response as JSON (the default; accepted for consistency with list commands)"
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
def dataset_reference(value: str):
|
|
10
13
|
name, separator, version = value.rpartition("@")
|
|
@@ -125,9 +128,11 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
125
128
|
help="Dataset name; optional author version (legacy positional form)",
|
|
126
129
|
)
|
|
127
130
|
job_submit.add_argument("--dataset", dest="dataset_option", type=dataset_reference, metavar="NAME[@VERSION]",
|
|
128
|
-
help="Dataset name; default selection uses the platform's pinned snapshot"
|
|
131
|
+
help="Agent: Dataset name; default selection uses the platform's pinned snapshot. "
|
|
132
|
+
"Train recipe (--spec): record Dataset NAMESPACE/NAME@VERSION read in place of records")
|
|
129
133
|
job_submit.add_argument("--config", help="Agent: Dataset subset; Train recipe: named preset; omitted preserves spec or server default")
|
|
130
|
-
job_submit.add_argument("--split", help="one complete split name
|
|
134
|
+
job_submit.add_argument("--split", help="Agent: one complete split name, omitted selects all splits; "
|
|
135
|
+
"Train recipe: the record Dataset split to train on (required with --dataset)")
|
|
131
136
|
job_submit.add_argument("--revision", help="Git branch/tag/commit; must match the platform's pinned snapshot")
|
|
132
137
|
runner_arguments(job_submit)
|
|
133
138
|
job_submit.add_argument("--attempts", type=int)
|
|
@@ -141,8 +146,8 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
141
146
|
job_submit.add_argument("--timeout-seconds", type=wait_seconds,
|
|
142
147
|
help="Agent/Sandbox or Train Runner execution timeout (whole seconds); Train recipe --wait timeout (default: 600)")
|
|
143
148
|
job_submit.add_argument("--max-cost-usd", type=max_cost_usd, metavar="USD",
|
|
144
|
-
help="Agent/Sandbox: Job spend cap in USD (model calls plus Sandbox time);
|
|
145
|
-
"
|
|
149
|
+
help="Agent/Sandbox: Job spend cap in USD (model calls plus Sandbox time); Train recipe "
|
|
150
|
+
"--spec: cap on the GPU time of all Trials. Work stops with error BUDGET_EXCEEDED")
|
|
146
151
|
job_submit.add_argument("--delete-delay-seconds", type=nonnegative_seconds, metavar="SECONDS",
|
|
147
152
|
help="keep each Sandbox (E2B or Fly) after completion for SECONDS (default: 0); cancellation/timeout delete immediately")
|
|
148
153
|
job_submit.add_argument("--wait", action="store_true")
|
|
@@ -153,6 +158,8 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
153
158
|
if action == 'event':
|
|
154
159
|
command.add_argument('--json', action='store_true')
|
|
155
160
|
command.set_defaults(_list_view=True)
|
|
161
|
+
else:
|
|
162
|
+
command.add_argument("--json", action="store_true", help=JSON_DEFAULT_HELP)
|
|
156
163
|
regrade = jobs.add_parser("regrade", help="Re-run only the verifier of sealed compose Trials, optionally with a reward set",
|
|
157
164
|
allow_abbrev=False)
|
|
158
165
|
regrade_source = regrade.add_mutually_exclusive_group(required=True)
|
|
@@ -197,6 +204,12 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
197
204
|
train_log.add_argument("--limit", type=log_page_size, default=200, help="Maximum records per page (default: 200)")
|
|
198
205
|
train_log.add_argument("--follow", action="store_true", help="Drain pages and poll until collection ends; Ctrl-C exits without stopping the Job")
|
|
199
206
|
train_log.add_argument("--json", action="store_true", help="Output the complete page as JSON; --follow emits one page per line (NDJSON)")
|
|
207
|
+
train_metrics = jobs.add_parser("metrics", help="Read or follow a Train Job's per-step metrics")
|
|
208
|
+
train_metrics.add_argument("job_id", metavar="JOB_ID")
|
|
209
|
+
train_metrics.add_argument("--follow", action="store_true",
|
|
210
|
+
help="Print new steps until the Job ends; Ctrl-C exits without stopping the Job")
|
|
211
|
+
train_metrics.add_argument("--json", action="store_true",
|
|
212
|
+
help="Output the complete response as JSON; --follow emits one step per line (NDJSON)")
|
|
200
213
|
from envloop._optional import available
|
|
201
214
|
if available('rsi-loop'):
|
|
202
215
|
from envloop_rsi_loop.cli import add_commands as add_runs
|
|
@@ -210,7 +223,9 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
210
223
|
snapshot = tasks.add_parser("snapshot")
|
|
211
224
|
snapshot.add_argument("trial_id", metavar="TRIAL_ID")
|
|
212
225
|
for action in ("get", "stop", "result"):
|
|
213
|
-
tasks.add_parser(action)
|
|
226
|
+
command = tasks.add_parser(action)
|
|
227
|
+
command.add_argument("trial_id", metavar="TRIAL_ID")
|
|
228
|
+
command.add_argument("--json", action="store_true", help=JSON_DEFAULT_HELP)
|
|
214
229
|
listing.add_argument("--json", action="store_true", help="Output the complete response as JSON")
|
|
215
230
|
artifacts = tasks.add_parser("artifact", help="List or download a Trial's artifacts").add_subparsers(dest="artifact_action", required=True)
|
|
216
231
|
artifact_list = artifacts.add_parser("list", help="List one page of artifacts")
|
|
@@ -409,6 +424,12 @@ def execute_job(args: argparse.Namespace, client: Any, cli: argparse.ArgumentPar
|
|
|
409
424
|
from envloop_experiment.train_log_cli import read_logs
|
|
410
425
|
|
|
411
426
|
raise CommandExit(read_logs(client.jobs, args))
|
|
427
|
+
elif args.action == "metrics":
|
|
428
|
+
from envloop_experiment.train_metrics_cli import read_metrics
|
|
429
|
+
|
|
430
|
+
result = read_metrics(client.training_jobs, args)
|
|
431
|
+
if result is None:
|
|
432
|
+
raise CommandExit(0)
|
|
412
433
|
elif args.action == "run" and args.run_action in {"start", "live", "steer", "stop"}:
|
|
413
434
|
from envloop_rsi_loop.rsi_cli import run_rsi
|
|
414
435
|
|
|
@@ -426,12 +447,13 @@ def execute_job(args: argparse.Namespace, client: Any, cli: argparse.ArgumentPar
|
|
|
426
447
|
else:
|
|
427
448
|
result = getattr(client.jobs, 'status' if args.action == 'get' else args.action)(args.job_id)
|
|
428
449
|
if args.action == 'get':
|
|
450
|
+
from envloop_experiment.train_metrics_cli import availability_line
|
|
429
451
|
from envloop_experiment.train_progress import job_progress, progress_line
|
|
430
452
|
|
|
431
453
|
# The JSON on stdout is unchanged; a Train Job's live progress is a readable stderr line.
|
|
432
|
-
line
|
|
433
|
-
|
|
434
|
-
|
|
454
|
+
for line in (progress_line(job_progress(result)), availability_line(result)):
|
|
455
|
+
if line:
|
|
456
|
+
print(line, file=sys.stderr)
|
|
435
457
|
if args.action in {'get', 'result'}:
|
|
436
458
|
from envloop_experiment.job_cost import cost_line
|
|
437
459
|
|
|
@@ -441,10 +463,27 @@ def execute_job(args: argparse.Namespace, client: Any, cli: argparse.ArgumentPar
|
|
|
441
463
|
print(line, file=sys.stderr)
|
|
442
464
|
from envloop.cli_errors import failure_lines
|
|
443
465
|
|
|
444
|
-
for line in failure_lines(result):
|
|
466
|
+
for line in failure_lines(train_trials(client, result)):
|
|
445
467
|
print(line, file=sys.stderr)
|
|
446
468
|
return result
|
|
447
469
|
|
|
470
|
+
|
|
471
|
+
def train_trials(client: Any, result: Any):
|
|
472
|
+
"""The failed Trials of a failed Train Job as a members view; any other Job is returned unchanged.
|
|
473
|
+
|
|
474
|
+
A Train Job lists only its Trial IDs, so their codes come from one Trial list read. A failed read
|
|
475
|
+
keeps the Job output and exit status: the failure lines are a convenience, not the result.
|
|
476
|
+
"""
|
|
477
|
+
if not isinstance(result, dict) or result.get('type') != 'train' or result.get('status') != 'failed':
|
|
478
|
+
return result
|
|
479
|
+
from envloop.http import RemoteError
|
|
480
|
+
try:
|
|
481
|
+
page = client.trials.list(type='train', job_id=result.get('job_id'), limit=100)
|
|
482
|
+
except (RemoteError, OSError):
|
|
483
|
+
return result
|
|
484
|
+
attempts = [trial for trial in page.get('items') or [] if isinstance(trial, dict)] if isinstance(page, dict) else []
|
|
485
|
+
return {'members': [{'attempts': attempts}]}
|
|
486
|
+
|
|
448
487
|
def execute_trial(args: argparse.Namespace, client: Any, cli: argparse.ArgumentParser):
|
|
449
488
|
if args.action == "artifact":
|
|
450
489
|
if args.artifact_action == "download":
|
envloop_experiment/job_cost.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""One-line view of
|
|
1
|
+
"""One-line view of a Job's ``cost`` and budget; reading never changes the Job."""
|
|
2
2
|
|
|
3
3
|
import math
|
|
4
4
|
from typing import Any
|
|
@@ -17,18 +17,21 @@ def _usd(value: object) -> str:
|
|
|
17
17
|
def cost_line(job: Any) -> str | None:
|
|
18
18
|
"""``Cost (estimate): $5.03 (model $4.12, sandbox $0.91) of a $5.00 budget; stopped: budget reached``.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
A budgeted Train Job reports GPU time instead: ``Cost (estimate): $6.79 (GPU) of a $10.00 budget, $3.21 left``.
|
|
21
|
+
None when the response has no ``cost`` block (Inference Jobs, Train Jobs without a budget, older platforms).
|
|
22
|
+
An unknown part is shown as unknown, never as zero.
|
|
22
23
|
"""
|
|
23
24
|
cost = job.get("cost") if isinstance(job, dict) else None
|
|
24
25
|
if not isinstance(cost, dict):
|
|
25
26
|
return None
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
train = "gpu_usd" in cost
|
|
28
|
+
line = f"Cost (estimate): {_usd(cost.get('total_usd'))} " + (
|
|
29
|
+
"(GPU)" if train else f"(model {_usd(cost.get('model_usd'))}, sandbox {_usd(cost.get('sandbox_usd'))})")
|
|
28
30
|
if cost.get("max_cost_usd") is not None:
|
|
29
31
|
line += f" of a {_usd(cost.get('max_cost_usd'))} budget"
|
|
30
32
|
if cost.get("unmetered") is True:
|
|
31
|
-
line += ";
|
|
33
|
+
line += ("; the GPUs have no price, so the budget cannot be enforced" if train
|
|
34
|
+
else "; some usage has no price, so the budget cannot be enforced")
|
|
32
35
|
elif cost.get("budget_exceeded") is True:
|
|
33
36
|
line += "; stopped: budget reached"
|
|
34
37
|
else:
|
|
@@ -37,5 +40,5 @@ def cost_line(job: Any) -> str | None:
|
|
|
37
40
|
if isinstance(reserved, (int, float)) and not isinstance(reserved, bool) and reserved > 0:
|
|
38
41
|
line += f" ({_usd(reserved)} reserved by running Trials)"
|
|
39
42
|
if cost.get("billing_mode") in {"off", "shadow"}:
|
|
40
|
-
line += f"; sandbox time not charged ({cost['billing_mode']} billing)"
|
|
43
|
+
line += f"; {'GPU' if train else 'sandbox'} time not charged ({cost['billing_mode']} billing)"
|
|
41
44
|
return line
|
|
@@ -14,6 +14,30 @@ class SpecFileError(ValueError):
|
|
|
14
14
|
"""The input file is not a Job JSON object."""
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
def train_dataset(spec: dict[str, Any], dataset: str | None, split: str | None) -> dict[str, Any]:
|
|
18
|
+
"""A Train spec's record Dataset selector: NAME@VERSION and --split replace or complete the file's."""
|
|
19
|
+
if 'runner' in spec:
|
|
20
|
+
raise ValueError('--dataset and --split select recipe training data; a Runner Train spec takes no records')
|
|
21
|
+
if 'records' in spec:
|
|
22
|
+
raise ValueError('--dataset replaces inline records; remove records from the Train spec')
|
|
23
|
+
current = spec.get('dataset', {})
|
|
24
|
+
if not isinstance(current, dict):
|
|
25
|
+
raise ValueError('Train spec dataset must be an object')
|
|
26
|
+
selector = dict(current)
|
|
27
|
+
if dataset is not None:
|
|
28
|
+
name, separator, version = dataset.rpartition('@')
|
|
29
|
+
if not separator:
|
|
30
|
+
raise ValueError('Train --dataset needs an exact NAMESPACE/NAME@VERSION')
|
|
31
|
+
if (name, version) != (current.get('name'), current.get('version')):
|
|
32
|
+
selector.pop('manifest_sha256', None) # a pin belongs to the version it was read from
|
|
33
|
+
selector.update(name=name, version=version)
|
|
34
|
+
if split is not None:
|
|
35
|
+
selector['split'] = split
|
|
36
|
+
if not {'name', 'version', 'split'} <= set(selector):
|
|
37
|
+
raise ValueError('Train --dataset needs NAMESPACE/NAME@VERSION and --split')
|
|
38
|
+
return selector
|
|
39
|
+
|
|
40
|
+
|
|
17
41
|
def spec_request(args: argparse.Namespace):
|
|
18
42
|
if args.trials is not None:
|
|
19
43
|
raise ValueError('--trials cannot be combined with --spec; the file defines its Trial list')
|
|
@@ -42,10 +66,11 @@ def spec_request(args: argparse.Namespace):
|
|
|
42
66
|
def supplied(names: Iterable[str]):
|
|
43
67
|
return [name for name in names if getattr(args, name) is not None]
|
|
44
68
|
if kind in {'train', 'inference'}:
|
|
45
|
-
invalid = supplied(('
|
|
46
|
-
'job_id', 'tag', 'attempts', 'profile', 'delete_delay_seconds'
|
|
69
|
+
invalid = supplied(('source', 'task_id', 'revision',
|
|
70
|
+
'job_id', 'tag', 'attempts', 'profile', 'delete_delay_seconds'))
|
|
47
71
|
if kind == 'inference':
|
|
48
|
-
invalid += supplied(('config', 'priority', 'seed', 'command', 'image',
|
|
72
|
+
invalid += supplied(('dataset', 'dataset_option', 'split', 'config', 'priority', 'seed', 'command', 'image',
|
|
73
|
+
'timeout_seconds', 'max_cost_usd', *SHORTCUT_FIELDS))
|
|
49
74
|
if args.wait:
|
|
50
75
|
invalid.append('wait')
|
|
51
76
|
if invalid:
|
|
@@ -62,12 +87,18 @@ def spec_request(args: argparse.Namespace):
|
|
|
62
87
|
raise ValueError('Train Job spec requires non-empty trials with spec objects')
|
|
63
88
|
if args.priority is not None:
|
|
64
89
|
request['priority'] = args.priority
|
|
90
|
+
if args.max_cost_usd is not None:
|
|
91
|
+
# One cap on the GPU time of all the Job's Trials; the platform refuses it where it cannot enforce it.
|
|
92
|
+
request['budget'] = {'max_cost_usd': args.max_cost_usd}
|
|
65
93
|
runner_fields = ('runner', 'command', 'image', 'timeout_seconds', *SHORTCUT_FIELDS)
|
|
94
|
+
dataset = args.dataset if args.dataset is not None else args.dataset_option
|
|
66
95
|
for trial in trials:
|
|
67
96
|
spec = trial['spec']
|
|
68
97
|
for field in ('seed', 'config'):
|
|
69
98
|
if getattr(args, field) is not None:
|
|
70
99
|
spec[field] = getattr(args, field)
|
|
100
|
+
if dataset is not None or args.split is not None:
|
|
101
|
+
spec['dataset'] = train_dataset(spec, dataset, args.split)
|
|
71
102
|
active_fields = runner_fields
|
|
72
103
|
values = vars(args).copy()
|
|
73
104
|
if not (args.runner or spec.get('runner')) and args.wait:
|
envloop_experiment/train.py
CHANGED
|
@@ -62,6 +62,11 @@ class TrainJobs:
|
|
|
62
62
|
query = urlencode(log_query(source=source, cursor=cursor, tail=tail, limit=limit, process=process))
|
|
63
63
|
return self.transport.request("GET", f"/v1/jobs/{quote(job_id, safe='')}/logs?{query}")
|
|
64
64
|
|
|
65
|
+
def metrics(self, job_id: str) -> dict[str, Any]:
|
|
66
|
+
"""Recorded training metrics; ``loss.per_step`` holds one point per step the trainer reported
|
|
67
|
+
(loss, learning_rate, grad_norm, epoch, tokens_seen, seconds_per_step, observation time ``at``)."""
|
|
68
|
+
return self.transport.request("GET", f"/v1/jobs/{quote(job_id, safe='')}/metrics")
|
|
69
|
+
|
|
65
70
|
def stop(self, job_id: str) -> dict[str, Any]:
|
|
66
71
|
return self._view(self.transport.request('POST', f'/v1/jobs/{quote(job_id, safe="")}/stop'))
|
|
67
72
|
|
|
@@ -72,9 +77,9 @@ class TrainJobs:
|
|
|
72
77
|
page = self.transport.request("GET", "/v1/jobs?" + query)
|
|
73
78
|
return {**page, "items": [self._view(item) for item in page["items"]]}
|
|
74
79
|
|
|
75
|
-
def checkpoints(self, *, job_id: str | None = None,
|
|
80
|
+
def checkpoints(self, *, job_id: str | None = None, trial_id: str | None = None, cursor: str | None = None, limit: int = 25) -> dict[str, Any]:
|
|
76
81
|
query = urlencode({key: value for key, value in {
|
|
77
|
-
"job_id": job_id, "
|
|
82
|
+
"job_id": job_id, "trial_id": trial_id,
|
|
78
83
|
"cursor": cursor, "limit": limit,
|
|
79
84
|
}.items() if value is not None})
|
|
80
85
|
return self.transport.request("GET", "/v1/checkpoints?" + query)
|
|
@@ -12,7 +12,7 @@ from envloop.http import TRANSIENT_CODES, RemoteError
|
|
|
12
12
|
from envloop.terminal import color_enabled, compact_time, safe_text, status_text, style
|
|
13
13
|
from envloop_experiment.train_progress import job_progress, progress_line
|
|
14
14
|
|
|
15
|
-
# While following a Train Job, re-read its progress at most this often (the platform observes it about every
|
|
15
|
+
# While following a Train Job, re-read its progress at most this often (the platform observes it about every 10 s).
|
|
16
16
|
PROGRESS_POLL_SEC = 30
|
|
17
17
|
# Consecutive transient failures `job log --follow` retries before it exits with the error.
|
|
18
18
|
FOLLOW_RETRIES = 3
|
|
@@ -30,10 +30,13 @@ def log_line(item: dict[str, Any], *, color: bool = False):
|
|
|
30
30
|
if item.get("phase"):
|
|
31
31
|
diagnostic += f"; phase={safe_text(item['phase'])}"
|
|
32
32
|
message = f"[{diagnostic}] {message}"
|
|
33
|
+
# The line had no write time and was read after the Job ended: its time is when it was collected.
|
|
34
|
+
backfilled = "(backfilled)" if item.get("backfilled") is True else ""
|
|
33
35
|
if color:
|
|
34
36
|
timestamp = style(timestamp, "2") if timestamp else ""
|
|
37
|
+
backfilled = style(backfilled, "2") if backfilled else ""
|
|
35
38
|
level = status_text(level)
|
|
36
|
-
prefix = " ".join(part for part in (timestamp, level) if part)
|
|
39
|
+
prefix = " ".join(part for part in (timestamp, backfilled, level) if part)
|
|
37
40
|
return f"{prefix} {message}"
|
|
38
41
|
|
|
39
42
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Per-step Train Job metrics as a table or JSON; reading never changes the remote Job."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import math
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
import time
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from envloop.cli_output import display, table
|
|
13
|
+
from envloop.http import TRANSIENT_CODES, RemoteError
|
|
14
|
+
|
|
15
|
+
# The platform records new steps about every 10 s.
|
|
16
|
+
POLL_SEC = 10
|
|
17
|
+
# After the Job ends, its last steps are recorded by one final read on the platform.
|
|
18
|
+
FINAL_READ_DELAY_SEC = 5
|
|
19
|
+
FOLLOW_RETRIES = 3
|
|
20
|
+
TERMINAL = {"completed", "succeeded", "failed", "cancelled", "SUCCEEDED", "FAILED", "CANCELLED"}
|
|
21
|
+
HEADERS = ("STEP", "LOSS", "LEARNING RATE", "GRAD NORM", "EPOCH", "TOKENS", "SECONDS/STEP", "OBSERVED AT")
|
|
22
|
+
# Column widths of --follow, which prints rows before later ones are known.
|
|
23
|
+
WIDTHS = (6, 10, 13, 10, 8, 12, 12, 23)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _number(value: Any) -> float | None:
|
|
27
|
+
return value if isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value) else None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def job_steps(metrics: Any) -> list[dict[str, Any]]:
|
|
31
|
+
"""``loss.per_step`` of a metrics response: one point per recorded step."""
|
|
32
|
+
loss = metrics.get("loss") if isinstance(metrics, dict) else None
|
|
33
|
+
points = loss.get("per_step") if isinstance(loss, dict) else None
|
|
34
|
+
return [point for point in points if isinstance(point, dict) and _number(point.get("step")) is not None] \
|
|
35
|
+
if isinstance(points, list) else []
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _value(value: Any, spec: str) -> str | None:
|
|
39
|
+
number = _number(value)
|
|
40
|
+
return None if number is None else format(int(number) if spec == "d" else number, spec)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _observed(value: Any) -> str | None:
|
|
44
|
+
"""``at`` is Unix time; like every table time it is shown in UTC, labelled (--json keeps the number)."""
|
|
45
|
+
number = _number(value)
|
|
46
|
+
return None if number is None else datetime.fromtimestamp(number, timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def step_row(point: dict[str, Any], *, model: bool = False) -> tuple[object, ...]:
|
|
50
|
+
row = (_value(point.get("step"), "d"), _value(point.get("loss"), ".6g"),
|
|
51
|
+
_value(point.get("learning_rate"), ".4g"), _value(point.get("grad_norm"), ".4g"),
|
|
52
|
+
_value(point.get("epoch"), ".4g"), _value(point.get("tokens_seen"), "d"),
|
|
53
|
+
_value(point.get("seconds_per_step"), ".3g"), _observed(point.get("at")))
|
|
54
|
+
return (point.get("model_id"), *row) if model else row
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _fixed(cells: tuple[object, ...]) -> str:
|
|
58
|
+
return " ".join(display(cell).ljust(width) for cell, width in zip(cells, WIDTHS)).rstrip()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _read(read: Any, args: argparse.Namespace, retries: list[int]) -> Any:
|
|
62
|
+
"""One read; ``--follow`` retries transient failures and names each retry."""
|
|
63
|
+
while True:
|
|
64
|
+
try:
|
|
65
|
+
value = read()
|
|
66
|
+
except RemoteError as error:
|
|
67
|
+
transient = error.code in TRANSIENT_CODES or error.status_code in {429, 500, 502, 503, 504}
|
|
68
|
+
if not args.follow or not transient or retries[0] >= FOLLOW_RETRIES:
|
|
69
|
+
raise
|
|
70
|
+
retries[0] += 1
|
|
71
|
+
delay = error.retry_after if error.retry_after is not None else 2
|
|
72
|
+
code = error.code if re.fullmatch(r"[A-Z0-9_]{1,128}", error.code) else "HTTP_ERROR"
|
|
73
|
+
status = f", HTTP {error.status_code}" if isinstance(error.status_code, int) else ""
|
|
74
|
+
print(f"Metrics read failed ({code}{status}); retry {retries[0]}/{FOLLOW_RETRIES} in {delay:g}s.",
|
|
75
|
+
file=sys.stderr, flush=True)
|
|
76
|
+
time.sleep(delay)
|
|
77
|
+
continue
|
|
78
|
+
retries[0] = 0
|
|
79
|
+
return value
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def read_metrics(train: Any, args: argparse.Namespace) -> Any:
|
|
83
|
+
"""``job metrics``: the response for ``--json``; otherwise prints and returns None."""
|
|
84
|
+
if not args.follow:
|
|
85
|
+
metrics = train.metrics(args.job_id)
|
|
86
|
+
if args.json:
|
|
87
|
+
return metrics
|
|
88
|
+
steps = job_steps(metrics)
|
|
89
|
+
if not steps:
|
|
90
|
+
print("No step metrics recorded yet." if not metrics.get("available") else "No step metrics.",
|
|
91
|
+
file=sys.stderr)
|
|
92
|
+
return None
|
|
93
|
+
models = len({point.get("model_id") for point in steps}) > 1
|
|
94
|
+
print(table(("MODEL", *HEADERS) if models else HEADERS, [step_row(point, model=models) for point in steps]))
|
|
95
|
+
return None
|
|
96
|
+
return follow(train, args)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def follow(train: Any, args: argparse.Namespace) -> None:
|
|
100
|
+
seen: set[tuple[Any, Any]] = set()
|
|
101
|
+
retries = [0]
|
|
102
|
+
header = False
|
|
103
|
+
model = None # the Trials of a group Job run one after another; each starts with its model
|
|
104
|
+
final = False
|
|
105
|
+
try:
|
|
106
|
+
while True:
|
|
107
|
+
job = _read(lambda: train.status(args.job_id), args, retries)
|
|
108
|
+
metrics = _read(lambda: train.metrics(args.job_id), args, retries)
|
|
109
|
+
for point in job_steps(metrics):
|
|
110
|
+
identity = (point.get("model_id"), point.get("step"))
|
|
111
|
+
if identity in seen:
|
|
112
|
+
continue
|
|
113
|
+
seen.add(identity)
|
|
114
|
+
if args.json:
|
|
115
|
+
# One step per line; JSON escaping keeps control sequences out of the terminal.
|
|
116
|
+
print(json.dumps(point, ensure_ascii=True), flush=True)
|
|
117
|
+
continue
|
|
118
|
+
if isinstance(point.get("model_id"), str) and point["model_id"] != model:
|
|
119
|
+
model = point["model_id"]
|
|
120
|
+
print(f"Model {display(model)}", flush=True)
|
|
121
|
+
header = False
|
|
122
|
+
if not header:
|
|
123
|
+
print(_fixed(HEADERS), flush=True)
|
|
124
|
+
header = True
|
|
125
|
+
print(_fixed(step_row(point)), flush=True)
|
|
126
|
+
if final:
|
|
127
|
+
return None
|
|
128
|
+
if isinstance(job, dict) and job.get("status") in TERMINAL:
|
|
129
|
+
final = True # one more read picks up the steps recorded when the Job ended
|
|
130
|
+
time.sleep(FINAL_READ_DELAY_SEC)
|
|
131
|
+
continue
|
|
132
|
+
time.sleep(POLL_SEC)
|
|
133
|
+
except KeyboardInterrupt:
|
|
134
|
+
from envloop._optional import CommandExit
|
|
135
|
+
|
|
136
|
+
raise CommandExit(130) from None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def availability_line(job: Any) -> str | None:
|
|
140
|
+
"""``Step metrics: ...`` for a Train Job response; None for other Jobs."""
|
|
141
|
+
training = job.get("training") if isinstance(job, dict) else None
|
|
142
|
+
if not isinstance(training, dict) or not isinstance(training.get("metrics_available"), bool):
|
|
143
|
+
return None
|
|
144
|
+
if training["metrics_available"]:
|
|
145
|
+
return f"Step metrics: available; read them with: el job metrics {display(job.get('job_id'))}"
|
|
146
|
+
return "Step metrics: not recorded yet"
|
|
@@ -48,5 +48,5 @@ def progress_line(progress: dict[str, Any] | None) -> str | None:
|
|
|
48
48
|
if _number(progress.get("eta_seconds")) is not None:
|
|
49
49
|
parts.append(f"ETA {_duration(progress['eta_seconds'])}")
|
|
50
50
|
if isinstance(progress.get("updated_at"), str):
|
|
51
|
-
parts.append(f"updated {safe_text(compact_time(progress['updated_at']))}")
|
|
51
|
+
parts.append(f"updated {safe_text(compact_time(progress['updated_at'], utc=True))}")
|
|
52
52
|
return "Training progress: " + ", ".join(parts)
|
|
File without changes
|
|
File without changes
|