envloop-cli 1.28.0__tar.gz → 1.30.0__tar.gz
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_cli-1.28.0 → envloop_cli-1.30.0}/PKG-INFO +3 -3
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/README.pypi.md +2 -2
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/_optional.py +1 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/auth_cli.py +3 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/auth_login.py +4 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/cli_errors.py +8 -4
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/cli_output.py +2 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/lifecycle_cli.py +3 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/terminal.py +8 -5
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/cli_output.py +5 -4
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/client.py +2 -2
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/data.py +35 -35
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/data_cli.py +14 -10
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/data_publications.py +6 -6
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/data_upload.py +1 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/navigation_resources.py +7 -5
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/resource_cli.py +12 -11
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/cli.py +48 -9
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/job_cost.py +10 -7
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/job_spec_cli.py +34 -3
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/train.py +7 -2
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/train_log_cli.py +5 -2
- envloop_cli-1.30.0/packages/experiment/envloop_experiment/train_metrics_cli.py +146 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/train_progress.py +1 -1
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/pyproject.toml +2 -2
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/.gitignore +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/auth_workspace.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/client.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/config.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/downloads.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/http.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/navigation_resources.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/profile_secrets.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/resource_cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/resources.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/utils/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/envloop/utils/logging.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/http.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/profile_updates.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/recipes.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/runner_packages.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/cli_output.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/client.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/decision.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/http.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/inference.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/job_logs.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/navigation_resources.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/resource_cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/resources.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/runtime_params.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/sandbox.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/train_runner_cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/experiment/envloop_experiment/training/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/rsi-loop/envloop_rsi_loop/__init__.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/rsi-loop/envloop_rsi_loop/agent_runs.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/rsi-loop/envloop_rsi_loop/cli.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/rsi-loop/envloop_rsi_loop/cli_output.py +0 -0
- {envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/rsi-loop/envloop_rsi_loop/rsi_cli.py +0 -0
|
@@ -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
|
|
@@ -232,7 +232,7 @@ The platform starts the published Revision’s `main.sh` / `main.py` using the R
|
|
|
232
232
|
CLI output uses compact timestamps and highlights statuses and log levels by default on terminals.
|
|
233
233
|
Use `el --no-color job list` or append `--no-color` to a command to disable highlighting, including errors.
|
|
234
234
|
`NO_COLOR=1`, `TERM=dumb`, pipes, and redirected output also disable colors. JSON preserves original values.
|
|
235
|
-
List times
|
|
235
|
+
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`.
|
|
236
236
|
`el job run live RUN --follow --json` emits complete response frames as NDJSON; Ctrl-C stops reading without stopping the Run.
|
|
237
237
|
|
|
238
238
|
## Job-bound decision plugins
|
|
@@ -266,7 +266,7 @@ download a complete registered ANS object directory through EnvHub. Datasets req
|
|
|
266
266
|
authorization the SDK uses GET URLs valid for up to five minutes, verifies file size/SHA-256,
|
|
267
267
|
and installs the directory atomically. Matching platform support is required.
|
|
268
268
|
|
|
269
|
-
A compatible server
|
|
269
|
+
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`:
|
|
270
270
|
|
|
271
271
|
```bash
|
|
272
272
|
el data list --type dataset --json
|
|
@@ -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 = {
|
|
@@ -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")
|
|
@@ -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)
|
|
@@ -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
|
|
|
@@ -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:
|
|
@@ -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)
|
|
@@ -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
|
|
@@ -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':
|
|
@@ -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
|
|
@@ -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:
|
|
@@ -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
|
|
@@ -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()
|
{envloop_cli-1.28.0 → envloop_cli-1.30.0}/packages/data/envloop_data/navigation_resources.py
RENAMED
|
@@ -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']):
|