tlpytools 0.2.9__tar.gz → 0.2.11__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.
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/copilot-instructions.md +2 -2
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/workflows/deploy.yml +1 -1
- {tlpytools-0.2.9 → tlpytools-0.2.11}/CHANGELOG.md +101 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/DEVELOPER_GUIDE.md +2 -2
- {tlpytools-0.2.9 → tlpytools-0.2.11}/PKG-INFO +1 -1
- {tlpytools-0.2.9 → tlpytools-0.2.11}/pyproject.toml +1 -1
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/__init__.py +1 -1
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/README.md +102 -28
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/batch_task_runner.py +236 -29
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/cli.py +54 -2
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/orchestrator.py +754 -360
- tlpytools-0.2.11/tests/test_orca_cli_batch_options.py +584 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/test_orca_integration.py +21 -9
- tlpytools-0.2.11/tests/test_orca_resume_cloud.py +879 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/test_orca_unit.py +98 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/uv.lock +1 -1
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.env.example +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/skills/README.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/skills/prepare-official-release/SKILL.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/workflows/code-formatting-pr.yml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/workflows/code-formatting.yml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.github/workflows/test.yml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.gitignore +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.pre-commit-config.yaml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/.python-version +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/ENVIRONMENT_VARIABLES.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/Makefile +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/README.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/adls_server.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/azure_credential_manager.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/README.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/orca_cloud_workflow.drawio +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/orca_detailed_steps.drawio +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/orca_file_structure.drawio +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/orca_local_workflow.drawio +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/diagrams/orca_main_features.drawio +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/docs/unified_logging.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/requirements.txt +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/examples/batchtask.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/examples/data_files/example.csv +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/examples/mydataproject.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/examples/readwritedata.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/examples/unified_logging.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/adls_server.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/azure_credential.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/config.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/data.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/data_store.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/env_config.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/log.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/__init__.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/__main__.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/orca_model_config_barebone.yaml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/orca/orca_model_config_example.yaml +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/src/tlpytools/sql_server.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/README.md +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/__init__.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/conftest.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/run_tests.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/test_azure_credential.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/test_basic.py +0 -0
- {tlpytools-0.2.9 → tlpytools-0.2.11}/tests/test_core.py +0 -0
|
@@ -98,8 +98,8 @@ Interpretation for agent PRs:
|
|
|
98
98
|
|
|
99
99
|
Observed result:
|
|
100
100
|
- Build succeeds and produces:
|
|
101
|
-
- `dist/tlpytools-0.2.
|
|
102
|
-
- `dist/tlpytools-0.2.
|
|
101
|
+
- `dist/tlpytools-0.2.11.tar.gz`
|
|
102
|
+
- `dist/tlpytools-0.2.11-py3-none-any.whl`
|
|
103
103
|
|
|
104
104
|
### 5) Run
|
|
105
105
|
- ORCA CLI (module form):
|
|
@@ -2,6 +2,107 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to TLPyTools will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.11]
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **`run_model` execution granularity (`--execution-options`/`--resume-iteration`/`--resume-step`):**
|
|
9
|
+
- `tlpytools.orca.cli`'s `run_model` action can now run just one step (`one_step`), all remaining
|
|
10
|
+
steps in the current iteration (`one_iteration`), or the full remaining model (`full`, default)
|
|
11
|
+
- `--resume-iteration`/`--resume-step` reset state to a specific point (via `resume_from_step()`)
|
|
12
|
+
before running; `--resume-step` requires `--resume-iteration`
|
|
13
|
+
- `BatchTaskRunner` (`batch_task_runner.py`, both the `main()` CLI and `submit_task`/`run_task`)
|
|
14
|
+
accepts the same options and forwards them to the Azure Batch container's `run_model` command,
|
|
15
|
+
so a single step/iteration can be debugged remotely without running the full model
|
|
16
|
+
- **`OrcaOrchestrator.get_remote_state()`:** public wrapper around the existing ADLS config +
|
|
17
|
+
state-download helpers, returning the scenario's actual cloud state (or `None`) so callers can
|
|
18
|
+
validate local assumptions against cloud progress before triggering Azure Batch operations
|
|
19
|
+
- **`status_callback` for `BatchTaskRunner.run_task()`/`wait_for_task_completion()`:** optional
|
|
20
|
+
`callable(state, message)` invoked during the duplicate check, task creation and after every poll
|
|
21
|
+
with the Batch task state, so a notebook can show live progress instead of a static "submitting"
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- **Duplicate task submission no longer errors on a task that is already in progress:**
|
|
25
|
+
`BatchTaskRunner.run_task()` now attaches to a matching `active`/`preparing`/`running` task
|
|
26
|
+
(newest if several) and reports its status, instead of raising. A successfully completed
|
|
27
|
+
matching task still blocks; `skip_duplicate_check=True` still always submits a new task
|
|
28
|
+
- **Failed Batch tasks were reported as successful:** Azure Batch reports a task whose command
|
|
29
|
+
exited non-zero as state `completed` (with `executionInfo.result = "failure"`), and
|
|
30
|
+
`BatchTaskRunner` only checked the state name. It now treats a failed result or non-zero exit
|
|
31
|
+
code as a failed task (and shows the exit code), so the new "failed cloud sync fails the run"
|
|
32
|
+
behavior actually reaches the caller. The duplicate-task check likewise no longer lets such a
|
|
33
|
+
task block resubmission
|
|
34
|
+
- **Cloud resume left regenerated outputs un-uploaded:** `_backup_affected_outputs()` renamed
|
|
35
|
+
archives only on the Batch VM, so the old canonical blobs stayed in ADLS and the outputs upload
|
|
36
|
+
(which skips existing names) never uploaded the regenerated files. In `cloud_production` mode
|
|
37
|
+
the matching ADLS blobs (including archives that exist only in ADLS) are now renamed to the
|
|
38
|
+
same `_bak` names before the local rename; a failed ADLS rename or listing aborts the resume
|
|
39
|
+
and leaves the local files untouched
|
|
40
|
+
- **Cloud upload blocked after a resume to an earlier point:** a resume rewinds
|
|
41
|
+
`total_steps_completed`, so the upload check saw the cloud state as ahead and refused every
|
|
42
|
+
upload. The state now carries `resume_generation`, incremented by a rewinding resume and
|
|
43
|
+
honored by `OrcaState.compare_states()`, so the rewound state can replace the older cloud copy
|
|
44
|
+
(and a local copy can download a rewound cloud scenario)
|
|
45
|
+
- **`resume_from_step()` ran a whole iteration when `resume_step` was omitted for the current
|
|
46
|
+
iteration,** and did nothing on a completed run. It now only rewinds the state (the caller then
|
|
47
|
+
runs with the chosen granularity); a resume point ahead of current progress or outside the
|
|
48
|
+
`start_at`-based iteration range is rejected, and `total_steps_completed` is computed from
|
|
49
|
+
`start_at`. The `output_archives` registry no longer lists archives renamed by a backup
|
|
50
|
+
- **Backup filename parsing:** archives are matched with an end-anchored pattern and the longest
|
|
51
|
+
matching step name, so a step named `run` no longer captures `run_extended_*` archives
|
|
52
|
+
- **Regenerated outputs skipped by the outputs upload:** files are now compared by path below
|
|
53
|
+
`outputs/` (not basename), and archives created in the current session are always uploaded,
|
|
54
|
+
with any same-named cloud copy moved to `.cloud_sync_conflict/` first; failed output uploads
|
|
55
|
+
now fail the sync instead of being reported as success
|
|
56
|
+
- **Cloud sync failures no longer reported as success:** a failed final upload (`run`) or per-step
|
|
57
|
+
upload (`run_one_step`/`run_one_iteration`) fails the run so the Batch task exits non-zero;
|
|
58
|
+
`status` is set to `completed` before the last step syncs, and `run_one_iteration` syncs the
|
|
59
|
+
completed iteration
|
|
60
|
+
- **Config/state upload success** required only that any file (including logs) uploaded; the
|
|
61
|
+
config and state files must now all upload
|
|
62
|
+
- **Overwrite of the only cloud copy:** `_upload_file_with_conflict_handling()` continued with the
|
|
63
|
+
upload when moving the existing file to `.cloud_sync_conflict/` failed; it now returns failure.
|
|
64
|
+
Conflict backup names have seconds resolution
|
|
65
|
+
- **Incomplete downloads reported as success:** failed component, config/state or output
|
|
66
|
+
downloads now fail `_download_all_from_cloud()`/`_download_state_and_outputs()` (so a cloud run
|
|
67
|
+
does not start on a partial scenario); components are extracted to a staging folder and config
|
|
68
|
+
files are downloaded before the existing ones are replaced, so a failure no longer deletes the
|
|
69
|
+
working copy; nested `outputs/` paths are preserved; a local pre-resume archive is renamed to
|
|
70
|
+
match a cloud resume backup so the regenerated archive downloads
|
|
71
|
+
- **`unpack_zip_file()`** refuses archive members that resolve outside the output folder and
|
|
72
|
+
returns `False` if any member fails to extract
|
|
73
|
+
- **`_execute_step()`** restores the working directory, stops the performance monitor and
|
|
74
|
+
terminates the component process if the step raises; a failed output archive (zip or copy) now
|
|
75
|
+
fails the step and is not registered in the state
|
|
76
|
+
- **State file:** written atomically; an unreadable file is kept as `.corrupt_<timestamp>`
|
|
77
|
+
instead of being silently replaced
|
|
78
|
+
- **`_sync_state_with_config()`** compared the current iteration to the iteration count, which
|
|
79
|
+
was wrong when `start_at` is not 1
|
|
80
|
+
- **`export_detailed_data()`** no longer fails for a bare filename (empty directory part)
|
|
81
|
+
- Remote state cache is cleared after an upload
|
|
82
|
+
- **ADLS connection timeout was ineffective:** `_get_adls_connection_with_timeout()` waited for a
|
|
83
|
+
hung connection to finish when leaving its `ThreadPoolExecutor` block, so the timeout never
|
|
84
|
+
fired. It now uses a daemon thread with a bounded join
|
|
85
|
+
- **`run_one_step()`/`run_one_iteration()` on an already-complete run** now correct a stale
|
|
86
|
+
`status` (for example `error`) to `completed`
|
|
87
|
+
|
|
88
|
+
### Changed
|
|
89
|
+
- `download_from_adls_by_pattern()` accepts `raise_on_error=True` to raise instead of returning
|
|
90
|
+
`[]`, so a failed listing can be told apart from "no matching files" (used when planning a
|
|
91
|
+
cloud resume backup; the default behavior is unchanged)
|
|
92
|
+
|
|
93
|
+
## [0.2.10]
|
|
94
|
+
|
|
95
|
+
### Fixed
|
|
96
|
+
- **`_copy_input_data`: `NameError` on glob-matched files with an `exclude` list:**
|
|
97
|
+
- The glob-pattern branch referenced an undefined variable `exclude_names` instead of the in-scope `entry_exclude` set
|
|
98
|
+
- Files matched by a glob pattern are now correctly skipped when their basename appears in the per-entry `exclude` list
|
|
99
|
+
- **`_upload_component_zips`: `IndexError`/`TypeError` when `steps` is empty:**
|
|
100
|
+
- `self.state.get("steps")[current_step_index - 1]` would raise if the steps list was empty or `None`
|
|
101
|
+
- Now guards with `steps = self.state.get("steps") or []` and uses conditional indexing; returns early with a log message if steps is empty
|
|
102
|
+
- **`sync_with_adls`: `TypeError` when keyword arguments are supplied:**
|
|
103
|
+
- `**kwargs` was forwarded to `_sync_with_cloud(self, direction: str)` which does not accept extra keyword arguments, causing a `TypeError` for any caller passing additional options
|
|
104
|
+
- The unused `**kwargs` forwarding has been removed from the `download` and `upload` branches
|
|
105
|
+
|
|
5
106
|
## [0.2.9]
|
|
6
107
|
|
|
7
108
|
### Changed
|
|
@@ -200,7 +200,7 @@ make check-all
|
|
|
200
200
|
4. Click **"Run workflow"** button
|
|
201
201
|
5. Fill in the required information:
|
|
202
202
|
- **Branch**: Select `main` (or your release branch)
|
|
203
|
-
- **Version number**: Enter the new version (e.g., `0.2.
|
|
203
|
+
- **Version number**: Enter the new version (e.g., `0.2.11`)
|
|
204
204
|
- **Is this a pre-release?**: Check if this is a pre-release version
|
|
205
205
|
|
|
206
206
|
#### 3. Monitor the Release
|
|
@@ -219,7 +219,7 @@ After the workflow completes:
|
|
|
219
219
|
|
|
220
220
|
```bash
|
|
221
221
|
# Verify the package is available on PyPI
|
|
222
|
-
pip install tlpytools==0.2.
|
|
222
|
+
pip install tlpytools==0.2.11 # Replace with your version
|
|
223
223
|
|
|
224
224
|
# Test installation in a fresh environment
|
|
225
225
|
python -c "import tlpytools; print(tlpytools.__version__)"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tlpytools
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.11
|
|
4
4
|
Summary: TransLink's Python Tools - A comprehensive toolkit for transportation modeling and forecasting
|
|
5
5
|
Project-URL: Homepage, https://github.com/TransLinkForecasting/tlpytools
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/TransLinkForecasting/tlpytools/issues
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tlpytools"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.11"
|
|
8
8
|
description = "TransLink's Python Tools - A comprehensive toolkit for transportation modeling and forecasting"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10.0, <3.13"
|
|
@@ -112,6 +112,15 @@ python -m tlpytools.orca --action run_model \
|
|
|
112
112
|
--scenario db_example \
|
|
113
113
|
--mode cloud_production \
|
|
114
114
|
--project custom_project
|
|
115
|
+
|
|
116
|
+
# Debugging: run just one step, then stop
|
|
117
|
+
python -m tlpytools.orca --action run_model --scenario db_example --execution-options one_step
|
|
118
|
+
|
|
119
|
+
# Debugging: run just one iteration, then stop
|
|
120
|
+
python -m tlpytools.orca --action run_model --scenario db_example --execution-options one_iteration
|
|
121
|
+
|
|
122
|
+
# Debugging: reset state to iteration 2, step 'quetzal', then run the full remaining model
|
|
123
|
+
python -m tlpytools.orca --action run_model --scenario db_example --resume-iteration 2 --resume-step quetzal
|
|
115
124
|
```
|
|
116
125
|
|
|
117
126
|
#### 2. Initialize Scenario (`init_model`)
|
|
@@ -148,6 +157,9 @@ python -m tlpytools.orca --action adls_sync --project my_project_folder --scenar
|
|
|
148
157
|
| `--scenario` | Name of the scenario | `db_test` |
|
|
149
158
|
| `--mode` | Execution mode (`local_testing`, `cloud_production`) | `local_testing` |
|
|
150
159
|
| `--project` | Override ADLS project folder path (see priority below) | From config file |
|
|
160
|
+
| `--execution-options` | `run_model` granularity: `full`, `one_step`, or `one_iteration` (run_model only) | `full` |
|
|
161
|
+
| `--resume-iteration` | Reset state to this iteration before running (run_model only) | None |
|
|
162
|
+
| `--resume-step` | Reset state to this step name before running; requires `--resume-iteration` (run_model only) | None |
|
|
151
163
|
| `--verbose` | Enable verbose logging | `False` |
|
|
152
164
|
|
|
153
165
|
**ADLS Project Folder Priority:**
|
|
@@ -456,7 +468,7 @@ Logs are written to `orca_YYYYMMDD_HHMMSS.log` in the scenario directory.
|
|
|
456
468
|
|
|
457
469
|
## Model Execution and Resume Behavior
|
|
458
470
|
|
|
459
|
-
The orchestrator uses the configuration file and state file to determine what to run. **
|
|
471
|
+
The orchestrator uses the configuration file and state file to determine what to run. **The total number of iterations and the list of steps come from the config file** - there are no CLI overrides for these totals. The CLI does support overriding *where in that sequence* a run starts or stops, via `--execution-options`/`--resume-iteration`/`--resume-step` (see [Options](#options) above) - useful for debugging a single step or iteration without editing the config file.
|
|
460
472
|
|
|
461
473
|
### First Run
|
|
462
474
|
When you run a model for the first time (no state file exists):
|
|
@@ -482,11 +494,34 @@ To restart a model from the beginning:
|
|
|
482
494
|
1. Delete or rename the state file (`orca_model_state.json`)
|
|
483
495
|
2. Or delete the entire scenario and reinitialize with `--action init_model`
|
|
484
496
|
|
|
497
|
+
### Restarting From a Specific Iteration/Step
|
|
498
|
+
To re-run from a specific point without discarding everything before it, pass `--resume-iteration`
|
|
499
|
+
(and optionally `--resume-step`) to `run_model`:
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
# Reset state to iteration 2, step 'quetzal', then run the full remaining model
|
|
503
|
+
python -m tlpytools.orca --action run_model --scenario db_example --resume-iteration 2 --resume-step quetzal
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
- `--resume-step` requires `--resume-iteration`; omit `--resume-step` to resume from the start of
|
|
507
|
+
that iteration. Iterations are numbered from `iterations.start_at` (default 1).
|
|
508
|
+
- A resume only rewinds the scenario to that point; the run that follows (full, one iteration or
|
|
509
|
+
one step) is chosen with `--execution-options`. Resuming at the point the run is already at is
|
|
510
|
+
allowed and changes nothing.
|
|
511
|
+
- A resume point ahead of the current progress is rejected, since the steps in between have no
|
|
512
|
+
outputs yet.
|
|
513
|
+
- Output archives produced by the affected steps/iterations are renamed with a `_bak` suffix
|
|
514
|
+
before being regenerated - they are not deleted, but are not used by subsequent steps either.
|
|
515
|
+
In `cloud_production` mode the same files are also renamed in ADLS before the run starts, so
|
|
516
|
+
the regenerated archives can be uploaded under their original names.
|
|
517
|
+
- Combine with `--execution-options one_step`/`one_iteration` to stop after just the resumed
|
|
518
|
+
step/iteration instead of running to completion.
|
|
519
|
+
|
|
485
520
|
This design ensures:
|
|
486
|
-
- **Predictable behavior**: Config file is the single source of truth
|
|
521
|
+
- **Predictable behavior**: Config file is the single source of truth for iteration/step totals
|
|
487
522
|
- **Easy resumption**: Just run the same command - it figures out what's needed
|
|
488
523
|
- **Change flexibility**: Update config file to run more iterations or different steps
|
|
489
|
-
- **
|
|
524
|
+
- **Explicit debugging escape hatch**: `--execution-options`/`--resume-iteration`/`--resume-step` let you deliberately override the resume point without touching the config file, while normal re-runs remain config-driven
|
|
490
525
|
|
|
491
526
|
## File Management
|
|
492
527
|
|
|
@@ -563,15 +598,18 @@ The orchestrator implements intelligent, state-aware synchronization with Azure
|
|
|
563
598
|
The orchestrator compares state files to determine sync eligibility:
|
|
564
599
|
|
|
565
600
|
**State Comparison Logic:**
|
|
566
|
-
- Compares `total_steps_completed`, `current_iteration`, and `current_step_index`
|
|
601
|
+
- Compares `resume_generation` first (a higher generation is ahead), then `total_steps_completed`, `current_iteration`, and `current_step_index`
|
|
567
602
|
- Returns: `state1_ahead`, `state2_ahead`, `equal`, or `incomparable`
|
|
568
603
|
|
|
569
604
|
**Upload Rules:**
|
|
570
605
|
- ❌ Barebone configs are never uploaded (used to download model run from cloud)
|
|
571
606
|
- ✅ Upload only if local state is ahead of or equal to remote state
|
|
572
607
|
- ❌ Upload blocked if remote state is ahead (prevents overwriting newer data)
|
|
608
|
+
- ✅ A state rewound by a resume has a higher `resume_generation` and is allowed to replace the remote state
|
|
573
609
|
- If remote doesn't exist: Upload everything (inputs, components, outputs, config, state)
|
|
574
610
|
- If remote exists: Upload only state and new outputs files
|
|
611
|
+
- Outputs already present in the cloud are skipped, except archives regenerated in the current session: the cloud copy is moved to `.cloud_sync_conflict/` and the new file is uploaded
|
|
612
|
+
- A failed upload (outputs, or config/state) makes the sync return failure; if the existing cloud file cannot be moved to `.cloud_sync_conflict/`, it is never overwritten
|
|
575
613
|
|
|
576
614
|
**Download Rules:**
|
|
577
615
|
- ✅ Barebone configs always allow download (will be overwritten completely)
|
|
@@ -579,6 +617,7 @@ The orchestrator compares state files to determine sync eligibility:
|
|
|
579
617
|
- ❌ Download blocked if local state is ahead (prevents overwriting local progress)
|
|
580
618
|
- If local is barebone or empty: Download everything from remote
|
|
581
619
|
- If local exists: Download only state and new outputs files
|
|
620
|
+
- A failed component, config/state or output download makes the sync return failure (re-run to fetch what is missing)
|
|
582
621
|
|
|
583
622
|
#### Selective File Synchronization
|
|
584
623
|
|
|
@@ -597,9 +636,10 @@ The orchestrator compares state files to determine sync eligibility:
|
|
|
597
636
|
- This design assumes sub-components can run iterations using files from inputs/outputs
|
|
598
637
|
|
|
599
638
|
**Download Behavior:**
|
|
600
|
-
- Component zip files are extracted
|
|
601
|
-
- Config files are downloaded
|
|
639
|
+
- Component zip files are extracted into a staging folder and swapped in, so a corrupt archive never replaces a working component
|
|
640
|
+
- Config and state files are downloaded to a staging folder before replacing the existing files
|
|
602
641
|
- Logs subdirectory files are downloaded (performance data and logs)
|
|
642
|
+
- Outputs keep their path below `outputs/`; an existing local file is kept, except that a local pre-resume archive is renamed to match a cloud resume backup (`<name>_<timestamp>_bak.<ext>`) so the regenerated archive downloads
|
|
603
643
|
- Conflict files are moved to `.cloud_sync_conflict/` folder
|
|
604
644
|
- Files in `.cloud_sync_conflict/` are always skipped during sync
|
|
605
645
|
|
|
@@ -636,18 +676,26 @@ The orchestrator maintains execution state in `orca_model_state.json`:
|
|
|
636
676
|
- `project_name`: Project identifier for cloud synchronization (from config or --project override)
|
|
637
677
|
- `scenario_name`: Model run identifier (always derived from local folder basename)
|
|
638
678
|
- `total_steps_completed`: Cumulative steps across all iterations (used for state comparison)
|
|
639
|
-
- `current_iteration`: Current iteration number (1
|
|
679
|
+
- `current_iteration`: Current iteration number (numbered from `start_at`, default 1)
|
|
640
680
|
- `current_step_index`: Index of current step within iteration (0-based)
|
|
641
681
|
- `completed_steps`: Steps completed in current iteration (resets each iteration)
|
|
682
|
+
- `resume_generation`: Incremented each time a resume rewinds progress (0 if never resumed)
|
|
683
|
+
- `output_archives`: Registry of the output archive file for each step/archive/iteration
|
|
642
684
|
|
|
643
685
|
### State Comparison
|
|
644
686
|
|
|
645
687
|
The `OrcaState.compare_states()` method determines which state is further ahead:
|
|
646
688
|
1. First checks project/scenario name compatibility
|
|
647
|
-
2. Compares `
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
689
|
+
2. Compares `resume_generation`: the higher generation is ahead, because a resume deliberately
|
|
690
|
+
rewinds progress and the rewound state must be able to replace the older one
|
|
691
|
+
3. For equal generations, compares `total_steps_completed` (primary progress metric)
|
|
692
|
+
4. If equal, compares `current_iteration`
|
|
693
|
+
5. If equal, compares `current_step_index`
|
|
694
|
+
6. Returns: `state1_ahead`, `state2_ahead`, `equal`, or `incomparable`
|
|
695
|
+
|
|
696
|
+
The state file is written atomically (temp file, then replace). An unreadable state
|
|
697
|
+
file is kept as `orca_model_state.json.corrupt_<timestamp>` and a default state is started, so
|
|
698
|
+
the damaged file can be inspected instead of being overwritten.
|
|
651
699
|
|
|
652
700
|
## Performance Monitoring
|
|
653
701
|
|
|
@@ -1026,22 +1074,29 @@ For more details about the Azure credential manager, see [docs/azure_credential_
|
|
|
1026
1074
|
|
|
1027
1075
|
#### Basic Usage
|
|
1028
1076
|
```bash
|
|
1029
|
-
python batch_task_runner
|
|
1077
|
+
python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_project --scenario my_scenario
|
|
1030
1078
|
```
|
|
1031
1079
|
|
|
1032
1080
|
#### Full Example with All Options
|
|
1033
1081
|
```bash
|
|
1034
|
-
python batch_task_runner
|
|
1082
|
+
python -m tlpytools.orca.batch_task_runner \
|
|
1035
1083
|
--job-id job_large \
|
|
1036
1084
|
--project orca_optimization \
|
|
1037
1085
|
--scenario db_test \
|
|
1038
|
-
--python-command orca/orchestrator.py \
|
|
1039
|
-
--python-env orca \
|
|
1040
1086
|
--docker-image orca/orca:develop \
|
|
1041
1087
|
--max-retry-count 2 \
|
|
1042
1088
|
--max-wall-clock-time PT8H \
|
|
1043
1089
|
--poll-interval 45 \
|
|
1044
|
-
--
|
|
1090
|
+
--timeout-minutes 480
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
#### Debugging a Single Step or Resume Point
|
|
1094
|
+
```bash
|
|
1095
|
+
# Run just one step, then stop
|
|
1096
|
+
python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_project --scenario my_scenario --execution-options one_step
|
|
1097
|
+
|
|
1098
|
+
# Reset state to iteration 2, step 'quetzal', then run the full remaining model
|
|
1099
|
+
python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_project --scenario my_scenario --resume-iteration 2 --resume-step quetzal
|
|
1045
1100
|
```
|
|
1046
1101
|
|
|
1047
1102
|
### Command Line Arguments
|
|
@@ -1051,38 +1106,56 @@ python batch_task_runner.py \
|
|
|
1051
1106
|
| `--job-id` | Yes | - | Batch job ID where the task will be submitted |
|
|
1052
1107
|
| `--project` | Yes | - | Project name (used in task ID generation) |
|
|
1053
1108
|
| `--scenario` | Yes | - | Scenario name for the ORCA task |
|
|
1054
|
-
| `--python-
|
|
1055
|
-
| `--python-
|
|
1109
|
+
| `--override-python-env` | No | Docker image default | Python environment path inside the container |
|
|
1110
|
+
| `--override-python-command` | No | Docker image default | Python command/script to run inside the container |
|
|
1111
|
+
| `--override-python-options` | No | Default orca `run_model` options | Full command-line options string; if set, `--execution-options`/`--resume-iteration`/`--resume-step` below are ignored |
|
|
1112
|
+
| `--execution-options` | No | `full` | `run_model` granularity: `full`, `one_step`, or `one_iteration` |
|
|
1113
|
+
| `--resume-iteration` | No | - | Reset state to this iteration before running |
|
|
1114
|
+
| `--resume-step` | No | - | Reset state to this step name before running (requires `--resume-iteration`) |
|
|
1056
1115
|
| `--docker-image` | No | `orca/orca:develop` | Docker image to use |
|
|
1057
1116
|
| `--max-retry-count` | No | `0` | Maximum number of task retries |
|
|
1058
1117
|
| `--max-wall-clock-time` | No | `PT6H` | Maximum wall clock time (ISO 8601) |
|
|
1059
1118
|
| `--poll-interval` | No | `30` | Polling interval in seconds |
|
|
1060
|
-
| `--
|
|
1119
|
+
| `--timeout-minutes` | No | `360` | Maximum minutes to monitor before giving up (task keeps running on Azure Batch regardless) |
|
|
1061
1120
|
| `--skip-duplicate-check` | No | `False` | Skip duplicate task detection (use with caution) |
|
|
1121
|
+
| `--log-file` | No | Auto-generated | Log file path |
|
|
1122
|
+
| `--log-level` | No | `INFO` | Logging level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) |
|
|
1062
1123
|
|
|
1063
1124
|
### How It Works
|
|
1064
1125
|
|
|
1065
1126
|
1. **Duplicate Detection**: Checks for existing tasks with the same project and scenario name
|
|
1066
|
-
-
|
|
1067
|
-
|
|
1127
|
+
- A task that is already `active`, `preparing` or `running` is monitored instead of resubmitted
|
|
1128
|
+
(the newest one, if several); requested execution/resume options are NOT applied to it
|
|
1129
|
+
- A successfully `completed` task blocks submission (it would overwrite finished results)
|
|
1130
|
+
- Allows resubmission when previous tasks have failed
|
|
1068
1131
|
- Provides clear user-facing messages with guidance on how to proceed
|
|
1069
1132
|
- Can be bypassed with `--skip-duplicate-check` flag if needed
|
|
1070
1133
|
2. **Task Submission**: Creates a unique task ID and submits it to the specified Azure Batch job
|
|
1071
1134
|
3. **Status Monitoring**: Polls the task status at regular intervals
|
|
1072
|
-
4. **Early Exit**: Stops polling when the task reaches
|
|
1073
|
-
5. **
|
|
1135
|
+
4. **Early Exit**: Stops polling when the task reaches the 'completed' state, or fails
|
|
1136
|
+
5. **Failure Detection**: Azure Batch reports a task whose command exited non-zero as `completed`
|
|
1137
|
+
with `executionInfo.result = "failure"`. The runner treats that (or any non-zero `exitCode`)
|
|
1138
|
+
as a failed task, prints the exit code, and `run_task()` raises `RuntimeError` / the CLI exits
|
|
1139
|
+
non-zero. This includes a run whose final save to ADLS failed.
|
|
1140
|
+
6. **Timeout Handling**: Fails if the task doesn't finish within the specified timeout
|
|
1141
|
+
|
|
1142
|
+
`run_task()` and `wait_for_task_completion()` accept an optional `status_callback(state, message)`
|
|
1143
|
+
that is called during the duplicate check (`CHECKING`), task creation (`SUBMITTING`) and after each
|
|
1144
|
+
poll with the Batch state (`active`, `running`, `completed`), for live progress displays.
|
|
1074
1145
|
|
|
1075
1146
|
### Duplicate Task Detection
|
|
1076
1147
|
|
|
1077
|
-
The batch task runner includes automatic duplicate detection to prevent accidental resubmission of tasks
|
|
1148
|
+
The batch task runner includes automatic duplicate detection to prevent accidental resubmission of tasks.
|
|
1149
|
+
If a matching task is still queued or running, `run_task()` (and the CLI) attach to it and report its
|
|
1150
|
+
status until it finishes. The block below is shown only when the matching task already completed:
|
|
1078
1151
|
|
|
1079
|
-
**When a duplicate is detected:**
|
|
1152
|
+
**When a completed duplicate is detected:**
|
|
1080
1153
|
```
|
|
1081
1154
|
======================================================================
|
|
1082
1155
|
[WARNING] DUPLICATE TASK DETECTED
|
|
1083
1156
|
======================================================================
|
|
1084
1157
|
|
|
1085
|
-
Found 1 existing task(s) with matching project/scenario: task_id (
|
|
1158
|
+
Found 1 existing task(s) with matching project/scenario: task_id (completed).
|
|
1086
1159
|
Cannot submit duplicate task while previous task is still active, running, or completed.
|
|
1087
1160
|
|
|
1088
1161
|
[INFO] A task with the same project and scenario name already exists.
|
|
@@ -1101,8 +1174,9 @@ Cannot submit duplicate task while previous task is still active, running, or co
|
|
|
1101
1174
|
```
|
|
1102
1175
|
|
|
1103
1176
|
**Behavior:**
|
|
1104
|
-
- Tasks with same project/scenario in
|
|
1105
|
-
- Tasks in `
|
|
1177
|
+
- Tasks with same project/scenario in state `active`, `preparing` or `running` are monitored, not resubmitted
|
|
1178
|
+
- Tasks in state `completed` (successful exit) block new submissions
|
|
1179
|
+
- Tasks in `failed` state, and `completed` tasks whose command exited non-zero, allow automatic resubmission
|
|
1106
1180
|
- Use `--skip-duplicate-check` flag to bypass detection (use with caution)
|
|
1107
1181
|
|
|
1108
1182
|
### Task ID Format
|