accli 2.2.1__tar.gz → 2.3.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.
- {accli-2.2.1 → accli-2.3.0}/PKG-INFO +65 -1
- accli-2.3.0/README.md +222 -0
- {accli-2.2.1 → accli-2.3.0}/accli/AcceleratorTaskDispatcher.py +60 -83
- {accli-2.2.1 → accli-2.3.0}/accli/_version.py +1 -1
- {accli-2.2.1 → accli-2.3.0}/accli/cli.py +411 -36
- accli-2.3.0/accli/file_filter.py +175 -0
- {accli-2.2.1 → accli-2.3.0}/accli/gui.py +79 -4
- accli-2.3.0/accli/iiasa-internal-s3.crt +23 -0
- accli-2.3.0/accli/internal_certs.py +467 -0
- {accli-2.2.1 → accli-2.3.0}/accli/setup-nfs.ps1 +33 -1
- {accli-2.2.1 → accli-2.3.0}/accli/token.py +13 -0
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/PKG-INFO +65 -1
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/SOURCES.txt +7 -0
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/requires.txt +1 -0
- {accli-2.2.1 → accli-2.3.0}/pyproject.toml +2 -1
- accli-2.3.0/tests/test_file_filter.py +235 -0
- accli-2.3.0/tests/test_internal_certs.py +546 -0
- accli-2.3.0/tests/test_job_folder_size.py +68 -0
- {accli-2.2.1 → accli-2.3.0}/tests/test_jobs_commands.py +2 -1
- {accli-2.2.1 → accli-2.3.0}/tests/test_mount_lifecycle.py +7 -0
- {accli-2.2.1 → accli-2.3.0}/tests/test_update_check.py +1 -0
- accli-2.3.0/tests/test_version_control_upload.py +191 -0
- accli-2.2.1/README.md +0 -159
- {accli-2.2.1 → accli-2.3.0}/LICENSE +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/AcceleratorJobProjectService.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/AcceleratorTerminalCliProjectService.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/CsvRegionalTimeseriesValidator.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/__init__.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/__main__.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/acc_logo.ico +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/acc_logo.png +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/cleanup-nfs.ps1 +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/common.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/job_views.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/log_timeline.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/mount_downloader.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/nfs_watcher.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/refresh_explorer.ps1 +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/version_checker.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli/xet_cache.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/dependency_links.txt +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/entry_points.txt +0 -0
- {accli-2.2.1 → accli-2.3.0}/accli.egg-info/top_level.txt +0 -0
- {accli-2.2.1 → accli-2.3.0}/setup.cfg +0 -0
- {accli-2.2.1 → accli-2.3.0}/tests/test_log_timeline.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/tests/test_logs_command.py +0 -0
- {accli-2.2.1 → accli-2.3.0}/tests/test_xet_cache.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: accli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: IIASA Accelerator Client
|
|
5
5
|
Author-email: Wrufesh S <wrufesh@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -40,6 +40,7 @@ Requires-Dist: jsonschema>=4.5.1
|
|
|
40
40
|
Requires-Dist: pydantic>=2.0
|
|
41
41
|
Requires-Dist: GitPython
|
|
42
42
|
Requires-Dist: hf-xet==1.8.0
|
|
43
|
+
Requires-Dist: cryptography>=3.4
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
45
46
|
# Accelerator Terminal Client and Python API
|
|
@@ -96,6 +97,42 @@ irm https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.ps1 | i
|
|
|
96
97
|
pip install accli --user
|
|
97
98
|
```
|
|
98
99
|
|
|
100
|
+
#### IIASA storage certificate
|
|
101
|
+
|
|
102
|
+
On the IIASA network, downloads go directly to the internal storage server (currently `hctr01obj81.iiasa.ac.at`), which uses a self-signed certificate. Uploads always go through the Accelerator server and never need it.
|
|
103
|
+
|
|
104
|
+
- **Downloads (`accli copy acc://… <local path>`):** the Accelerator server tells accli whether your computer counts as internal (VPN connections do not). Outside the IIASA network nothing is required.
|
|
105
|
+
- **Mounts (`accli mount start`):** the certificate is always required, on any network. A mount keeps running when a laptop moves onto the IIASA network, and its reads would then fail without the certificate.
|
|
106
|
+
|
|
107
|
+
accli ships the certificate and makes sure it is trusted:
|
|
108
|
+
|
|
109
|
+
- **Windows:** installed into the machine-wide trusted certificates. Windows asks for administrator approval once.
|
|
110
|
+
- **macOS:** added to the System keychain. macOS asks for your password once.
|
|
111
|
+
- **Linux:** accli writes `~/.accli/ca-bundle.pem` (the system's trusted certificates plus this one) and uses it automatically. No administrator rights are needed.
|
|
112
|
+
|
|
113
|
+
To check or install it yourself:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
accli cert status # add --json for a machine-readable result
|
|
117
|
+
accli cert install
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
IT administrators can install it ahead of time with `setup-nfs.ps1` on Windows (see [SECURITY.md](SECURITY.md)).
|
|
121
|
+
|
|
122
|
+
**When the storage certificate changes:** accli asks the Accelerator server for the current certificate at most once a day (and every time you run `accli cert status` or `accli cert install`), saves it in `~/.accli/storage-certs/`, and asks you to install it, the same way as the first time. No accli update is needed. Certificates installed earlier stay trusted, so nothing breaks during the switch.
|
|
123
|
+
|
|
124
|
+
Because a certificate from the network ends up trusted by your computer, accli only accepts one that cannot vouch for anything else: not a certificate authority, valid for exactly one server under `iiasa.ac.at` (no wildcards), and currently valid. Anything else is refused with a warning, and accli keeps using the certificate it has.
|
|
125
|
+
|
|
126
|
+
For server administrators: the Accelerator server publishes the current certificate by default (`configs/InternalStorageCert.py`). To change it, replace it there, or set `XET_CAS_S3_INTERNAL_CERT_BASE64` (the base64 of the PEM file), **at least a day before** switching the storage server to it, so users have it before it is needed.
|
|
127
|
+
|
|
128
|
+
#### AI agents and scripts
|
|
129
|
+
|
|
130
|
+
When accli runs without an interactive terminal (AI agents, scripts, CI), it never opens an administrator prompt, because nobody could answer it. If a person has to act first, the command stops with **exit code 3** and prints a message starting with `ACTION REQUIRED:` that says what to ask the user to run (for example `accli cert install`). Exit code 1 still means other errors.
|
|
131
|
+
|
|
132
|
+
- `accli cert status --json` lets an agent check in advance: `"action_required": true` means a person must run `"fix_command"`.
|
|
133
|
+
- `ACCLI_NO_PROMPT=1` turns prompts off even in a terminal. Set it for agent tools that run commands in a terminal, so accli stops with exit code 3 instead of waiting on a dialog nobody sees.
|
|
134
|
+
- The same guidance is printed by `accli --help`, and in short by `accli copy --help`, `accli mount start --help` and `accli cert --help`.
|
|
135
|
+
|
|
99
136
|
### ▶️ Usage
|
|
100
137
|
|
|
101
138
|
#### As a Python Module
|
|
@@ -162,6 +199,33 @@ accli job restart my-project 1234
|
|
|
162
199
|
accli job restart my-project 1234 --rebuild
|
|
163
200
|
```
|
|
164
201
|
|
|
202
|
+
### 📁 Copying files
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
accli copy ./results acc://my-project/results # upload a folder
|
|
206
|
+
accli copy acc://my-project/results ./results # download
|
|
207
|
+
accli copy ./myjob acc://my-project/jobstore/20261126/<id> --exclude ".git, .venv, __pycache__, *.pyc"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
When uploading a folder, `--include` and `--exclude` choose which files to upload. They work the same as `include` and `exclude` in `wkube.py`: comma-separated wildcard patterns, matched against file and folder names and their paths inside the folder. A matching folder covers everything in it (`.git` leaves out the whole `.git` folder), `--include` wins over `--exclude`, and with only `--include` nothing else is uploaded. Nothing is left out automatically, not even `.git`, in `accli copy` or in the job folder upload of `accli dispatch`.
|
|
211
|
+
|
|
212
|
+
Version-control folders (`.git`, `.svn`, `.hg`, `.bzr`) are not uploaded by accident, though. When an upload of `accli copy` or `accli dispatch` would include one, accli asks `Upload them anyway? [y/N]`. Without a terminal (AI agents, scripts) it stops instead and explains how to exclude them; the GUI asks in a dialog. Pass `-y` to upload them without asking, or exclude them (`--exclude ".git"`, or `exclude=".git"` in `wkube.py`).
|
|
213
|
+
|
|
214
|
+
To see what makes a folder large before uploading it, `accli size` lists its largest files and folders, largest first. It takes the same `--include`/`--exclude`, so you can check what an upload would contain:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
accli size ./myjob
|
|
218
|
+
accli size ./myjob --exclude ".git, .venv, outputs" --top 10
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### Large job folders
|
|
222
|
+
|
|
223
|
+
`accli dispatch` uploads the job folder from `wkube.py` to build the job's container image, and stops if that upload is over 1 GB. The error message then explains the steps, with a ready-to-use path:
|
|
224
|
+
|
|
225
|
+
1. Upload the job folder to the project space with `accli copy … acc://<project>/jobstore/<YYYYMMDD>/<id>`, using `--exclude`/`--include` to leave out what the job does not need while it runs.
|
|
226
|
+
2. In `wkube.py`, set `include`/`exclude` so the job folder upload contains only the files the image build needs.
|
|
227
|
+
3. In `wkube.py`, run the job from the uploaded copy: `command="cd /mnt/wdrv/jobstore/<YYYYMMDD>/<id> && …"`.
|
|
228
|
+
|
|
165
229
|
---
|
|
166
230
|
|
|
167
231
|
## 👩💻 Developer Guide
|
accli-2.3.0/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Accelerator Terminal Client and Python API
|
|
2
|
+
|
|
3
|
+
This package provides:
|
|
4
|
+
|
|
5
|
+
- A **command-line client** (`accli`) for interacting with the **Accelerator**.
|
|
6
|
+
- A **Python API** via the `accli` package.
|
|
7
|
+
|
|
8
|
+
Both interfaces communicate with the Accelerator’s REST API, implemented in
|
|
9
|
+
the [Control Services Backend](https://github.com/iiasa/control_services_backend).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🔐 Authentication
|
|
14
|
+
|
|
15
|
+
This client uses **device authentication** via Auth0.
|
|
16
|
+
|
|
17
|
+
- **OAuth Flow
|
|
18
|
+
**: [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
|
|
19
|
+
- **Token Validity**: 7 days
|
|
20
|
+
- **Access Control**: Role-Based Access Control (RBAC) with stateless tokens
|
|
21
|
+
- **Grants**: Limited and scoped
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📖 User Guide
|
|
26
|
+
|
|
27
|
+
### ✅ Requirements
|
|
28
|
+
|
|
29
|
+
- Python >= 3.8
|
|
30
|
+
|
|
31
|
+
### 📦 Installation
|
|
32
|
+
|
|
33
|
+
#### Option 1: Standalone Binaries (Recommended)
|
|
34
|
+
|
|
35
|
+
No Python install required. Run the appropriate command for your system:
|
|
36
|
+
|
|
37
|
+
**Linux / macOS:**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curl -fsSL https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.sh | bash
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Windows (PowerShell):**
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
irm https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.ps1 | iex
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Option 2: Via PIP
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install accli --user
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### IIASA storage certificate
|
|
56
|
+
|
|
57
|
+
On the IIASA network, downloads go directly to the internal storage server (currently `hctr01obj81.iiasa.ac.at`), which uses a self-signed certificate. Uploads always go through the Accelerator server and never need it.
|
|
58
|
+
|
|
59
|
+
- **Downloads (`accli copy acc://… <local path>`):** the Accelerator server tells accli whether your computer counts as internal (VPN connections do not). Outside the IIASA network nothing is required.
|
|
60
|
+
- **Mounts (`accli mount start`):** the certificate is always required, on any network. A mount keeps running when a laptop moves onto the IIASA network, and its reads would then fail without the certificate.
|
|
61
|
+
|
|
62
|
+
accli ships the certificate and makes sure it is trusted:
|
|
63
|
+
|
|
64
|
+
- **Windows:** installed into the machine-wide trusted certificates. Windows asks for administrator approval once.
|
|
65
|
+
- **macOS:** added to the System keychain. macOS asks for your password once.
|
|
66
|
+
- **Linux:** accli writes `~/.accli/ca-bundle.pem` (the system's trusted certificates plus this one) and uses it automatically. No administrator rights are needed.
|
|
67
|
+
|
|
68
|
+
To check or install it yourself:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
accli cert status # add --json for a machine-readable result
|
|
72
|
+
accli cert install
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
IT administrators can install it ahead of time with `setup-nfs.ps1` on Windows (see [SECURITY.md](SECURITY.md)).
|
|
76
|
+
|
|
77
|
+
**When the storage certificate changes:** accli asks the Accelerator server for the current certificate at most once a day (and every time you run `accli cert status` or `accli cert install`), saves it in `~/.accli/storage-certs/`, and asks you to install it, the same way as the first time. No accli update is needed. Certificates installed earlier stay trusted, so nothing breaks during the switch.
|
|
78
|
+
|
|
79
|
+
Because a certificate from the network ends up trusted by your computer, accli only accepts one that cannot vouch for anything else: not a certificate authority, valid for exactly one server under `iiasa.ac.at` (no wildcards), and currently valid. Anything else is refused with a warning, and accli keeps using the certificate it has.
|
|
80
|
+
|
|
81
|
+
For server administrators: the Accelerator server publishes the current certificate by default (`configs/InternalStorageCert.py`). To change it, replace it there, or set `XET_CAS_S3_INTERNAL_CERT_BASE64` (the base64 of the PEM file), **at least a day before** switching the storage server to it, so users have it before it is needed.
|
|
82
|
+
|
|
83
|
+
#### AI agents and scripts
|
|
84
|
+
|
|
85
|
+
When accli runs without an interactive terminal (AI agents, scripts, CI), it never opens an administrator prompt, because nobody could answer it. If a person has to act first, the command stops with **exit code 3** and prints a message starting with `ACTION REQUIRED:` that says what to ask the user to run (for example `accli cert install`). Exit code 1 still means other errors.
|
|
86
|
+
|
|
87
|
+
- `accli cert status --json` lets an agent check in advance: `"action_required": true` means a person must run `"fix_command"`.
|
|
88
|
+
- `ACCLI_NO_PROMPT=1` turns prompts off even in a terminal. Set it for agent tools that run commands in a terminal, so accli stops with exit code 3 instead of waiting on a dialog nobody sees.
|
|
89
|
+
- The same guidance is printed by `accli --help`, and in short by `accli copy --help`, `accli mount start --help` and `accli cert --help`.
|
|
90
|
+
|
|
91
|
+
### ▶️ Usage
|
|
92
|
+
|
|
93
|
+
#### As a Python Module
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python -m accli
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### As an Executable
|
|
100
|
+
|
|
101
|
+
After installation, the executable might not be in your system `PATH`. You may see a warning like this:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
WARNING: The script accli.exe is installed in 'C:\Users\<user>\AppData\Roaming\Python\Python311\Scripts' which is not on PATH.
|
|
105
|
+
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
To resolve this, add the script's path to your system's environment variables:
|
|
109
|
+
|
|
110
|
+
- [Update PATH on Windows](https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10-with-screensho)
|
|
111
|
+
- [Update PATH on Linux](https://www.geeksforgeeks.org/how-to-set-path-permanantly-in-linux/)
|
|
112
|
+
|
|
113
|
+
> **Note:** On Linux/macOS, you may need to prefix the command with `./`, and on Windows, with `.\`.
|
|
114
|
+
|
|
115
|
+
### 🔍 Help Command
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
accli --help
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Sample Output:**
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Usage: accli [OPTIONS] COMMAND [ARGS]...
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 📋 Jobs
|
|
128
|
+
|
|
129
|
+
List root jobs, newest first, with each job's type (`standalone`, `children`, `callback` or `children+callback`), its own status and the status of its whole graph:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
accli jobs my-project # latest 10
|
|
133
|
+
accli jobs my-project -n 50
|
|
134
|
+
accli jobs my-project -s failed # graphs with a failed job
|
|
135
|
+
accli jobs my-project -s processing,error
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`--status` filters on the graph status: `processing` (or `active`), `error` (or `failed`) and `done`. A standalone job counts by its own status.
|
|
139
|
+
|
|
140
|
+
Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <project> <job>`:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
accli job my-project 1234
|
|
144
|
+
accli job my-project 1234 --json
|
|
145
|
+
accli job show my-project 1234
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`accli job <project> <job>` is the same as `accli job show <project> <job>`.
|
|
149
|
+
|
|
150
|
+
Restart a job that is done or failed. The job can be a root job or a child job. The command fails if that job, a parent, or a descendant is still processing. `--rebuild` builds the container image again before the job starts.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
accli job restart my-project 1234
|
|
154
|
+
accli job restart my-project 1234 --rebuild
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 📁 Copying files
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
accli copy ./results acc://my-project/results # upload a folder
|
|
161
|
+
accli copy acc://my-project/results ./results # download
|
|
162
|
+
accli copy ./myjob acc://my-project/jobstore/20261126/<id> --exclude ".git, .venv, __pycache__, *.pyc"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
When uploading a folder, `--include` and `--exclude` choose which files to upload. They work the same as `include` and `exclude` in `wkube.py`: comma-separated wildcard patterns, matched against file and folder names and their paths inside the folder. A matching folder covers everything in it (`.git` leaves out the whole `.git` folder), `--include` wins over `--exclude`, and with only `--include` nothing else is uploaded. Nothing is left out automatically, not even `.git`, in `accli copy` or in the job folder upload of `accli dispatch`.
|
|
166
|
+
|
|
167
|
+
Version-control folders (`.git`, `.svn`, `.hg`, `.bzr`) are not uploaded by accident, though. When an upload of `accli copy` or `accli dispatch` would include one, accli asks `Upload them anyway? [y/N]`. Without a terminal (AI agents, scripts) it stops instead and explains how to exclude them; the GUI asks in a dialog. Pass `-y` to upload them without asking, or exclude them (`--exclude ".git"`, or `exclude=".git"` in `wkube.py`).
|
|
168
|
+
|
|
169
|
+
To see what makes a folder large before uploading it, `accli size` lists its largest files and folders, largest first. It takes the same `--include`/`--exclude`, so you can check what an upload would contain:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
accli size ./myjob
|
|
173
|
+
accli size ./myjob --exclude ".git, .venv, outputs" --top 10
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Large job folders
|
|
177
|
+
|
|
178
|
+
`accli dispatch` uploads the job folder from `wkube.py` to build the job's container image, and stops if that upload is over 1 GB. The error message then explains the steps, with a ready-to-use path:
|
|
179
|
+
|
|
180
|
+
1. Upload the job folder to the project space with `accli copy … acc://<project>/jobstore/<YYYYMMDD>/<id>`, using `--exclude`/`--include` to leave out what the job does not need while it runs.
|
|
181
|
+
2. In `wkube.py`, set `include`/`exclude` so the job folder upload contains only the files the image build needs.
|
|
182
|
+
3. In `wkube.py`, run the job from the uploaded copy: `command="cd /mnt/wdrv/jobstore/<YYYYMMDD>/<id> && …"`.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 👩💻 Developer Guide
|
|
187
|
+
|
|
188
|
+
### Handling self-signed certificates
|
|
189
|
+
|
|
190
|
+
Import the certificates from `accelerator_service` into the Windows Root store (auto-elevates to Administrator if needed):
|
|
191
|
+
```powershell
|
|
192
|
+
cd <path to>/accelerator_service/scripts
|
|
193
|
+
.\import_certs_certutil.ps1
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 🛠 Build & Upload
|
|
197
|
+
|
|
198
|
+
Follow the official Python packaging tutorial:
|
|
199
|
+
[Packaging Projects – Python.org](https://packaging.python.org/en/latest/tutorials/packaging-projects/)
|
|
200
|
+
|
|
201
|
+
### 🚀 Release Process
|
|
202
|
+
|
|
203
|
+
1. Update the version in `accli/_version.py`
|
|
204
|
+
2. Tag the release:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python scripts/tag.py
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
3. Build the package:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
python -m build
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
4. Upload to PyPI:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
twine upload -r pypi -u __token__ -p <password-or-token> ./dist/*
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
@@ -3,9 +3,10 @@ import zipfile
|
|
|
3
3
|
import hashlib
|
|
4
4
|
import shutil
|
|
5
5
|
import tempfile
|
|
6
|
-
import fnmatch
|
|
7
6
|
import concurrent.futures
|
|
8
7
|
import json
|
|
8
|
+
import uuid
|
|
9
|
+
from datetime import datetime
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import Optional, Dict, List
|
|
11
12
|
|
|
@@ -13,6 +14,7 @@ import requests
|
|
|
13
14
|
from functools import lru_cache
|
|
14
15
|
from pydantic import BaseModel, model_validator, Field
|
|
15
16
|
from accli.AcceleratorTerminalCliProjectService import AcceleratorTerminalCliProjectService
|
|
17
|
+
from accli.file_filter import confirm_version_control, iter_selected_files
|
|
16
18
|
from accli.token import (
|
|
17
19
|
get_token, get_server_url,
|
|
18
20
|
get_project_slug, exchange_refresh_token
|
|
@@ -52,42 +54,16 @@ def get_file_sha1(file_path):
|
|
|
52
54
|
return sha1_hash.hexdigest()
|
|
53
55
|
|
|
54
56
|
|
|
55
|
-
def copy_tree(src, dst, include=None, exclude=None
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
dst_path = os.path.join(dst, item)
|
|
66
|
-
rel_path = os.path.relpath(src_path, root_src)
|
|
67
|
-
|
|
68
|
-
if os.path.isdir(src_path):
|
|
69
|
-
if item == '.git':
|
|
70
|
-
continue
|
|
71
|
-
|
|
72
|
-
is_excluded = any(fnmatch.fnmatch(rel_path, p) or fnmatch.fnmatch(item, p) for p in excludes)
|
|
73
|
-
# Traverse even if excluded as long as includes exist, to find exceptions
|
|
74
|
-
if is_excluded and not includes:
|
|
75
|
-
continue
|
|
76
|
-
|
|
77
|
-
os.makedirs(dst_path, exist_ok=True)
|
|
78
|
-
copy_tree(src_path, dst_path, include, exclude, root_src)
|
|
79
|
-
else:
|
|
80
|
-
is_excluded = any(fnmatch.fnmatch(rel_path, p) or fnmatch.fnmatch(item, p) for p in excludes)
|
|
81
|
-
is_included = any(fnmatch.fnmatch(rel_path, p) or fnmatch.fnmatch(item, p) for p in includes)
|
|
82
|
-
|
|
83
|
-
if is_included:
|
|
84
|
-
pass # Included files override exclude
|
|
85
|
-
elif is_excluded:
|
|
86
|
-
continue # Skipped by exclude
|
|
87
|
-
elif includes and not excludes:
|
|
88
|
-
continue # If ONLY includes list is provided, act as whitelist
|
|
89
|
-
|
|
90
|
-
shutil.copy2(src_path, dst_path)
|
|
57
|
+
def copy_tree(src, dst, include=None, exclude=None):
|
|
58
|
+
"""Copy the files of src that include/exclude keep into dst.
|
|
59
|
+
|
|
60
|
+
include/exclude work as described in accli/file_filter.py (the same rules as
|
|
61
|
+
`accli copy --include/--exclude`).
|
|
62
|
+
"""
|
|
63
|
+
for src_path, rel_path in iter_selected_files(src, include, exclude):
|
|
64
|
+
dst_path = os.path.join(dst, *rel_path.split("/"))
|
|
65
|
+
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
|
|
66
|
+
shutil.copy2(src_path, dst_path)
|
|
91
67
|
|
|
92
68
|
|
|
93
69
|
def _upload_cas_file_worker(args):
|
|
@@ -120,33 +96,8 @@ def _upload_cas_file_worker(args):
|
|
|
120
96
|
|
|
121
97
|
MAX_JOB_FOLDER_BYTES = 1024 * 1024 * 1024 # 1 GB
|
|
122
98
|
|
|
123
|
-
#
|
|
124
|
-
|
|
125
|
-
DEPENDENCY_FILE_EXAMPLES = (
|
|
126
|
-
" Containers: Dockerfile, *.dockerfile, Containerfile, .dockerignore, docker-compose.yml, "
|
|
127
|
-
"Singularity / *.def, apptainer.def\n"
|
|
128
|
-
" Python: requirements*.txt, constraints.txt, pyproject.toml, setup.py, setup.cfg, Pipfile, "
|
|
129
|
-
"Pipfile.lock, poetry.lock, uv.lock, pdm.lock, environment.yml, conda-lock.yml, .python-version, runtime.txt\n"
|
|
130
|
-
" R: init.R, install.R, install_packages.R, DESCRIPTION, NAMESPACE, renv.lock, renv/activate.R, "
|
|
131
|
-
".Rprofile, packrat/packrat.lock\n"
|
|
132
|
-
" Julia: Project.toml, Manifest.toml\n"
|
|
133
|
-
" Node/JS: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, .npmrc, .nvmrc\n"
|
|
134
|
-
" Go: go.mod, go.sum\n"
|
|
135
|
-
" Rust: Cargo.toml, Cargo.lock, rust-toolchain.toml\n"
|
|
136
|
-
" Java/JVM: pom.xml, build.gradle, build.gradle.kts, settings.gradle, gradle.properties, "
|
|
137
|
-
"gradle/wrapper/*, build.sbt\n"
|
|
138
|
-
" C/C++: CMakeLists.txt, *.cmake, Makefile, configure, meson.build, conanfile.txt, conanfile.py, vcpkg.json\n"
|
|
139
|
-
" Fortran: fpm.toml, Makefile\n"
|
|
140
|
-
" Ruby/PHP: Gemfile, Gemfile.lock, composer.json, composer.lock\n"
|
|
141
|
-
" .NET: *.csproj, *.sln, packages.config, global.json\n"
|
|
142
|
-
" MATLAB: *.prj, startup.m, buildfile.m\n"
|
|
143
|
-
" GAMS/Optim: solver option files (*.opt), licence/config files the model reads at startup\n"
|
|
144
|
-
" System: apt.txt, packages.txt, install.sh, setup.sh, entrypoint.sh, startscript.sh, Makefile, "
|
|
145
|
-
"Taskfile.yml, justfile, .env.example, *.conf / config files read during setup\n"
|
|
146
|
-
" Also any local package your dependency file points to, e.g. '-e ./mypkg' in requirements.txt "
|
|
147
|
-
"or a vendored wheel/tarball.\n"
|
|
148
|
-
)
|
|
149
|
-
|
|
99
|
+
# Set by `accli dispatch -y`: upload version-control folders in the job folder without asking.
|
|
100
|
+
UPLOAD_VERSION_CONTROL = False
|
|
150
101
|
|
|
151
102
|
def _format_bytes(num_bytes):
|
|
152
103
|
for unit in ("B", "KB", "MB", "GB"):
|
|
@@ -155,6 +106,11 @@ def _format_bytes(num_bytes):
|
|
|
155
106
|
num_bytes /= 1024
|
|
156
107
|
|
|
157
108
|
|
|
109
|
+
def job_code_path():
|
|
110
|
+
"""A new project-space path for job code: jobstore/<date as YYYYMMDD>/<uuid>."""
|
|
111
|
+
return f"jobstore/{datetime.now().strftime('%Y%m%d')}/{uuid.uuid4()}"
|
|
112
|
+
|
|
113
|
+
|
|
158
114
|
def check_job_folder_size(repo_dir, directory, project_slug):
|
|
159
115
|
"""Stop the dispatch if the filtered job folder is larger than MAX_JOB_FOLDER_BYTES."""
|
|
160
116
|
total = 0
|
|
@@ -165,26 +121,42 @@ def check_job_folder_size(repo_dir, directory, project_slug):
|
|
|
165
121
|
if total <= MAX_JOB_FOLDER_BYTES:
|
|
166
122
|
return
|
|
167
123
|
|
|
124
|
+
# A ready-to-use path, so the commands below can be copied as they are.
|
|
125
|
+
code_path = job_code_path()
|
|
126
|
+
|
|
168
127
|
raise ValueError(
|
|
169
|
-
f"
|
|
170
|
-
f"
|
|
171
|
-
f"
|
|
172
|
-
f"
|
|
173
|
-
f"
|
|
174
|
-
f"
|
|
175
|
-
f"
|
|
176
|
-
f"
|
|
177
|
-
f"
|
|
178
|
-
f"
|
|
179
|
-
f"
|
|
180
|
-
f"
|
|
181
|
-
f"
|
|
182
|
-
f"
|
|
183
|
-
f"
|
|
184
|
-
f"
|
|
185
|
-
f"
|
|
186
|
-
f"
|
|
187
|
-
f"
|
|
128
|
+
f"Job folder too large: '{directory}' is {_format_bytes(total)} after the include/exclude "
|
|
129
|
+
f"in wkube.py; the limit is {_format_bytes(MAX_JOB_FOLDER_BYTES)}.\n"
|
|
130
|
+
f"\n"
|
|
131
|
+
f"'accli dispatch' uploads the job folder from wkube.py (job_folder, include, exclude) to build "
|
|
132
|
+
f"the job's container image. Keep that upload to the files the build needs, upload the job's "
|
|
133
|
+
f"code and data to the project space with 'accli copy', and run the job from there.\n"
|
|
134
|
+
f"\n"
|
|
135
|
+
f"Steps:\n"
|
|
136
|
+
f" 1. Upload the job folder to the project space:\n"
|
|
137
|
+
f" accli copy \"{directory}\" acc://{project_slug}/{code_path} --exclude \"<patterns>\"\n"
|
|
138
|
+
f" Use --exclude (and --include) to leave out what the job does not need while it runs, such "
|
|
139
|
+
f"as version-control folders (.git, .svn), environments and installed packages, caches, old "
|
|
140
|
+
f"outputs, and temporary or test data. Look at the job's command in wkube.py and the code it "
|
|
141
|
+
f"runs to work out what it needs.\n"
|
|
142
|
+
f" To see the largest files and folders, run:\n"
|
|
143
|
+
f" accli size \"{directory}\"\n"
|
|
144
|
+
f" Run it again with the --exclude/--include you plan to use to check what the upload will contain.\n"
|
|
145
|
+
f" 2. In wkube.py, set include/exclude so the job folder upload contains only the files the "
|
|
146
|
+
f"image build needs, for example:\n"
|
|
147
|
+
f" exclude=\"*\",\n"
|
|
148
|
+
f" include=\"<build files>\",\n"
|
|
149
|
+
f" To check it, run accli size with the same patterns: "
|
|
150
|
+
f"accli size \"{directory}\" --exclude \"*\" --include \"<build files>\"\n"
|
|
151
|
+
f" 3. In wkube.py, run the job from the uploaded copy:\n"
|
|
152
|
+
f" command=\"cd /mnt/wdrv/{code_path} && <your current command>\"\n"
|
|
153
|
+
f" acc://{project_slug}/{code_path} is available in the job at /mnt/wdrv/{code_path}.\n"
|
|
154
|
+
f" 4. Run 'accli dispatch' again.\n"
|
|
155
|
+
f"\n"
|
|
156
|
+
f"include/exclude work the same in wkube.py and accli copy: comma-separated wildcard patterns, "
|
|
157
|
+
f"matched against file and folder names and their paths inside the folder. A matching folder "
|
|
158
|
+
f"covers everything in it. include wins over exclude. With only include, nothing else is "
|
|
159
|
+
f"uploaded."
|
|
188
160
|
)
|
|
189
161
|
|
|
190
162
|
|
|
@@ -207,6 +179,11 @@ def push_folder_job(directory, include=None, exclude=None):
|
|
|
207
179
|
os.remove(f'{repo_dir}/wkube.py')
|
|
208
180
|
|
|
209
181
|
try:
|
|
182
|
+
uploaded = [(rel, os.path.getsize(path)) for path, rel in iter_selected_files(repo_dir)]
|
|
183
|
+
confirm_version_control(
|
|
184
|
+
uploaded, UPLOAD_VERSION_CONTROL,
|
|
185
|
+
'add them to exclude in wkube.py, for example exclude=".git"', _format_bytes,
|
|
186
|
+
)
|
|
210
187
|
check_job_folder_size(repo_dir, directory, project_slug)
|
|
211
188
|
except ValueError:
|
|
212
189
|
shutil.rmtree(repo_dir, ignore_errors=True)
|