envloop-cli 1.32.0__py3-none-any.whl → 1.34.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 +18 -4
- envloop/auth_cli.py +48 -8
- envloop/cli.py +6 -13
- envloop/cli_errors.py +101 -22
- envloop/cli_output.py +1 -1
- envloop/http.py +61 -11
- envloop/navigation_resources.py +1 -1
- envloop/profile_secrets.py +46 -1
- envloop/resource_cli.py +31 -4
- envloop/terminal.py +19 -0
- {envloop_cli-1.32.0.dist-info → envloop_cli-1.34.0.dist-info}/METADATA +47 -13
- envloop_cli-1.34.0.dist-info/RECORD +67 -0
- envloop_data/checkpoint_upload.py +94 -0
- envloop_data/cli.py +2 -0
- envloop_data/cli_output.py +74 -13
- envloop_data/client.py +62 -9
- envloop_data/data.py +70 -22
- envloop_data/data_cli.py +155 -20
- envloop_data/data_publications.py +11 -3
- envloop_data/data_upload.py +93 -12
- envloop_data/http.py +6 -2
- envloop_data/navigation_resources.py +24 -0
- envloop_data/profile_updates.py +1 -1
- envloop_data/recipe_packages.py +125 -0
- envloop_data/recipes.py +1 -1
- envloop_data/resource_cli.py +89 -27
- envloop_data/runner_packages.py +41 -1
- envloop_experiment/cli.py +75 -41
- envloop_experiment/client.py +57 -10
- envloop_experiment/http.py +14 -0
- envloop_experiment/inference.py +18 -2
- envloop_experiment/job_spec_cli.py +78 -10
- envloop_experiment/named_profile.py +86 -10
- envloop_experiment/train.py +2 -0
- envloop_experiment/train_runner_cli.py +23 -11
- envloop_rsi_loop/cli.py +49 -29
- envloop_rsi_loop/cli_output.py +77 -43
- envloop_rsi_loop/loop_cli.py +113 -0
- envloop_rsi_loop/loops.py +203 -0
- envloop_cli-1.32.0.dist-info/RECORD +0 -65
- envloop_rsi_loop/agent_runs.py +0 -249
- envloop_rsi_loop/rsi_cli.py +0 -65
- {envloop_cli-1.32.0.dist-info → envloop_cli-1.34.0.dist-info}/WHEEL +0 -0
- {envloop_cli-1.32.0.dist-info → envloop_cli-1.34.0.dist-info}/entry_points.txt +0 -0
envloop/_optional.py
CHANGED
|
@@ -19,19 +19,22 @@ FEATURE_COMMANDS = {
|
|
|
19
19
|
'dataset': 'Discover Datasets, revisions and tasks',
|
|
20
20
|
'data': 'Manage versioned Data resources and verified file downloads',
|
|
21
21
|
'runner': 'Discover available Runner revisions',
|
|
22
|
-
'checkpoint': 'List and download saved training Checkpoints',
|
|
22
|
+
'checkpoint': 'List, share and download saved training Checkpoints',
|
|
23
23
|
'profile': 'Manage platform runtime Profiles',
|
|
24
24
|
},
|
|
25
25
|
'experiment': {
|
|
26
26
|
'job': 'Submit and manage Agent, Sandbox, Train and Inference Jobs',
|
|
27
27
|
'trial': 'Inspect and control existing Trials',
|
|
28
28
|
},
|
|
29
|
+
'rsi-loop': {
|
|
30
|
+
'loop': 'Start, observe and steer RSI Loops and their Iterations',
|
|
31
|
+
},
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
MODULES: dict[str, str] = {
|
|
32
35
|
**dict.fromkeys('data data_publications data_upload data_cli profile_updates recipes'.split(), 'data'),
|
|
33
36
|
**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
|
-
**dict.fromkeys('
|
|
37
|
+
**dict.fromkeys('loops'.split(), 'rsi-loop'),
|
|
35
38
|
}
|
|
36
39
|
CLIENTS = {
|
|
37
40
|
**{name: ('data', 'client') for name in ('ProfileService', 'RunnerService', 'Profiles', 'Runners')},
|
|
@@ -82,6 +85,15 @@ def require_data_dependencies():
|
|
|
82
85
|
raise MissingFeatureError('data')
|
|
83
86
|
|
|
84
87
|
|
|
88
|
+
def missing_feature(error: BaseException) -> MissingFeatureError | None:
|
|
89
|
+
"""Treat a deferred import of the public ANS dependency as the missing [data] extra."""
|
|
90
|
+
if isinstance(error, MissingFeatureError):
|
|
91
|
+
return error
|
|
92
|
+
if isinstance(error, ModuleNotFoundError) and isinstance(error.name, str) and error.name.partition('.')[0] == 'envhub':
|
|
93
|
+
return MissingFeatureError('data')
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
|
|
85
97
|
def feature_module(feature: str, module: str):
|
|
86
98
|
if not available(feature):
|
|
87
99
|
raise IncompleteInstallationError(feature)
|
|
@@ -148,8 +160,8 @@ def client_resource(client: Any, name: str):
|
|
|
148
160
|
return feature_attribute('experiment', 'train', 'TrainJobs')(server)
|
|
149
161
|
if name == 'decision':
|
|
150
162
|
return feature_attribute('experiment', 'decision', 'DecisionClient')(server)
|
|
151
|
-
if name == '
|
|
152
|
-
return feature_attribute('rsi-loop', '
|
|
163
|
+
if name == 'loops':
|
|
164
|
+
return feature_attribute('rsi-loop', 'loops', 'Loops')(client.training_jobs)
|
|
153
165
|
if name in {'endpoints', 'adapters'}:
|
|
154
166
|
return feature_attribute('experiment', 'resources', name.capitalize())(server)
|
|
155
167
|
if name == 'inference':
|
|
@@ -160,6 +172,8 @@ def client_resource(client: Any, name: str):
|
|
|
160
172
|
def execute_command(args: argparse.Namespace, client: Any, cli: Any):
|
|
161
173
|
if args.group in {'job', 'trial'}:
|
|
162
174
|
return getattr(feature_module('experiment', 'cli'), 'execute_' + args.group)(args, client, cli)
|
|
175
|
+
if args.group == 'loop':
|
|
176
|
+
return feature_module('rsi-loop', 'loop_cli').execute(args, client)
|
|
163
177
|
if args.group == 'profile':
|
|
164
178
|
return feature_module('data', 'cli').execute_profile(args, client, cli)
|
|
165
179
|
if args.group in {'data', 'dataset', 'runner', 'checkpoint'}:
|
envloop/auth_cli.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import argparse
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
|
+
import re
|
|
5
6
|
import sys
|
|
6
7
|
from typing import Any, cast
|
|
7
8
|
|
|
@@ -43,8 +44,9 @@ def add_auth_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParse
|
|
|
43
44
|
show.add_argument("--json", action="store_true")
|
|
44
45
|
remove = actions.add_parser("unset", help="Delete a saved field; does not revoke the server key")
|
|
45
46
|
remove.add_argument("field", metavar="FIELD", choices=CONFIG_FIELDS, help=FIELD_HELP)
|
|
46
|
-
status = commands.add_parser("status", help="Inspect local credentials; --check verifies
|
|
47
|
-
status.add_argument("--check", action="store_true",
|
|
47
|
+
status = commands.add_parser("status", help="Inspect local credentials; --check verifies them with the API")
|
|
48
|
+
status.add_argument("--check", action="store_true",
|
|
49
|
+
help="Confirm the API key and scope with GET /v1/me; other read probes are reported as warnings")
|
|
48
50
|
status.add_argument("--json", action="store_true")
|
|
49
51
|
commands.add_parser("logout", help="Remove the saved key for the stored default Base URL (local only)")
|
|
50
52
|
workspace = commands.add_parser("workspace", help="Select and verify the active Workspace")
|
|
@@ -113,13 +115,14 @@ def _report(args: argparse.Namespace, store: ConfigStore):
|
|
|
113
115
|
from .cli import resolve_cli_connection
|
|
114
116
|
|
|
115
117
|
connection = resolve_cli_connection()
|
|
116
|
-
|
|
118
|
+
report: dict[str, Any] = {
|
|
117
119
|
"saved": {**saved, "api_key": "configured" if configured else "missing"},
|
|
118
120
|
"effective": {"api_url": connection.api_url, "workspace_id": connection.workspace_id, "project_id": connection.project_id,
|
|
119
121
|
"api_key": "configured" if connection.api_key is not None else "missing"},
|
|
120
122
|
"sources": connection.sources,
|
|
121
123
|
"check": "not_checked",
|
|
122
|
-
}
|
|
124
|
+
}
|
|
125
|
+
return report, connection
|
|
123
126
|
|
|
124
127
|
|
|
125
128
|
def _verify_key(url: str, key: str, workspace_id: str | None = None, project_id: str | None = None):
|
|
@@ -164,6 +167,8 @@ def _print(report: dict[str, Any], as_json: bool = False) -> None:
|
|
|
164
167
|
print(f"Saved workspace: {report['saved'].get('workspace_id') or 'server default'}")
|
|
165
168
|
print(f"Saved project: {report['saved'].get('project_id') or 'key scope'}")
|
|
166
169
|
print(f"Check: {report['check']}")
|
|
170
|
+
for name, result in report.get("probes", {}).items():
|
|
171
|
+
print(f"Probe {name}: {result}")
|
|
167
172
|
|
|
168
173
|
|
|
169
174
|
def run_auth(args: argparse.Namespace, parser: argparse.ArgumentParser):
|
|
@@ -278,10 +283,14 @@ def run_auth(args: argparse.Namespace, parser: argparse.ArgumentParser):
|
|
|
278
283
|
|
|
279
284
|
try:
|
|
280
285
|
require_remote(connection)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
286
|
+
if connection.api_key is None:
|
|
287
|
+
raise ConfigError('API_KEY_REQUIRED')
|
|
288
|
+
service = HttpService(connection.api_url, api_key=connection.api_key,
|
|
289
|
+
workspace_id=connection.workspace_id, project_id=connection.project_id,
|
|
290
|
+
config=False, environment=False)
|
|
291
|
+
# `/v1/me` is the identity check; it alone decides whether the key works.
|
|
292
|
+
_confirm_identity(service.request("GET", "/v1/me"), connection.workspace_id, connection.project_id)
|
|
293
|
+
report["check"] = "access_confirmed"
|
|
285
294
|
except (ConfigError, RemoteError) as error:
|
|
286
295
|
from .cli_errors import format_error, safe_error_code
|
|
287
296
|
|
|
@@ -291,5 +300,36 @@ def run_auth(args: argparse.Namespace, parser: argparse.ArgumentParser):
|
|
|
291
300
|
_print(report, args.json)
|
|
292
301
|
print(format_error(error), file=sys.stderr)
|
|
293
302
|
return 1
|
|
303
|
+
# Further probes describe service health, not the credential: report them as warnings.
|
|
304
|
+
report["probes"], report["warnings"] = _probe(service)
|
|
294
305
|
_print(report, getattr(args, "json", False))
|
|
306
|
+
for warning in report.get("warnings", []):
|
|
307
|
+
print("Warning: " + warning, file=sys.stderr)
|
|
295
308
|
return 0
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _confirm_identity(response: Any, workspace_id: str | None, project_id: str | None) -> None:
|
|
312
|
+
"""Require API key authentication; when the server names the scope, it must match the selected one."""
|
|
313
|
+
if not isinstance(response, dict) or response.get("auth_method") != "api_key":
|
|
314
|
+
raise ConfigError("AUTH_CHECK_UNCONFIRMED")
|
|
315
|
+
if response.get("workspace") is not None:
|
|
316
|
+
from .auth_workspace import _scope
|
|
317
|
+
|
|
318
|
+
_scope(response, workspace_id, project_id)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def _probe(service: Any) -> tuple[dict[str, str], list[str]]:
|
|
322
|
+
"""Read one Job page; a failure here is a service problem, not a credential problem."""
|
|
323
|
+
from .cli_errors import safe_error_code
|
|
324
|
+
from .http import RemoteError
|
|
325
|
+
|
|
326
|
+
try:
|
|
327
|
+
service.list_jobs(limit=1)
|
|
328
|
+
return {"jobs": "ok"}, []
|
|
329
|
+
except RemoteError as error:
|
|
330
|
+
code = error.code if isinstance(error.code, str) and re.fullmatch(r"[A-Z0-9_]{1,128}", error.code) else safe_error_code(error)
|
|
331
|
+
status = error.status_code if isinstance(error.status_code, int) and 100 <= error.status_code <= 599 else None
|
|
332
|
+
retry = status is None or status >= 500
|
|
333
|
+
return {"jobs": code}, [f"GET /v1/jobs failed with {code}" + (f" (HTTP {status})" if status else "")
|
|
334
|
+
+ "; the API key is authenticated, but this request did not succeed."
|
|
335
|
+
+ (" The service may be degraded; retry later." if retry else "")]
|
envloop/cli.py
CHANGED
|
@@ -14,7 +14,7 @@ from .http import CLI_VERSION
|
|
|
14
14
|
|
|
15
15
|
SECTIONS = {
|
|
16
16
|
'OVERVIEW': ('dashboard',),
|
|
17
|
-
'EXPERIMENT': ('job', 'trial'),
|
|
17
|
+
'EXPERIMENT': ('job', 'trial', 'loop'),
|
|
18
18
|
'DATA': ('dataset', 'data', 'runner', 'checkpoint', 'profile'),
|
|
19
19
|
'MANAGE': ('billing', 'limit', 'member', 'setting'),
|
|
20
20
|
'TOOLS': ('auth', 'help'),
|
|
@@ -227,16 +227,11 @@ def _main(argv: list[str] | None = None):
|
|
|
227
227
|
from ._optional import IncompleteInstallationError, available
|
|
228
228
|
requested = next((value for value in argv if not value.startswith('-')), None)
|
|
229
229
|
feature = cast(dict[str | None, str], {'job': 'experiment', 'trial': 'experiment', 'data': 'data', 'dataset': 'data',
|
|
230
|
-
'runner': 'data', 'checkpoint': 'data', 'profile': 'data'}).get(requested)
|
|
230
|
+
'runner': 'data', 'checkpoint': 'data', 'profile': 'data', 'loop': 'rsi-loop'}).get(requested)
|
|
231
231
|
if feature is not None and not available(feature):
|
|
232
232
|
from .cli_errors import format_error
|
|
233
233
|
print(format_error(IncompleteInstallationError(feature)), file=sys.stderr)
|
|
234
234
|
return 1
|
|
235
|
-
job_action = next((value for value in argv[argv.index('job') + 1:] if not value.startswith('-')), None) if requested == 'job' else None
|
|
236
|
-
if job_action == 'run' and not available('rsi-loop'):
|
|
237
|
-
from .cli_errors import format_error
|
|
238
|
-
print(format_error(IncompleteInstallationError('rsi-loop')), file=sys.stderr)
|
|
239
|
-
return 1
|
|
240
235
|
args = cli.parse_args(argv)
|
|
241
236
|
if args.group == "help":
|
|
242
237
|
cli.parse_args([*args.command, "--help"])
|
|
@@ -265,6 +260,9 @@ def _main(argv: list[str] | None = None):
|
|
|
265
260
|
if args.group == 'setting' and args.action == 'update' and not any(getattr(args, key) is not None for key in ('name', 'slug', 'region')):
|
|
266
261
|
cli.error('provide at least one of --name, --slug or --region')
|
|
267
262
|
try:
|
|
263
|
+
if args.group == 'loop':
|
|
264
|
+
from ._optional import feature_module
|
|
265
|
+
feature_module('rsi-loop', 'loop_cli').validate(args)
|
|
268
266
|
resolved = resolve_cli_connection(args.api_url, args.workspace_id)
|
|
269
267
|
args.api_url = resolved.api_url
|
|
270
268
|
connection = Client.remote(args.api_url, api_key=resolved.api_key, workspace_id=resolved.workspace_id,
|
|
@@ -279,12 +277,7 @@ def _main(argv: list[str] | None = None):
|
|
|
279
277
|
if result.get('status') in {'FAILED', 'CANCELLED', 'RETRYABLE_FAILED', 'BLOCKED'}:
|
|
280
278
|
raise CleanupError(result)
|
|
281
279
|
result = operation_output(result)
|
|
282
|
-
if args.
|
|
283
|
-
from .cli_output import run_output
|
|
284
|
-
|
|
285
|
-
print(run_output(result))
|
|
286
|
-
elif (args.action == 'list' or getattr(args, '_list_view', False)
|
|
287
|
-
or (args.group == 'job' and args.action == 'run' and args.run_action == 'list')) and not args.json:
|
|
280
|
+
if (args.action == 'list' or getattr(args, '_list_view', False)) and not args.json:
|
|
288
281
|
from .cli_output import list_output
|
|
289
282
|
|
|
290
283
|
print(list_output(result, args, cli.prog))
|
envloop/cli_errors.py
CHANGED
|
@@ -5,10 +5,11 @@ for any code, including codes this CLI does not know. `http.error_fields`
|
|
|
5
5
|
already bounded that text to single printable lines and removed the API key.
|
|
6
6
|
Local text below only adds guidance, and is the sole text when the server sent
|
|
7
7
|
none (non-JSON body, network failure). Local failures never reflect exception
|
|
8
|
-
messages.
|
|
8
|
+
messages, except the CLI's own validation refusals (see `validation_message`).
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
import json
|
|
12
|
+
import linecache
|
|
12
13
|
import os
|
|
13
14
|
import re
|
|
14
15
|
import sys
|
|
@@ -17,7 +18,7 @@ from collections.abc import Iterable
|
|
|
17
18
|
from datetime import datetime
|
|
18
19
|
from typing import Any, cast
|
|
19
20
|
|
|
20
|
-
from .http import GATEWAY_TIMEOUT_STATUSES, RemoteError
|
|
21
|
+
from .http import GATEWAY_TIMEOUT_STATUSES, RemoteError, _text
|
|
21
22
|
|
|
22
23
|
_MESSAGES: dict[str, str] = {}
|
|
23
24
|
|
|
@@ -27,7 +28,7 @@ def _register(codes: str, message: str) -> None:
|
|
|
27
28
|
_MESSAGES[code] = message
|
|
28
29
|
|
|
29
30
|
|
|
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
|
|
31
|
+
_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 create). 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
32
|
_register("DATA_NATIVE_INCOMPLETE DATA_NATIVE_UNAVAILABLE", "Native catalog registration is incomplete. Retry the same input after the platform is ready.")
|
|
32
33
|
_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
34
|
_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.")
|
|
@@ -38,7 +39,8 @@ _register("DATA_RESUME_MISMATCH", "The saved transfer no longer matches this res
|
|
|
38
39
|
_register("DATA_HASH_MISMATCH DATA_SIZE_MISMATCH", "The downloaded bytes do not match the published file. The destination was not installed.")
|
|
39
40
|
_register("DATA_REDIRECT_REJECTED", "The API returned a redirect. EL Data requires an authenticated proxy; update or contact the platform administrator.")
|
|
40
41
|
_register("HTTP_ERROR", "The API request failed.")
|
|
41
|
-
_register("
|
|
42
|
+
_register("API_KEY_SCOPE_MISMATCH", "An API key works only in the workspace and project it was issued for. Set ENVLOOP_WORKSPACE_ID and ENVLOOP_PROJECT_ID (or el auth workspace) to the key's own scope named above, or use a key issued in the target project.")
|
|
43
|
+
_register("NOT_FOUND RESOURCE_NOT_FOUND JOB_NOT_FOUND RUNNER_NOT_FOUND DATASET_REVISION_NOT_FOUND PROFILE_NOT_FOUND WORKSPACE_NOT_FOUND CHECKPOINT_NOT_FOUND ARTIFACT_NOT_FOUND", "The requested API resource or route was not found.")
|
|
42
44
|
_register("UNAUTHORIZED UNAUTHENTICATED INVALID_AUTH AUTHENTICATION_REQUIRED AUTHENTICATION_REJECTED API_KEY_REQUIRED", "API key authentication is required or was rejected.")
|
|
43
45
|
_register("FORBIDDEN ACCESS_DENIED AUTHORIZATION_DENIED PERMISSION_DENIED WORKSPACE_ACCESS_DENIED PROJECT_ACCESS_DENIED", "The current credentials do not have permission for this operation.")
|
|
44
46
|
_register("EDGE_REJECTED", "The network edge (Cloudflare) rejected the request before it reached the EnvLoop API; this is not a permission decision. Upgrade envloop-cli, check any proxy or custom User-Agent, or contact support with the HTTP status.")
|
|
@@ -49,10 +51,42 @@ _register("PROFILE_SECRET_NAME_INVALID", "A Secret parameter name must look like
|
|
|
49
51
|
_register("PROFILE_SECRET_VALUE_INVALID", "A Secret parameter value is missing or unusable: it must be non-empty UTF-8 text of at most 64 KiB from a prompt, stdin, an environment variable or a file.")
|
|
50
52
|
_register("PROFILE_MODEL_KEY_UNSUPPORTED", "--model-api-key-stdin and --prompt-model-api-key only set the encrypted key of a managed model connection (params.model_connection). Store other keys as a Secret parameter, for example --secret MODEL_API_KEY=stdin.")
|
|
51
53
|
_register("PROFILE_SECRET_CONFLICT", "Give each Secret parameter once, by --secret only (not also in the Profile file or patch), and read at most one value from stdin.")
|
|
52
|
-
_register("RUNNER_PACKAGE_INVALID", "The Runner package directory is invalid. It needs runner.toml whose [runner] name matches the Runner and has no version,
|
|
53
|
-
_register("RUNNER_REVISION_INVALID", "Use the full lowercase 40- or 64-character source commit as --revision and a NAMESPACE/NAME Runner name.")
|
|
54
|
+
_register("RUNNER_PACKAGE_INVALID", "The Runner package directory is invalid. It needs runner.toml whose [runner] name matches the Runner and has no version, an entrypoint main.py or main.sh in [runner] for v6 or [execution] for historical schemas, at most 100 regular files, no symlinks, and path parts of letters, digits, '_', '.' or '-' that do not start with '.'. v6 declarations must satisfy the EnvHub protocol, including supported types and per-type defaults.")
|
|
55
|
+
_register("RUNNER_REVISION_INVALID", "Use the full lowercase 40- or 64-character source commit, or a local branch or tag name, as --revision and a NAMESPACE/NAME Runner name.")
|
|
56
|
+
_register("RUNNER_REVISION_UNRESOLVED", "--revision names no local branch or tag in the Git checkout that holds DIRECTORY, or Git is unavailable. Fetch or create the branch, or pass the full source commit.")
|
|
57
|
+
_register("RUNNER_PACKAGE_UNCOMMITTED", "DIRECTORY differs from the --revision commit: it has uncommitted changes, untracked files or ignored files, all of which would be published. Commit or remove them, or pass a full commit you vouch for.")
|
|
54
58
|
_register("RUNNER_SOURCE_REF_INVALID", "Use a branch or tag name such as main or v1 with --source-ref-kind branch, tag or commit; HEAD, latest, default, release, '..', spaces and ~^:?*[\\ are not allowed.")
|
|
55
59
|
_register("RUNNER_REVISION_CONFLICT", "The platform catalog holds different package or index hashes for this Runner revision. Publish a new revision instead of changing an existing one.")
|
|
60
|
+
_register("RECIPE_PACKAGE_INVALID RECIPE_DECLARATION_INVALID RECIPE_INVALID", "--directory must hold recipe.toml with schema_version = \"envloop.recipe/v2\" and the tables [recipe] name, types; [runner] name, abi; [source] paths, optional exclude and optional repository (a https://github.com/OWNER/REPO URL if given; omit it for a local-only repository); optional [inputs], [params], [outputs] and [dependencies]. No other top-level tables or keys are allowed.")
|
|
61
|
+
_register("RECIPE_PACKAGE_SCHEMA_RETIRED", "recipe.toml uses the retired envloop.recipe-publication/v3 format. Rewrite it as schema_version = \"envloop.recipe/v2\" with [recipe], [runner] and [source] tables and add entrypoint.sh next to it; published Recipes stay readable.")
|
|
62
|
+
_register("RECIPE_SCHEMA_UNSUPPORTED RECIPE_PACKAGE_SCHEMA_UNSUPPORTED", "Set schema_version = \"envloop.recipe/v2\" at the top of recipe.toml.")
|
|
63
|
+
_register("RECIPE_ABI_UNSUPPORTED", "Set [runner] abi = \"envloop.recipe/1\"; it is the only Recipe ABI for new Recipes.")
|
|
64
|
+
_register("RECIPE_DECLARATION_NOT_FOUND", "The --revision commit has no recipe.toml in --directory. Commit the declaration, or point --directory at the directory that holds it.")
|
|
65
|
+
_register("RECIPE_ENTRYPOINT_NOT_FOUND", "The --revision commit has no entrypoint.sh next to recipe.toml, or it is not a regular file of at most 512 MiB. Commit entrypoint.sh in the same directory as recipe.toml.")
|
|
66
|
+
_register("RECIPE_DECLARATION_CONFLICT", "[source].paths would place another file at the package root path recipe.toml or entrypoint.sh. Narrow paths or list that file in exclude.")
|
|
67
|
+
_register("RECIPE_PATH_NOT_FOUND", "Every [source].paths entry must match files present at the --revision commit, and every exclude entry must name one of the selected files exactly.")
|
|
68
|
+
_register("RECIPE_PATH_INVALID", "Paths in recipe.toml are relative to the repository root and use only letters, digits, '_', '.' or '-' parts that do not start with '.'.")
|
|
69
|
+
_register("RECIPE_FILE_UNSUPPORTED", "Packaged Recipe paths may contain only regular files; remove symlinks and submodules from paths or list them in exclude.")
|
|
70
|
+
_register("RECIPE_PACKAGE_TOO_LARGE", "A Recipe package holds at most 1000 files, 512 MiB per file and 1 GiB in total. Narrow paths or add exclusions.")
|
|
71
|
+
_register("RECIPE_DEPENDENCY_INVALID", "Each [dependencies.SLOT] needs the uri and manifest_sha256 of an already published Recipe, envloop://recipes/NAMESPACE/NAME@SHA256, with the same digest in both.")
|
|
72
|
+
_register("RECIPE_NAME_INVALID", "[recipe] name is NAMESPACE/NAME using letters, digits, '_', '.' or '-'.")
|
|
73
|
+
_register("RECIPE_NAME_MISMATCH", "[recipe] name in recipe.toml must equal the NAMESPACE/NAME of the Recipe URI. Publish with --directory so the URI is derived from recipe.toml.")
|
|
74
|
+
_register("RECIPE_TYPES_INVALID", "[recipe] types is a non-empty list of distinct Job types from agent, sandbox, train and inference.")
|
|
75
|
+
_register("RECIPE_PARAMS_INVALID", "Each [params.NAME] uses type, default, required, description, enum, minimum, maximum or locked (object params also properties and additional_properties); names are lowercase snake_case. Recipe image accepts only a default pinned with @sha256:<digest> and optional description. command, timeout_seconds and max_retries cannot be declared by a Recipe.")
|
|
76
|
+
_register("RECIPE_PARAM_CONFLICT", "A Recipe param may only narrow the Runner's declaration of the same name: same type, tighter range, enum subset, keep Runner locks and required params. Relax the Recipe declaration.")
|
|
77
|
+
_register("RECIPE_INPUTS_INVALID", "Each [inputs.SLOT] has kind (dataset, checkpoint or artifact) and required (true or false); slot names are lowercase, and train_dataset / eval_dataset must be datasets, checkpoint / resume_from_checkpoint checkpoints.")
|
|
78
|
+
_register("RECIPE_OUTPUTS_INVALID", "[outputs] files lists distinct relative paths under $ENVLOOP_OUTPUT_DIR; result.json is always produced and is not listed.")
|
|
79
|
+
_register("RECIPE_AGENT_DEFINITION_NOT_FOUND", "[agent] definition must name a JSON file selected by [source].paths.")
|
|
80
|
+
_register("RECIPE_SOURCE_INVALID RECIPE_SOURCE_MISMATCH", "[source] repository is optional: omit it for a local-only Git repository, or give https://github.com/OWNER/REPO. It is recorded as provenance only and never fetched.")
|
|
81
|
+
_register("RECIPE_INDEX_INVALID RECIPE_INTEGRITY RECIPE_FILE_NOT_SELECTED RECIPE_DEPENDENCY_MISMATCH", "The uploaded Recipe files do not match their content index. Rebuild and publish with el data create --type recipe --directory DIR instead of a hand-written manifest.")
|
|
82
|
+
_register("RECIPE_ABI_MISMATCH", "The Job's Runner Revision does not implement the Recipe ABI envloop.recipe/1. Use a Runner Revision that does, or a Recipe published for this Runner's ABI.")
|
|
83
|
+
_register("RECIPE_TYPE_UNSUPPORTED", "The Job type must be listed in both the Runner's and the Recipe's types. Submit a supported --type or add the type to [recipe] types.")
|
|
84
|
+
_register("RECIPE_PARAM_REQUIRED RUNNER_PARAM_REQUIRED", "A required param has no value. Set it under params in the Job spec (or the Profile); required params never get a default.")
|
|
85
|
+
_register("RECIPE_REVISION_INVALID", "Use a local branch or tag name, or the full lowercase 40- or 64-character commit, as --revision.")
|
|
86
|
+
_register("RECIPE_REVISION_UNRESOLVED", "--revision names no local branch, tag or commit in the Git checkout that holds --directory, or Git is unavailable. Fetch it, or pass the full commit.")
|
|
87
|
+
_register("RECIPE_PACKAGE_UNCOMMITTED", "recipe.toml or a packaged path differs from the --revision branch or tag: it has uncommitted changes or untracked files that would not be published. Commit them, or pass a full commit to publish exactly that commit.")
|
|
88
|
+
_register("RECIPE_READBACK_MISMATCH", "The platform catalog did not return this Recipe as ready with the published manifest digest. Read it with el data list --type recipe --ref URI before retrying.")
|
|
89
|
+
_register("RECIPE_PACKAGE_UNSUPPORTED", "The installed envloop-envhub cannot build Recipe packages. Upgrade envloop-cli[data] to a release that includes it.")
|
|
56
90
|
_register("DATASET_REQUIRED", "Missing Dataset input (--dataset or --source) for this Agent Job.")
|
|
57
91
|
_register("DATASET_CONFIG_REQUIRED", "An explicit Dataset configuration (--config) is required.")
|
|
58
92
|
_register("RUNNER_REQUIRED", "Missing Runner input (--runner) for this Job.")
|
|
@@ -74,6 +108,8 @@ _register("FILE_EXISTS", "The destination already exists.")
|
|
|
74
108
|
_register("FILE_ERROR", "A local file could not be read or written.")
|
|
75
109
|
_register("INVALID_JSON", "The request file is not valid JSON.")
|
|
76
110
|
_register("INVALID_INPUT", "The request or input is invalid.")
|
|
111
|
+
_register("DATA_FILE_REQUIRED", "This resource has several files. Download one with --file FILE_ID; its files are listed below.")
|
|
112
|
+
_register("DATA_FILE_UNAVAILABLE", "This resource has no downloadable file yet. Check its status with `el data get DATA_ID`.")
|
|
77
113
|
_register("INVALID_API_KEY", "The supplied API key has an invalid format.")
|
|
78
114
|
_register("API_URL_REQUIRED INVALID_API_URL", "The API Base URL is missing or invalid.")
|
|
79
115
|
_register("PROJECT_REQUIRED PROJECT_SCOPE_REQUIRED", "This operation requires a project scope.")
|
|
@@ -84,6 +120,7 @@ _register("REGISTRY_CREDENTIAL_EXISTS", "This project already has a credential f
|
|
|
84
120
|
_register("REGISTRY_CREDENTIAL_LIMIT", "The project reached its registry credential limit. Remove an unused credential first.")
|
|
85
121
|
_register("INVALID_REGISTRY_CREDENTIAL", "Use a registry host such as ghcr.io, a repository prefix such as my-org, a username without ':' and a non-empty token.")
|
|
86
122
|
_register("REGISTRY_CREDENTIALS_UNAVAILABLE", "Registry credentials are unavailable on this deployment. Retry later or contact the platform operator.")
|
|
123
|
+
_register("REGISTRY_CREDENTIAL_SCOPE_REQUIRED", "This API key does not carry registry_credentials.write, and existing keys never gain permissions. Only a key issued by el auth login can manage registry credentials: as a project Admin, run el auth login again, then retry.")
|
|
87
124
|
_register("CONCURRENCY_ABOVE_CEILING", "The limit is above the ceiling the platform operator set for this project. Check `el limit get`.")
|
|
88
125
|
_register("INVALID_CONCURRENCY_LIMIT", "Use a whole number from 1 to 10000, or none to clear the project limit.")
|
|
89
126
|
_register("INVALID_PROJECT_ID INVALID_WORKSPACE_ID", "The workspace or project ID has an invalid format.")
|
|
@@ -108,9 +145,18 @@ _register("PROFILE_RUNNER_UNSUPPORTED", "This submission path cannot execute the
|
|
|
108
145
|
_register("PROFILE_ARCHIVED PROFILE_HASH_MISMATCH", "The selected Profile is archived or does not match its frozen version.")
|
|
109
146
|
_register("NAMED_PROFILE_INVALID PROFILE_INPUT_INVALID PROFILE_CHECKPOINT_MODEL_MISMATCH", "The named Profile or input binding is incompatible. Use its declared input slots and allowed parameter replacements.")
|
|
110
147
|
_register("PROFILE_AUTHORIZATION_UNAVAILABLE", "Current Profile authorization could not be verified. Retry the same request after authorization is available.")
|
|
111
|
-
_register("VISIBILITY_CONFLICT", "Visibility changed since it was read. Read the
|
|
112
|
-
_register("VISIBILITY_INVALID", "Choose private or public
|
|
113
|
-
_register("
|
|
148
|
+
_register("VISIBILITY_CONFLICT", "Visibility changed since it was read. Read the current acl_revision again (el data get DATA_ID or el checkpoint get CHECKPOINT_ID) and retry with it, or omit --expected-acl-revision to use the current value. A Profile also needs its current visibility as --expected-visibility.")
|
|
149
|
+
_register("VISIBILITY_INVALID", "Choose private, internal or public with a nonnegative --expected-acl-revision; a Profile takes private or public. A Hugging Face model registration (metadata only) has no visibility: it stays readable only in the project that registered it, so register it in each project that needs it.")
|
|
150
|
+
_register("RECIPE_GRANTS_UNAVAILABLE", "Recipe sharing could not be checked for this request. This is temporary; retry the same request.")
|
|
151
|
+
_register("RECIPE_GRANTS_LIMIT", "This project can read more shared Recipe names than the platform can apply to one request. Retrying will not help; contact a platform operator.")
|
|
152
|
+
_register("VISIBILITY_PUBLIC_REQUIRES_ADMIN", "Only a platform administrator can make a resource public or withdraw public visibility; API keys never act as platform administrators. Use private or internal (this workspace), or ask a platform administrator.")
|
|
153
|
+
_register("RUNNER_REVISION_AMBIGUOUS", "Several projects share different content under this Runner revision. Publish your own copy in this project with el runner create (your copy takes precedence), or ask the owning project to set theirs private with el data set-visibility.")
|
|
154
|
+
_register("CHECKPOINT_REVISION_AMBIGUOUS", "Several projects share different checkpoints under this URI. Copy the one you need into this project (your copy takes precedence), or ask the owning project to set theirs private with el checkpoint set-visibility.")
|
|
155
|
+
_register("DATASET_REVISION_AMBIGUOUS", "Several projects share different content under this Dataset version. el data list --type dataset shows the entry as unavailable with the data_id of each readable copy under CANDIDATES (--json adds owners and digests); select one copy by passing that data_id as --dataset DATA_ID or --input SLOT=DATA_ID. Or pass another explicit NAME@VERSION, publish your own copy in this project with el data create --type dataset (your copy takes precedence), or ask the owning project to set theirs private with el data set-visibility.")
|
|
156
|
+
_register("DATASET_NAMESPACE_UNAVAILABLE", "This registration ran while Dataset namespaces were still reserved or claimed across projects. Datasets are now stored per project and no namespace is reserved: register the same snapshot again (el data register PUBLICATION_ID --runner NAME@REVISION).")
|
|
157
|
+
_register("RESOURCE_IN_USE", "Remove or release the listed references first. A reference listed with a workspace and project belongs to another project that froze your shared copy (for example an endpoint or adapter holding a checkpoint); ask that project to delete or release it. Narrowing visibility does not release a frozen reference.")
|
|
158
|
+
_register("PUBLIC_DEPENDENCY_UNAVAILABLE", "A shared resource needs dependencies at least as readable as itself: a public Recipe needs public dependencies, and an internal Recipe needs dependencies readable in this workspace (internal or public). Change the dependencies' visibility first (el data set-visibility DATA_ID), then retry; private dependencies are never shared automatically.")
|
|
159
|
+
_register("PUBLIC_CONTENT_UNSAFE PUBLICATION_REVIEW_REQUIRED", "Content review failed for one of this name's current revisions, so it cannot be shared. Fix or retire the flagged revision, then retry.")
|
|
114
160
|
_register("CHECKPOINT_AMBIGUOUS", "More than one checkpoint matches this selection.")
|
|
115
161
|
_register("CHECKPOINT_FILES_UNAVAILABLE ARTIFACT_NOT_READY", "The requested download is not available yet.")
|
|
116
162
|
_register("CHECKPOINT_FILES_INVALID ARTIFACT_LISTING_INVALID ARTIFACT_NAME_UNSAFE UNSAFE_ARTIFACT_REDIRECT ARTIFACT_SIZE_MISMATCH ARTIFACT_HASH_MISMATCH", "The download failed a safety or integrity check.")
|
|
@@ -123,9 +169,12 @@ _register("RUNNER_NOT_FOUND", "The Runner reference was not found or is not read
|
|
|
123
169
|
_register("INVALID_SANDBOX_RUNNER", "The Runner revision cannot execute as a standalone Sandbox Job.")
|
|
124
170
|
_register("INVALID_SANDBOX_IMAGE", "The Sandbox image reference is invalid.")
|
|
125
171
|
|
|
126
|
-
_register("
|
|
172
|
+
_register("RSI_LOOP_NOT_FOUND", "No RSI Loop with this LOOP_ID is visible in the current project. List Loops with el loop list.")
|
|
173
|
+
_register("RSI_ITERATION_NOT_FOUND", "The Loop has no Iteration with this number yet. See its Iterations with el loop get LOOP_ID.")
|
|
174
|
+
_register("INVALID_LOOP_ID", "LOOP_ID must be loop_ followed by 32 lower-case hex characters, as el loop list shows it.")
|
|
175
|
+
_register("INVALID_ITERATION", "ITERATION must be a positive integer; Iterations are numbered from 1.")
|
|
127
176
|
_register("INVALID_RSI_REQUEST INVALID_STEER INVALID_DIRECTIVE", "The RSI service rejected the request fields.")
|
|
128
|
-
_register("RSI_CONFLICT
|
|
177
|
+
_register("RSI_CONFLICT RSI_LOOP_NOT_ACTIVE", "A Loop with this name exists, the Loop is not in a state that allows this action, or no loop machine is free.")
|
|
129
178
|
_register("RSI_CONTROL_UNCONFIGURED RSI_CONTROL_UNAVAILABLE RSI_CONTROL_TIMEOUT", "The RSI loop service is not available through this platform right now.")
|
|
130
179
|
|
|
131
180
|
_register("UNSUPPORTED_ADAPTER_SOURCE", 'Register a training checkpoint with {"serving_profile": "NAME", "source": {"type": "train_checkpoint", "uri": "envloop://..."}}. '
|
|
@@ -145,7 +194,7 @@ for _code, _resource in {
|
|
|
145
194
|
"RUNNER_NOT_FOUND": "Runner revision", "DATASET_NOT_FOUND": "Dataset",
|
|
146
195
|
"DATASET_REVISION_NOT_FOUND": "Dataset revision", "CHECKPOINT_NOT_FOUND": "checkpoint",
|
|
147
196
|
"ARTIFACT_NOT_FOUND": "artifact", "WORKSPACE_NOT_FOUND": "workspace",
|
|
148
|
-
"
|
|
197
|
+
"TRIAL_NOT_FOUND": "Trial",
|
|
149
198
|
}.items():
|
|
150
199
|
_register(_code, f"The {_resource} was not found or is not readable in the current scope.")
|
|
151
200
|
|
|
@@ -189,7 +238,7 @@ TEMPORARY_SCOPE_CONFLICT TEMPORARY_SCOPE_EXPIRED TRIAL_IDEMPOTENCY_CONFLICT TRIA
|
|
|
189
238
|
PROFILE_CORRUPT ADAPTER_STORAGE_UNAVAILABLE INSUFFICIENT_BALANCE METHOD_NOT_ALLOWED REQUEST_TOO_LARGE
|
|
190
239
|
BATCH_POLICY_NOT_APPROVED BATCH_PROVIDER_UNAVAILABLE CHECKPOINT_ACCESS_DENIED CHECKPOINT_DOWNLOAD_UNAVAILABLE
|
|
191
240
|
CHECKPOINT_MANAGEMENT_UNAVAILABLE CHECKPOINT_MANAGEMENT_UNSUPPORTED CHECKPOINT_NOT_DURABLE CHECKPOINT_TRIAL_REQUIRED
|
|
192
|
-
CHECKPOINT_SIGNER_UNAVAILABLE INVALID_CHECKPOINT_CURSOR INVALID_CHECKPOINT_TTL
|
|
241
|
+
CHECKPOINT_SIGNER_UNAVAILABLE INVALID_CHECKPOINT_CURSOR INVALID_CHECKPOINT_TTL
|
|
193
242
|
INVALID_EXECUTION_CONFIG INVALID_METRICS_RANGE INVALID_TRAIN_JOB_CURSOR INVALID_TRAIN_JOB_LIST_LIMIT
|
|
194
243
|
INVALID_TRAIN_JOB_METADATA INVALID_TRAIN_JOB_SPEC INVALID_TRAIN_JOB_STATUS LOG_RETENTION_EXPIRED
|
|
195
244
|
TRAINING_RUN_NOT_FOUND TRAIN_JOB_CAPACITY_EXCEEDED TRAIN_JOB_IDEMPOTENCY_CONFLICT TRAIN_JOB_NOT_FOUND
|
|
@@ -233,19 +282,43 @@ def _http_message(status: int | None) -> str:
|
|
|
233
282
|
return _MESSAGES["HTTP_ERROR"]
|
|
234
283
|
|
|
235
284
|
|
|
285
|
+
_OWN_PACKAGES = frozenset({"envloop", "envloop_data", "envloop_experiment", "envloop_rsi_loop"})
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def validation_message(error: BaseException) -> str | None:
|
|
289
|
+
"""The wording of a client-side validation refusal, or None for any other failure.
|
|
290
|
+
|
|
291
|
+
Shown only for a plain `ValueError` constructed by a `raise` statement in this CLI's own
|
|
292
|
+
packages: that text is fixed client wording plus field names or the user's own path. Errors
|
|
293
|
+
from the standard library or dependencies (`int()`, JSON, Unicode), raised from server
|
|
294
|
+
content, or of credential-bearing subclasses (`ConfigError`, `InvalidProfileSecrets`) keep
|
|
295
|
+
the static explanation.
|
|
296
|
+
"""
|
|
297
|
+
if type(error) is not ValueError or not (trace := error.__traceback__):
|
|
298
|
+
return None
|
|
299
|
+
while trace.tb_next:
|
|
300
|
+
trace = trace.tb_next
|
|
301
|
+
module = trace.tb_frame.f_globals.get("__name__")
|
|
302
|
+
if not isinstance(module, str) or module.partition(".")[0] not in _OWN_PACKAGES:
|
|
303
|
+
return None
|
|
304
|
+
if not linecache.getline(trace.tb_frame.f_code.co_filename, trace.tb_lineno).lstrip().startswith("raise "):
|
|
305
|
+
return None
|
|
306
|
+
return _text(str(error), 500)
|
|
307
|
+
|
|
308
|
+
|
|
236
309
|
def safe_error_code(error: Any) -> str:
|
|
237
310
|
"""Select a trusted CLI/report identifier without changing the SDK error."""
|
|
238
|
-
from ._optional import
|
|
311
|
+
from ._optional import missing_feature
|
|
239
312
|
from .config import ConfigError
|
|
240
313
|
from .downloads import ArtifactError
|
|
241
314
|
from .profile_secrets import InvalidProfileSecrets
|
|
242
315
|
from .resources import CleanupError
|
|
243
316
|
|
|
244
|
-
if
|
|
245
|
-
return
|
|
317
|
+
if (feature := missing_feature(error)) is not None:
|
|
318
|
+
return feature.code
|
|
246
319
|
if isinstance(error, CleanupError):
|
|
247
320
|
code = "CLEANUP_INCOMPLETE"
|
|
248
|
-
elif isinstance(error, (RemoteError, ConfigError, ArtifactError, InvalidProfileSecrets)) or type(error).__module__ == 'envloop_rsi_loop.
|
|
321
|
+
elif isinstance(error, (RemoteError, ConfigError, ArtifactError, InvalidProfileSecrets)) or type(error).__module__ == 'envloop_rsi_loop.loops':
|
|
249
322
|
known = _MESSAGES.keys() | _KNOWN_REMOTE_CODES if isinstance(error, RemoteError) else _MESSAGES.keys()
|
|
250
323
|
code = error.code if isinstance(error.code, str) and error.code in known else (
|
|
251
324
|
"HTTP_ERROR" if isinstance(error, RemoteError) else "CONFIG_ERROR" if isinstance(error, ConfigError) else "CLI_ERROR")
|
|
@@ -272,7 +345,7 @@ def safe_error_code(error: Any) -> str:
|
|
|
272
345
|
return code
|
|
273
346
|
|
|
274
347
|
|
|
275
|
-
def error_block(code: str, message: str, *, status: int | None = None, guidance: str | None = None, hint: str | None = None, details: Iterable[str] = (), request_id: str | None = None) -> str:
|
|
348
|
+
def error_block(code: str, message: str, *, status: int | None = None, guidance: str | None = None, hint: str | None = None, details: Iterable[str] = (), request_id: str | None = None, route: str | None = None) -> str:
|
|
276
349
|
"""Render the error on stderr with optional terminal styling."""
|
|
277
350
|
from .terminal import color_enabled
|
|
278
351
|
|
|
@@ -287,7 +360,8 @@ def error_block(code: str, message: str, *, status: int | None = None, guidance:
|
|
|
287
360
|
detail = textwrap.fill(message, width=max(24, min(columns, 88)),
|
|
288
361
|
initial_indent=" ", subsequent_indent=" ")
|
|
289
362
|
lines = [title, detail]
|
|
290
|
-
for text in (guidance, f"Hint: {hint}" if hint else None, *(f"- {item}" for item in details)
|
|
363
|
+
for text in (guidance, f"Hint: {hint}" if hint else None, *(f"- {item}" for item in details),
|
|
364
|
+
f"Request: {route}" if route else None):
|
|
291
365
|
if text:
|
|
292
366
|
# Keep flags and identifiers such as `--request-id UUID` copyable on one line.
|
|
293
367
|
lines.append(textwrap.fill(text, width=max(24, min(columns, 88)), break_on_hyphens=False,
|
|
@@ -300,9 +374,9 @@ def error_block(code: str, message: str, *, status: int | None = None, guidance:
|
|
|
300
374
|
|
|
301
375
|
def format_error(error: BaseException) -> str:
|
|
302
376
|
"""Render a human error; SDK exception attributes remain unchanged."""
|
|
303
|
-
from ._optional import
|
|
304
|
-
if
|
|
305
|
-
return error_block(
|
|
377
|
+
from ._optional import missing_feature
|
|
378
|
+
if (feature := missing_feature(error)) is not None:
|
|
379
|
+
return error_block(feature.code, str(feature))
|
|
306
380
|
code = safe_error_code(error)
|
|
307
381
|
remote = error if isinstance(error, RemoteError) else None
|
|
308
382
|
candidate = remote and remote.status_code
|
|
@@ -311,6 +385,9 @@ def format_error(error: BaseException) -> str:
|
|
|
311
385
|
code = remote.code
|
|
312
386
|
local = _http_message(status) if code == "HTTP_ERROR" or code not in _MESSAGES else _MESSAGES[code]
|
|
313
387
|
extra: dict[str, Any] = {"hint": remote.hint, "details": remote.details, "request_id": remote.request_id} if remote else {}
|
|
388
|
+
if remote and status == 404 and isinstance(getattr(remote, "route", None), str):
|
|
389
|
+
# Name the missing API resource; the platform's 404 text stays generic by design.
|
|
390
|
+
extra["route"] = remote.route
|
|
314
391
|
if remote and remote.message and remote.details:
|
|
315
392
|
# A detail that repeats the message (one refused field) only adds where it is: show the field alone.
|
|
316
393
|
extra["details"] = [line.removesuffix(": " + remote.message) for line in remote.details if line != remote.message]
|
|
@@ -320,6 +397,8 @@ def format_error(error: BaseException) -> str:
|
|
|
320
397
|
documented = (code in _MESSAGES and code != "HTTP_ERROR") or status in GATEWAY_TIMEOUT_STATUSES
|
|
321
398
|
guidance = local if documented and local != remote.message else None
|
|
322
399
|
rendered = error_block(code, remote.message, status=status, guidance=guidance, **extra)
|
|
400
|
+
elif message := validation_message(error):
|
|
401
|
+
rendered = error_block(code, message, guidance=local if local != message else None)
|
|
323
402
|
else:
|
|
324
403
|
rendered = error_block(code, local, status=status, **extra)
|
|
325
404
|
recovery = upload_recovery(error)
|
envloop/cli_output.py
CHANGED
|
@@ -95,7 +95,7 @@ def list_output(result: Any, args: argparse.Namespace, program: str) -> str:
|
|
|
95
95
|
if not isinstance(items, list):
|
|
96
96
|
items = [{'name': key, 'value': value} for key, value in items.items()]
|
|
97
97
|
from ._optional import feature_module
|
|
98
|
-
feature = ('rsi-loop' if args.group == '
|
|
98
|
+
feature = ('rsi-loop' if args.group == 'loop' else
|
|
99
99
|
'experiment' if args.group in {'job', 'trial'} else
|
|
100
100
|
'data' if args.group in {'data', 'dataset', 'runner', 'checkpoint', 'profile'} else None)
|
|
101
101
|
if feature is not None:
|