envloop-cli 2.4.1__tar.gz → 2.5.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-2.4.1/README.pypi.md → envloop_cli-2.5.0/PKG-INFO +70 -0
- envloop_cli-2.4.1/PKG-INFO → envloop_cli-2.5.0/README.pypi.md +50 -20
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/cli_errors.py +16 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/http.py +18 -1
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/client.py +7 -3
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/dataset_upload.py +3 -5
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/publications.py +7 -3
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/resource_cli.py +3 -1
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/transfer.py +5 -4
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/cli.py +15 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/job_spec_cli.py +6 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/rsi-loop/envloop_rsi_loop/cli.py +19 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/rsi-loop/envloop_rsi_loop/cli_output.py +24 -1
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/rsi-loop/envloop_rsi_loop/loop_cli.py +66 -6
- envloop_cli-2.5.0/packages/rsi-loop/envloop_rsi_loop/loops.py +390 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/pyproject.toml +4 -4
- envloop_cli-2.4.1/packages/rsi-loop/envloop_rsi_loop/loops.py +0 -203
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/.gitignore +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/_optional.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/auth_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/auth_login.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/auth_workspace.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/cli_output.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/client.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/config.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/downloads.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/lifecycle_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/navigation_resources.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/profile_secrets.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/resource_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/resources.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/terminal.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/utils/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/envloop/utils/logging.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/assets.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/checkpoint_download.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/checkpoint_upload.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/cli_output.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/direct_artifact.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/direct_checkpoint.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/direct_publication.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/direct_storage.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/direct_worker_artifact.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/execution_content.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/http.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/navigation_resources.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/profile_updates.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/publication_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/r2_upload.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/recipe_packages.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/recipes.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/runner_packages.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/tags.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/asset/envloop_asset/upload_strategy.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/chat/envloop_chat/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/chat/envloop_chat/cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/chat/envloop_chat/client.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/cli_output.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/client.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/decision.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/http.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/inference.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/job_cost.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/job_logs.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/named_profile.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/navigation_resources.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/resource_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/resources.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/runtime_params.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/sandbox.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/train.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/train_log_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/train_metrics_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/train_progress.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/train_runner_cli.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/training/__init__.py +0 -0
- {envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/rsi-loop/envloop_rsi_loop/__init__.py +0 -0
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: envloop-cli
|
|
3
|
+
Version: 2.5.0
|
|
4
|
+
Summary: EnvLoop CLI and Python SDK for jobs, training, checkpoints and inference
|
|
5
|
+
Project-URL: Homepage, https://envloop.ai
|
|
6
|
+
Project-URL: Documentation, https://docs.envloop.ai
|
|
7
|
+
Project-URL: Repository, https://github.com/EnvLoop/envloop-cli
|
|
8
|
+
Project-URL: Issues, https://github.com/EnvLoop/envloop-cli/issues
|
|
9
|
+
Project-URL: Agent instructions, https://docs.envloop.ai/skill.md
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Provides-Extra: asset
|
|
12
|
+
Requires-Dist: boto3==1.44.3; extra == 'asset'
|
|
13
|
+
Requires-Dist: envloop-envhub==2.5.0; extra == 'asset'
|
|
14
|
+
Provides-Extra: chat
|
|
15
|
+
Requires-Dist: openai==3.55.1; extra == 'chat'
|
|
16
|
+
Provides-Extra: default
|
|
17
|
+
Provides-Extra: experiment
|
|
18
|
+
Provides-Extra: rsi-loop
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
1
21
|
# envloop-cli: EnvLoop CLI and Python SDK
|
|
2
22
|
|
|
3
23
|
Install the public client to run agent Jobs, inspect Trials, manage training and
|
|
@@ -227,6 +247,11 @@ Omitting the option preserves spec/Profile parameters and the Runner default
|
|
|
227
247
|
setting the same key with `--params` is rejected. The option selects Harbor's
|
|
228
248
|
task environment; platform execution placement remains server configured.
|
|
229
249
|
|
|
250
|
+
Bench Jobs accept `--model-proxy` / `--no-model-proxy` in the same canonical
|
|
251
|
+
`--spec` or named `--profile` forms to set the boolean `model_proxy` parameter.
|
|
252
|
+
Omitting both keeps the spec/Profile value; setting `model_proxy` with `--params`
|
|
253
|
+
as well is rejected.
|
|
254
|
+
|
|
230
255
|
## Existing installations
|
|
231
256
|
|
|
232
257
|
This distribution provides both the CLI and the `envloop` import package. Use a
|
|
@@ -409,3 +434,48 @@ Trial Artifact publication is `el trial artifact create --file manifest.json --d
|
|
|
409
434
|
`trial artifact download --ref URI --output DIR --content-digest SHA256` downloads one fixed
|
|
410
435
|
ANS directory; `trial artifact download TRIAL_ID --output DIR` downloads all uploaded Trial files.
|
|
411
436
|
These execution-owned records are excluded from Assets.
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
### Update Loop metadata
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
el loop update LOOP_ID --spec loop.json
|
|
443
|
+
el loop update LOOP_ID --spec '{"schema":"envloop.loop/v1","name":"Carry research"}'
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
```json
|
|
447
|
+
{
|
|
448
|
+
"schema": "envloop.loop/v1",
|
|
449
|
+
"name": "Carry research",
|
|
450
|
+
"description": "Compare candidate methods on a fixed evaluation set."
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Supplied fields replace their current values; omitted fields stay unchanged.
|
|
455
|
+
Set `"description": ""` to clear it. Pass a JSON file path or a quoted JSON object to `--spec`. Updating metadata needs
|
|
456
|
+
`training.run` and keeps the Loop ID, execution settings and recorded research.
|
|
457
|
+
Use `client.loops.update(loop_id, spec)` from Python and read the effective `spec`
|
|
458
|
+
with `client.loops.get(loop_id)`. See the [Loop guide](https://docs.envloop.ai/guides/rsi-loops#update-metadata).
|
|
459
|
+
|
|
460
|
+
### Reconcile resources and close a Loop
|
|
461
|
+
|
|
462
|
+
Start with a JSON file such as `reconcile.json` containing `{"request_id":"scan-001"}`.
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
el loop reconcile LOOP_ID --spec reconcile.json --json
|
|
466
|
+
el loop reconcile LOOP_ID --get RECONCILIATION_ID --json
|
|
467
|
+
el loop reconcile LOOP_ID --apply RECONCILIATION_ID --digest SHA256 --json
|
|
468
|
+
el loop close LOOP_ID --state completed --request-id close-001 --json
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Review the plan and its blockers before applying its exact digest. If the apply response is lost, use
|
|
472
|
+
`--get` with the existing reconciliation ID. If planning or closing loses its response, repeat the
|
|
473
|
+
identical request with the original request ID. A close receipt can have local state
|
|
474
|
+
`completed` while report delivery is `report_pending`. Use `el loop get LOOP_ID` to check the
|
|
475
|
+
platform's visible state.
|
|
476
|
+
|
|
477
|
+
In Python, the corresponding methods are `client.loops.reconcile(loop_id, spec)`,
|
|
478
|
+
`reconciliation_get(loop_id, reconciliation_id)`,
|
|
479
|
+
`reconciliation_apply(loop_id, reconciliation_id, digest=digest)`, and
|
|
480
|
+
`close(loop_id, state=state, request_id=request_id)`.
|
|
481
|
+
See the [Loop guide](https://docs.envloop.ai/guides/rsi-loops#reconcile-resources-and-close-a-loop).
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.5
|
|
2
|
-
Name: envloop-cli
|
|
3
|
-
Version: 2.4.1
|
|
4
|
-
Summary: EnvLoop CLI and Python SDK for jobs, training, checkpoints and inference
|
|
5
|
-
Project-URL: Homepage, https://envloop.ai
|
|
6
|
-
Project-URL: Documentation, https://docs.envloop.ai
|
|
7
|
-
Project-URL: Repository, https://github.com/EnvLoop/envloop-cli
|
|
8
|
-
Project-URL: Issues, https://github.com/EnvLoop/envloop-cli/issues
|
|
9
|
-
Project-URL: Agent instructions, https://docs.envloop.ai/skill.md
|
|
10
|
-
Requires-Python: >=3.12
|
|
11
|
-
Provides-Extra: asset
|
|
12
|
-
Requires-Dist: boto3==1.44.3; extra == 'asset'
|
|
13
|
-
Requires-Dist: envloop-envhub==2.4.1; extra == 'asset'
|
|
14
|
-
Provides-Extra: chat
|
|
15
|
-
Requires-Dist: openai==3.55.1; extra == 'chat'
|
|
16
|
-
Provides-Extra: default
|
|
17
|
-
Provides-Extra: experiment
|
|
18
|
-
Provides-Extra: rsi-loop
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
|
|
21
1
|
# envloop-cli: EnvLoop CLI and Python SDK
|
|
22
2
|
|
|
23
3
|
Install the public client to run agent Jobs, inspect Trials, manage training and
|
|
@@ -247,6 +227,11 @@ Omitting the option preserves spec/Profile parameters and the Runner default
|
|
|
247
227
|
setting the same key with `--params` is rejected. The option selects Harbor's
|
|
248
228
|
task environment; platform execution placement remains server configured.
|
|
249
229
|
|
|
230
|
+
Bench Jobs accept `--model-proxy` / `--no-model-proxy` in the same canonical
|
|
231
|
+
`--spec` or named `--profile` forms to set the boolean `model_proxy` parameter.
|
|
232
|
+
Omitting both keeps the spec/Profile value; setting `model_proxy` with `--params`
|
|
233
|
+
as well is rejected.
|
|
234
|
+
|
|
250
235
|
## Existing installations
|
|
251
236
|
|
|
252
237
|
This distribution provides both the CLI and the `envloop` import package. Use a
|
|
@@ -429,3 +414,48 @@ Trial Artifact publication is `el trial artifact create --file manifest.json --d
|
|
|
429
414
|
`trial artifact download --ref URI --output DIR --content-digest SHA256` downloads one fixed
|
|
430
415
|
ANS directory; `trial artifact download TRIAL_ID --output DIR` downloads all uploaded Trial files.
|
|
431
416
|
These execution-owned records are excluded from Assets.
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
### Update Loop metadata
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
el loop update LOOP_ID --spec loop.json
|
|
423
|
+
el loop update LOOP_ID --spec '{"schema":"envloop.loop/v1","name":"Carry research"}'
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
```json
|
|
427
|
+
{
|
|
428
|
+
"schema": "envloop.loop/v1",
|
|
429
|
+
"name": "Carry research",
|
|
430
|
+
"description": "Compare candidate methods on a fixed evaluation set."
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Supplied fields replace their current values; omitted fields stay unchanged.
|
|
435
|
+
Set `"description": ""` to clear it. Pass a JSON file path or a quoted JSON object to `--spec`. Updating metadata needs
|
|
436
|
+
`training.run` and keeps the Loop ID, execution settings and recorded research.
|
|
437
|
+
Use `client.loops.update(loop_id, spec)` from Python and read the effective `spec`
|
|
438
|
+
with `client.loops.get(loop_id)`. See the [Loop guide](https://docs.envloop.ai/guides/rsi-loops#update-metadata).
|
|
439
|
+
|
|
440
|
+
### Reconcile resources and close a Loop
|
|
441
|
+
|
|
442
|
+
Start with a JSON file such as `reconcile.json` containing `{"request_id":"scan-001"}`.
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
el loop reconcile LOOP_ID --spec reconcile.json --json
|
|
446
|
+
el loop reconcile LOOP_ID --get RECONCILIATION_ID --json
|
|
447
|
+
el loop reconcile LOOP_ID --apply RECONCILIATION_ID --digest SHA256 --json
|
|
448
|
+
el loop close LOOP_ID --state completed --request-id close-001 --json
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Review the plan and its blockers before applying its exact digest. If the apply response is lost, use
|
|
452
|
+
`--get` with the existing reconciliation ID. If planning or closing loses its response, repeat the
|
|
453
|
+
identical request with the original request ID. A close receipt can have local state
|
|
454
|
+
`completed` while report delivery is `report_pending`. Use `el loop get LOOP_ID` to check the
|
|
455
|
+
platform's visible state.
|
|
456
|
+
|
|
457
|
+
In Python, the corresponding methods are `client.loops.reconcile(loop_id, spec)`,
|
|
458
|
+
`reconciliation_get(loop_id, reconciliation_id)`,
|
|
459
|
+
`reconciliation_apply(loop_id, reconciliation_id, digest=digest)`, and
|
|
460
|
+
`close(loop_id, state=state, request_id=request_id)`.
|
|
461
|
+
See the [Loop guide](https://docs.envloop.ai/guides/rsi-loops#reconcile-resources-and-close-a-loop).
|
|
@@ -187,6 +187,15 @@ _register("INVALID_SANDBOX_IMAGE", "The Sandbox image reference is invalid.")
|
|
|
187
187
|
_register("RSI_LOOP_NOT_FOUND", "No RSI Loop with this LOOP_ID is visible in the current project. List Loops with el loop list.")
|
|
188
188
|
_register("RSI_ITERATION_NOT_FOUND", "The Loop has no Iteration with this number yet. See its Iterations with el loop get LOOP_ID.")
|
|
189
189
|
_register("INVALID_LOOP_ID", "LOOP_ID must be loop_ followed by 32 lower-case hex characters, as el loop list shows it.")
|
|
190
|
+
_register("INVALID_RECONCILIATION_ID", "The reconciliation ID must be rec_ followed by 32 lower-case hex characters.")
|
|
191
|
+
_register("INVALID_RECONCILIATION_DIGEST", "Use the plan's SHA-256 digest (64 lower-case hex characters).")
|
|
192
|
+
_register("INVALID_RECONCILIATION_MODE", "Supply --digest with --apply. Use --spec or --get alone.")
|
|
193
|
+
_register("INVALID_CLOSE_STATE", "Choose completed, failed or cancelled for --state.")
|
|
194
|
+
_register("INVALID_RSI_RECONCILIATION", "Check the request fields. Request IDs must be 1 to 128 characters without whitespace or control characters.")
|
|
195
|
+
_register("RSI_RECONCILIATION_CONFLICT", "The operation conflicts with the saved plan or the current Loop.")
|
|
196
|
+
_register("RSI_RECONCILIATION_BLOCKED", "Unresolved Loop or resource evidence blocks the operation. Review the reconciliation plan and its blockers.")
|
|
197
|
+
_register("RSI_RECONCILIATION_FORBIDDEN", "This operation requires training.run. Historical exceptions require a personal project administrator.")
|
|
198
|
+
_register("RSI_RECONCILIATION_UNAVAILABLE", "Reconciliation is temporarily unavailable. Use --get for a known operation or repeat the identical plan or close request with its original request ID.")
|
|
190
199
|
_register("INVALID_ITERATION", "ITERATION must be a positive integer; Iterations are numbered from 1.")
|
|
191
200
|
_register("INVALID_RSI_REQUEST INVALID_STEER INVALID_DIRECTIVE", "The RSI service rejected the request fields.")
|
|
192
201
|
_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.")
|
|
@@ -399,6 +408,13 @@ def format_error(error: BaseException) -> str:
|
|
|
399
408
|
if remote and isinstance(remote.code, str) and re.fullmatch(r"[A-Z0-9_]{1,128}", remote.code):
|
|
400
409
|
code = remote.code
|
|
401
410
|
local = _http_message(status) if code == "HTTP_ERROR" or code not in _MESSAGES else _MESSAGES[code]
|
|
411
|
+
if code == "RSI_RECONCILIATION_CONFLICT" and remote and isinstance(remote.route, str):
|
|
412
|
+
if remote.route.endswith("/close"):
|
|
413
|
+
local += " Retry loop close with the original request ID and state to check delivery."
|
|
414
|
+
elif remote.route.endswith("/reconciliations"):
|
|
415
|
+
local += " Retry the original proposal with its request ID. A changed proposal needs a fresh request ID."
|
|
416
|
+
else:
|
|
417
|
+
local += " Inspect the saved operation with el loop reconcile LOOP_ID --get RECONCILIATION_ID."
|
|
402
418
|
extra: dict[str, Any] = {"hint": remote.hint, "details": remote.details, "request_id": remote.request_id} if remote else {}
|
|
403
419
|
if remote and status == 404 and isinstance(getattr(remote, "route", None), str):
|
|
404
420
|
# Name the missing API resource; the platform's 404 text stays generic by design.
|
|
@@ -282,9 +282,26 @@ class Download:
|
|
|
282
282
|
self.close()
|
|
283
283
|
|
|
284
284
|
|
|
285
|
+
def _check_utf16_keys(pairs: list[tuple[str, Any]]) -> None:
|
|
286
|
+
seen: dict[bytes, str] = {}
|
|
287
|
+
for key, _ in pairs:
|
|
288
|
+
units = key.encode("utf-16-le", "surrogatepass")
|
|
289
|
+
if seen.setdefault(units, key) != key:
|
|
290
|
+
raise ValueError("JSON object keys must be distinct in UTF-16")
|
|
291
|
+
|
|
292
|
+
|
|
285
293
|
def encode_json(body: Any) -> bytes:
|
|
286
294
|
"""Compact UTF-8 request body: \\uXXXX escapes would make CJK text ~2x larger and trip request size limits."""
|
|
287
|
-
|
|
295
|
+
text = json.dumps(body, allow_nan=False, ensure_ascii=False, separators=(",", ":"))
|
|
296
|
+
try:
|
|
297
|
+
return text.encode("utf-8")
|
|
298
|
+
except UnicodeEncodeError:
|
|
299
|
+
pass
|
|
300
|
+
# Check the serialized keys before folding explicit surrogate pairs into
|
|
301
|
+
# scalars. The hook sees each object's original spellings before any merge.
|
|
302
|
+
json.loads(text, object_pairs_hook=_check_utf16_keys)
|
|
303
|
+
text = text.encode("utf-16-le", "surrogatepass").decode("utf-16-le", "surrogatepass")
|
|
304
|
+
return text.encode("utf-8", "backslashreplace")
|
|
288
305
|
|
|
289
306
|
|
|
290
307
|
|
|
@@ -259,10 +259,14 @@ class Runners:
|
|
|
259
259
|
raise ValueError('a Runner Asset resource is required')
|
|
260
260
|
return resource
|
|
261
261
|
|
|
262
|
-
def delete(self, asset_id: str, *, dry_run: bool = False):
|
|
263
|
-
"""Preview or retire a Runner through the public Assets lifecycle protections.
|
|
262
|
+
def delete(self, asset_id: str, *, dry_run: bool = False, force: bool = False):
|
|
263
|
+
"""Preview or retire a Runner through the public Assets lifecycle protections.
|
|
264
|
+
|
|
265
|
+
``force`` skips dependency checks; the platform allows it only for a private Runner
|
|
266
|
+
retired by a project admin.
|
|
267
|
+
"""
|
|
264
268
|
from envloop_asset.execution_content import ExecutionContent
|
|
265
|
-
return ExecutionContent(self._server, 'runner').delete(asset_id, dry_run=dry_run)
|
|
269
|
+
return ExecutionContent(self._server, 'runner').delete(asset_id, dry_run=dry_run, force=force)
|
|
266
270
|
|
|
267
271
|
def set_visibility(self, ref: str, *, visibility: str, expected_acl_revision: int):
|
|
268
272
|
from .execution_content import ExecutionContent
|
|
@@ -56,7 +56,6 @@ def _invalid(message: str):
|
|
|
56
56
|
# mirrored so the CLI refuses before uploading. The server stays authoritative.
|
|
57
57
|
MAX_TASK_DELIVERY_BYTES = 16 * 1024 * 1024
|
|
58
58
|
MAX_MEMBERS = 500_000
|
|
59
|
-
MAX_UNPACKED_BYTES = 2 * 1024 ** 3
|
|
60
59
|
MAX_DEPTH = 32
|
|
61
60
|
PATH_SEGMENT = re.compile(r'[A-Za-z0-9._\[\]-]+')
|
|
62
61
|
|
|
@@ -116,7 +115,7 @@ def check_directory(root: str | Path, *, manifest_text: str | None = None):
|
|
|
116
115
|
manifest = root / 'dataset.toml'
|
|
117
116
|
if manifest.is_symlink() or not manifest.is_file():
|
|
118
117
|
raise _invalid('the Dataset directory must contain dataset.toml at its root')
|
|
119
|
-
cases, members
|
|
118
|
+
cases, members = cast(dict[str, str], {}), 0
|
|
120
119
|
for path in sorted(root.rglob('*')):
|
|
121
120
|
relative = path.relative_to(root)
|
|
122
121
|
if '.git' in relative.parts:
|
|
@@ -131,9 +130,8 @@ def check_directory(root: str | Path, *, manifest_text: str | None = None):
|
|
|
131
130
|
raise _invalid(f'unsupported path {name!r}: use letters, digits, ".", "_", "-", "[" and "]" only')
|
|
132
131
|
if cases.setdefault(name.casefold(), name) != name:
|
|
133
132
|
raise _invalid(f'paths {cases[name.casefold()]!r} and {name!r} differ only in letter case')
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
raise _invalid(f'a Dataset may hold at most {MAX_MEMBERS} files and directories and {MAX_UNPACKED_BYTES} bytes')
|
|
133
|
+
if members > MAX_MEMBERS:
|
|
134
|
+
raise _invalid(f'a Dataset may hold at most {MAX_MEMBERS} files and directories')
|
|
137
135
|
if (root / 'source.toml').exists():
|
|
138
136
|
raise _invalid('external Dataset sources (source.toml) cannot be uploaded')
|
|
139
137
|
document = tomllib.loads(manifest.read_text() if manifest_text is None else manifest_text)
|
|
@@ -67,7 +67,10 @@ def storage_files(manifest: dict[str, Any]) -> list[dict[str, Any]]:
|
|
|
67
67
|
if not isinstance(entries, list) or not 1 <= len(entries) <= 1000:
|
|
68
68
|
raise ValueError('publication requires a bounded native file manifest')
|
|
69
69
|
paths, total = set(), 0
|
|
70
|
-
|
|
70
|
+
schema = canonical_schema(manifest.get('schema'))
|
|
71
|
+
repository = schema == 'envloop.repository-snapshot/v1'
|
|
72
|
+
dataset = repository or (isinstance(schema, str) and schema.startswith('envloop.dataset-records/')) or (
|
|
73
|
+
manifest.get('metadata') == {'format': 'envloop.harbor-task-bundle/v1'})
|
|
71
74
|
projected = []
|
|
72
75
|
for entry in entries:
|
|
73
76
|
expected = {'path', 'size', 'sha256', 'mode'} if repository else {'path', 'size', 'sha256'}
|
|
@@ -78,13 +81,14 @@ def storage_files(manifest: dict[str, Any]) -> list[dict[str, Any]]:
|
|
|
78
81
|
if (not isinstance(path, str) or len(path) > 1024 or path in paths
|
|
79
82
|
or any(not re.fullmatch(r'[A-Za-z0-9_][A-Za-z0-9_.-]*', part) or part in ('.', '..')
|
|
80
83
|
for part in path.split('/'))
|
|
81
|
-
or type(size) is not int or not 0 <= size <=
|
|
84
|
+
or type(size) is not int or not 0 <= size <= 2**53 - 1
|
|
85
|
+
or not dataset and size > MAX_FILE
|
|
82
86
|
or not isinstance(digest, str) or not re.fullmatch(r'[a-f0-9]{64}', digest)):
|
|
83
87
|
raise ValueError('invalid file path, size or SHA-256')
|
|
84
88
|
paths.add(path)
|
|
85
89
|
total += size
|
|
86
90
|
projected.append({'path': path, 'size': size, 'sha256': digest})
|
|
87
|
-
if total > MAX_TOTAL or any('/'.join(path.split('/')[:i]) in paths
|
|
91
|
+
if (not dataset and total > MAX_TOTAL) or any('/'.join(path.split('/')[:i]) in paths
|
|
88
92
|
for path in paths for i in range(1, len(path.split('/')))):
|
|
89
93
|
raise ValueError('publication exceeds limits or contains path collisions')
|
|
90
94
|
return sorted(projected, key=lambda item: item['path'])
|
|
@@ -149,6 +149,8 @@ def add_runner_commands(groups: "argparse._SubParsersAction[argparse.ArgumentPar
|
|
|
149
149
|
if action == 'get' else 'Runner ID, fixed ANS URI or NAME@REVISION'))
|
|
150
150
|
if action == 'delete':
|
|
151
151
|
command.add_argument('--dry-run', action='store_true')
|
|
152
|
+
command.add_argument('--force', action='store_true',
|
|
153
|
+
help='Skip dependency checks; allowed only for a private Runner retired by a project admin')
|
|
152
154
|
command.add_argument('--json', action='store_true')
|
|
153
155
|
command = actions.add_parser('set-visibility')
|
|
154
156
|
command.add_argument('ref',metavar='RUNNER_REF')
|
|
@@ -200,7 +202,7 @@ def _execute(args: argparse.Namespace, client: Any):
|
|
|
200
202
|
return client.runners.files(args.ref,limit=args.limit,cursor=args.cursor)
|
|
201
203
|
if args.action == 'download':
|
|
202
204
|
return client.runners.download(args.ref,args.output,file_id=args.file_id,content_digest=args.content_digest,resume=args.resume)
|
|
203
|
-
return client.runners.delete(args.asset_id, dry_run=args.dry_run)
|
|
205
|
+
return client.runners.delete(args.asset_id, dry_run=args.dry_run, force=args.force)
|
|
204
206
|
collection = getattr(client, {'dataset':'datasets','checkpoint':'checkpoints','recipe':'recipes','profile':'profiles'}[args.group])
|
|
205
207
|
if args.action == 'list':
|
|
206
208
|
options = {key:getattr(args,key) for key in ('name','query','visibility','limit','cursor','include_deleted')}
|
|
@@ -497,10 +497,11 @@ class AssetTransfer:
|
|
|
497
497
|
return self.transport.request('PUT', self._path(asset_id) + '/visibility',
|
|
498
498
|
{'visibility': visibility, 'expected_acl_revision': expected_acl_revision})
|
|
499
499
|
|
|
500
|
-
def delete(self, asset_id: str, *, dry_run: bool = False):
|
|
501
|
-
if type(dry_run) is not bool:
|
|
502
|
-
raise ValueError('dry_run must be
|
|
503
|
-
|
|
500
|
+
def delete(self, asset_id: str, *, dry_run: bool = False, force: bool = False):
|
|
501
|
+
if type(dry_run) is not bool or type(force) is not bool:
|
|
502
|
+
raise ValueError('dry_run and force must be booleans')
|
|
503
|
+
query = '&'.join(name + '=true' for name, value in (('dry_run', dry_run), ('force', force)) if value)
|
|
504
|
+
return self.transport.request('DELETE', self._path(asset_id) + ('?' + query if query else ''))
|
|
504
505
|
|
|
505
506
|
@staticmethod
|
|
506
507
|
def _native_result(result: Any, data_type: str):
|
|
@@ -166,6 +166,12 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
166
166
|
help='Bench/Sandbox canonical --spec or named --profile: Harbor task environment; '
|
|
167
167
|
'omitted uses the Runner default (docker). '
|
|
168
168
|
'Cannot also set harbor_env with --params')
|
|
169
|
+
model_proxy = job_submit.add_mutually_exclusive_group()
|
|
170
|
+
model_proxy.add_argument('--model-proxy', dest='model_proxy', action='store_const', const=True, default=None,
|
|
171
|
+
help='Bench canonical --spec or named --profile: set the boolean model_proxy parameter; '
|
|
172
|
+
'omitted preserves the spec/Profile value. Cannot also set model_proxy with --params')
|
|
173
|
+
model_proxy.add_argument('--no-model-proxy', dest='model_proxy', action='store_const', const=False,
|
|
174
|
+
help='Bench canonical --spec or named --profile: set model_proxy to false')
|
|
169
175
|
job_submit.add_argument("--seed", type=int)
|
|
170
176
|
job_submit.add_argument("--timeout-seconds", type=wait_seconds,
|
|
171
177
|
help="Bench/Sandbox or Train Runner execution timeout (whole seconds); Train recipe --wait timeout (default: 600)")
|
|
@@ -375,6 +381,11 @@ def validate(args: argparse.Namespace, cli: argparse.ArgumentParser):
|
|
|
375
381
|
cli.error('--harbor_env applies only to Bench/Sandbox Jobs')
|
|
376
382
|
if any(key.lower() == 'harbor_env' for key in (getattr(args, 'named_parameters', None) or {})):
|
|
377
383
|
cli.error('--harbor_env and --params cannot both set harbor_env')
|
|
384
|
+
if args.model_proxy is not None:
|
|
385
|
+
if args.type != 'bench':
|
|
386
|
+
cli.error('--model-proxy and --no-model-proxy apply only to Bench Jobs')
|
|
387
|
+
if any(key.lower() == 'model_proxy' for key in (getattr(args, 'named_parameters', None) or {})):
|
|
388
|
+
cli.error('--model-proxy/--no-model-proxy and --params cannot both set model_proxy')
|
|
378
389
|
if args.provider is not None and args.type not in {'bench', 'sandbox'}:
|
|
379
390
|
cli.error('--provider requires a Bench/Sandbox Job')
|
|
380
391
|
named_mode = args.spec is None and args.profile is not None and (
|
|
@@ -402,11 +413,15 @@ def validate(args: argparse.Namespace, cli: argparse.ArgumentParser):
|
|
|
402
413
|
resources=requested_resources(args) or None, provider=args.provider)
|
|
403
414
|
if args.harbor_env is not None:
|
|
404
415
|
args.named_request['parameters']['harbor_env'] = args.harbor_env
|
|
416
|
+
if args.model_proxy is not None:
|
|
417
|
+
args.named_request['parameters']['model_proxy'] = args.model_proxy
|
|
405
418
|
except (TypeError, ValueError) as exc:
|
|
406
419
|
cli.error(str(exc))
|
|
407
420
|
return None
|
|
408
421
|
if args.harbor_env is not None and args.spec is None:
|
|
409
422
|
cli.error('--harbor_env requires a canonical --spec or a named --profile')
|
|
423
|
+
if args.model_proxy is not None and args.spec is None:
|
|
424
|
+
cli.error('--model-proxy and --no-model-proxy require a canonical --spec or a named --profile')
|
|
410
425
|
if args.spec is None and args.params is not None and args.type not in {'bench', 'sandbox'}:
|
|
411
426
|
cli.error('--params applies to Bench/Sandbox declared Runner runtime parameters')
|
|
412
427
|
runner_mode = args.type == 'train' and args.spec is None
|
{envloop_cli-2.4.1 → envloop_cli-2.5.0}/packages/experiment/envloop_experiment/job_spec_cli.py
RENAMED
|
@@ -77,6 +77,8 @@ def spec_request(args: argparse.Namespace):
|
|
|
77
77
|
request['type'] = kind
|
|
78
78
|
if args.harbor_env is not None:
|
|
79
79
|
raise ValueError('--harbor_env requires a canonical --spec with schema envloop.job/v1 or a named --profile')
|
|
80
|
+
if getattr(args, 'model_proxy', None) is not None:
|
|
81
|
+
raise ValueError('--model-proxy and --no-model-proxy require a canonical --spec or a named --profile')
|
|
80
82
|
if getattr(args, 'provider', None) is not None:
|
|
81
83
|
request['provider'] = args.provider
|
|
82
84
|
validate_public_execution(request)
|
|
@@ -219,6 +221,8 @@ def unified_request(args: argparse.Namespace, request: dict[str, Any]) -> dict[s
|
|
|
219
221
|
args.type = kind
|
|
220
222
|
if args.harbor_env is not None and kind not in {'bench', 'sandbox'}:
|
|
221
223
|
raise ValueError('--harbor_env applies only to Bench/Sandbox Jobs')
|
|
224
|
+
if getattr(args, 'model_proxy', None) is not None and kind != 'bench':
|
|
225
|
+
raise ValueError('--model-proxy and --no-model-proxy apply only to Bench Jobs')
|
|
222
226
|
incompatible = ('dataset', 'dataset_option', 'source', 'task_id', 'config', 'split', 'revision',
|
|
223
227
|
'job_id', 'tag', 'attempts', 'profile', 'delete_delay_seconds', *TRAIN_ONLY_FIELDS)
|
|
224
228
|
if any(getattr(args, key, None) is not None for key in incompatible):
|
|
@@ -237,6 +241,8 @@ def unified_request(args: argparse.Namespace, request: dict[str, Any]) -> dict[s
|
|
|
237
241
|
params.update(getattr(args, 'named_parameters', None) or {})
|
|
238
242
|
if args.harbor_env is not None:
|
|
239
243
|
params['harbor_env'] = args.harbor_env
|
|
244
|
+
if getattr(args, 'model_proxy', None) is not None:
|
|
245
|
+
params['model_proxy'] = args.model_proxy
|
|
240
246
|
for key in ('command', 'image', 'seed'):
|
|
241
247
|
if getattr(args, key) is not None:
|
|
242
248
|
params[key] = getattr(args, key)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
|
|
3
|
+
from envloop_rsi_loop.loops import CLOSE_STATES
|
|
4
|
+
|
|
3
5
|
LOOP_ID_HELP = "loop_ followed by 32 lower-case hex characters, as shown by el loop list"
|
|
4
6
|
|
|
5
7
|
|
|
@@ -21,6 +23,23 @@ def add_commands(groups: "argparse._SubParsersAction[argparse.ArgumentParser]"):
|
|
|
21
23
|
get = loops.add_parser("get", help="Show a Loop's state, Iterations and Train Jobs")
|
|
22
24
|
get.add_argument("loop_id", metavar="LOOP_ID", help=LOOP_ID_HELP)
|
|
23
25
|
get.add_argument("--json", action="store_true", help="Output the complete Loop as JSON (default: summary and tables)")
|
|
26
|
+
update = loops.add_parser("update", help="Update Loop metadata from a spec (needs training.run)")
|
|
27
|
+
update.add_argument("loop_id", metavar="LOOP_ID", help=LOOP_ID_HELP)
|
|
28
|
+
update.add_argument("--spec", required=True, metavar="FILE|JSON",
|
|
29
|
+
help="JSON file path or inline envloop.loop/v1 JSON object; supplied name/description override, omitted fields stay")
|
|
30
|
+
reconcile = loops.add_parser("reconcile", help="Plan, inspect or apply audited Loop reconciliation")
|
|
31
|
+
reconcile.add_argument("loop_id", metavar="LOOP_ID", help=LOOP_ID_HELP)
|
|
32
|
+
mode = reconcile.add_mutually_exclusive_group(required=True)
|
|
33
|
+
mode.add_argument("--spec", metavar="FILE", help="Plan reconciliation from a JSON file with a request_id")
|
|
34
|
+
mode.add_argument("--get", metavar="ID", help="Read a saved plan or receipt, including after a lost apply response")
|
|
35
|
+
mode.add_argument("--apply", metavar="ID", help="Apply the reviewed plan with --digest")
|
|
36
|
+
reconcile.add_argument("--digest", metavar="SHA256", help="Exact lowercase SHA-256 from the plan, required with --apply")
|
|
37
|
+
reconcile.add_argument("--json", action="store_true", help="Output the complete plan or receipt as JSON")
|
|
38
|
+
close = loops.add_parser("close", help="Explicitly close a Loop and show report delivery status")
|
|
39
|
+
close.add_argument("loop_id", metavar="LOOP_ID", help=LOOP_ID_HELP)
|
|
40
|
+
close.add_argument("--state", required=True, choices=CLOSE_STATES, help="Terminal state for local closure")
|
|
41
|
+
close.add_argument("--request-id", required=True, metavar="ID", help="Reuse this request ID with the same state to check delivery")
|
|
42
|
+
close.add_argument("--json", action="store_true", help="Output the complete closure receipt as JSON")
|
|
24
43
|
iteration = loops.add_parser("iteration", help="Read one Iteration of a Loop").add_subparsers(
|
|
25
44
|
dest="iteration_action", required=True)
|
|
26
45
|
iteration_get = iteration.add_parser("get", help="Show one Iteration's decision, summary and audits")
|
|
@@ -60,6 +60,27 @@ def _summary(fields: tuple[tuple[str, Any], ...]) -> str:
|
|
|
60
60
|
for label, value in fields)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
def reconciliation_output(receipt: dict[str, Any]) -> str:
|
|
64
|
+
return _summary((
|
|
65
|
+
("Loop ID", receipt.get("loop_id")),
|
|
66
|
+
("Reconciliation ID", receipt.get("reconciliation_id")),
|
|
67
|
+
("Status", receipt.get("status")),
|
|
68
|
+
("Digest", receipt.get("digest")),
|
|
69
|
+
("Blockers", receipt.get("blocker_count", len(receipt["blockers"]))),
|
|
70
|
+
("Expires at", timestamp(receipt.get("expires_at"))),
|
|
71
|
+
)) + "\nUse --json to review entries and blockers."
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def close_output(receipt: dict[str, Any]) -> str:
|
|
75
|
+
return _summary((
|
|
76
|
+
("Loop ID", receipt.get("loop_id")),
|
|
77
|
+
("Request ID", receipt.get("request_id")),
|
|
78
|
+
("Local state", receipt.get("state")),
|
|
79
|
+
("Report delivery", receipt.get("delivery")),
|
|
80
|
+
("Ended at", timestamp(receipt.get("ended_at"))),
|
|
81
|
+
))
|
|
82
|
+
|
|
83
|
+
|
|
63
84
|
def _checkpoint_name(checkpoint: Any) -> Any:
|
|
64
85
|
if not isinstance(checkpoint, dict):
|
|
65
86
|
return None
|
|
@@ -70,7 +91,9 @@ def loop_output(loop: dict[str, Any], jobs: dict[str, Any]) -> str:
|
|
|
70
91
|
"""A Loop's summary, its Iterations, then the Train Jobs it launched."""
|
|
71
92
|
spent = loop.get("spend") if isinstance(loop.get("spend"), dict) else {}
|
|
72
93
|
fields = (
|
|
73
|
-
("Loop ID", loop.get("loop_id")), ("Name", loop.get("name")),
|
|
94
|
+
("Loop ID", loop.get("loop_id")), ("Name", loop.get("name")),
|
|
95
|
+
*((("Description", loop["description"]),) if loop.get("description") else ()),
|
|
96
|
+
("State", state_text(loop.get("state"))),
|
|
74
97
|
("Iteration", iteration_text(loop)), ("Best version", loop.get("best_version")),
|
|
75
98
|
("Spend", spend(loop)), ("Model cost cap", usd(spent.get("max_model_cost_usd"))),
|
|
76
99
|
("Updated at", timestamp(loop.get("updated_at"))),
|
|
@@ -4,10 +4,20 @@ import argparse
|
|
|
4
4
|
import json
|
|
5
5
|
import sys
|
|
6
6
|
import time
|
|
7
|
+
from pathlib import Path
|
|
7
8
|
from typing import TYPE_CHECKING, Any
|
|
8
9
|
|
|
10
|
+
from envloop.http import RemoteError
|
|
9
11
|
from envloop.terminal import safe_text, status_text, style
|
|
10
|
-
from envloop_rsi_loop.loops import
|
|
12
|
+
from envloop_rsi_loop.loops import (
|
|
13
|
+
LoopError,
|
|
14
|
+
loop_path,
|
|
15
|
+
reconciliation_path,
|
|
16
|
+
reconciliation_spec,
|
|
17
|
+
valid_digest,
|
|
18
|
+
valid_iteration,
|
|
19
|
+
validate_request_id,
|
|
20
|
+
)
|
|
11
21
|
|
|
12
22
|
if TYPE_CHECKING:
|
|
13
23
|
from envloop_rsi_loop.loops import Loops
|
|
@@ -17,11 +27,32 @@ POLL_SECONDS = 3.0
|
|
|
17
27
|
|
|
18
28
|
|
|
19
29
|
def validate(args: argparse.Namespace) -> None:
|
|
20
|
-
"""
|
|
30
|
+
"""Validate local Loop command inputs before connecting."""
|
|
21
31
|
if getattr(args, "loop_id", None) is not None:
|
|
22
32
|
loop_path(args.loop_id)
|
|
23
33
|
if getattr(args, "iteration", None) is not None:
|
|
24
34
|
valid_iteration(args.iteration)
|
|
35
|
+
if args.action == "update":
|
|
36
|
+
try:
|
|
37
|
+
spec = json.loads(args.spec)
|
|
38
|
+
except json.JSONDecodeError:
|
|
39
|
+
if args.spec.lstrip().startswith(("{", "[", '"')):
|
|
40
|
+
raise
|
|
41
|
+
spec = json.loads(Path(args.spec).read_text(encoding="utf-8"))
|
|
42
|
+
if not isinstance(spec, dict):
|
|
43
|
+
raise ValueError("Loop spec must be a JSON object")
|
|
44
|
+
args.loop_spec = spec
|
|
45
|
+
if args.action == "reconcile":
|
|
46
|
+
if (args.apply is None) != (args.digest is None):
|
|
47
|
+
raise LoopError("INVALID_RECONCILIATION_MODE")
|
|
48
|
+
if args.spec is not None:
|
|
49
|
+
args.loop_spec = reconciliation_spec(json.loads(Path(args.spec).read_text(encoding="utf-8")))
|
|
50
|
+
else:
|
|
51
|
+
reconciliation_path(args.loop_id, args.get if args.get is not None else args.apply)
|
|
52
|
+
if args.digest is not None:
|
|
53
|
+
valid_digest(args.digest)
|
|
54
|
+
if args.action == "close":
|
|
55
|
+
validate_request_id(args.request_id)
|
|
25
56
|
|
|
26
57
|
|
|
27
58
|
def _brief(args: argparse.Namespace) -> str:
|
|
@@ -57,9 +88,8 @@ def _follow(loops: "Loops", loop_id: str, since: int | None, *, as_json: bool =
|
|
|
57
88
|
|
|
58
89
|
def loop_jobs(client: Any, detail: dict[str, Any]) -> dict[str, Any]:
|
|
59
90
|
"""The Loop's Train Jobs for the detail view; a failed lookup is shown, not raised."""
|
|
60
|
-
from
|
|
61
|
-
|
|
62
|
-
name = detail.get("name")
|
|
91
|
+
from envloop_rsi_loop.loops import train_jobs
|
|
92
|
+
name = detail.get("legacy_name", detail.get("name"))
|
|
63
93
|
try:
|
|
64
94
|
return train_jobs(client.training_jobs, detail.get("loop_id") or "", name=name if isinstance(name, str) else None)
|
|
65
95
|
except (RemoteError, LoopError) as error:
|
|
@@ -69,7 +99,14 @@ def loop_jobs(client: Any, detail: dict[str, Any]) -> dict[str, Any]:
|
|
|
69
99
|
|
|
70
100
|
def execute(args: argparse.Namespace, client: Any) -> dict[str, Any]:
|
|
71
101
|
"""Run one ``loop`` action; returns the result to print, or exits after printing its own output."""
|
|
72
|
-
|
|
102
|
+
try:
|
|
103
|
+
result = _run(args, client)
|
|
104
|
+
except RemoteError as error:
|
|
105
|
+
if args.action in {"reconcile", "close"}:
|
|
106
|
+
# The CLI uses static guidance for this error code. Remote diagnostics can include ledger data.
|
|
107
|
+
route = error.route if error.code == "RSI_RECONCILIATION_CONFLICT" else None
|
|
108
|
+
raise RemoteError(error.code, error.status_code, retry_after=error.retry_after, route=route) from None
|
|
109
|
+
raise
|
|
73
110
|
if result is None:
|
|
74
111
|
from envloop._optional import CommandExit
|
|
75
112
|
raise CommandExit(0)
|
|
@@ -81,6 +118,29 @@ def _run(args: argparse.Namespace, client: Any) -> dict[str, Any] | None:
|
|
|
81
118
|
action = args.action
|
|
82
119
|
if action == "list":
|
|
83
120
|
return loops.list()
|
|
121
|
+
if action == "update":
|
|
122
|
+
return loops.update(args.loop_id, args.loop_spec)
|
|
123
|
+
if action == "reconcile":
|
|
124
|
+
from envloop_rsi_loop.cli_output import reconciliation_output
|
|
125
|
+
|
|
126
|
+
if args.spec is not None:
|
|
127
|
+
result = loops.reconcile(args.loop_id, args.loop_spec)
|
|
128
|
+
elif args.get is not None:
|
|
129
|
+
result = loops.reconciliation_get(args.loop_id, args.get)
|
|
130
|
+
else:
|
|
131
|
+
result = loops.reconciliation_apply(args.loop_id, args.apply, digest=args.digest)
|
|
132
|
+
if args.json:
|
|
133
|
+
return result
|
|
134
|
+
print(reconciliation_output(result))
|
|
135
|
+
return None
|
|
136
|
+
if action == "close":
|
|
137
|
+
from envloop_rsi_loop.cli_output import close_output
|
|
138
|
+
|
|
139
|
+
result = loops.close(args.loop_id, state=args.state, request_id=args.request_id)
|
|
140
|
+
if args.json:
|
|
141
|
+
return result
|
|
142
|
+
print(close_output(result))
|
|
143
|
+
return None
|
|
84
144
|
if action == "get":
|
|
85
145
|
detail = loops.get(args.loop_id)
|
|
86
146
|
if not args.json:
|