nufi-python 1.1.1__tar.gz → 1.1.2.post1__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.
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/PKG-INFO +80 -20
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/README.md +79 -19
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/pyproject.toml +1 -1
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/__init__.py +8 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/auth.py +6 -6
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/auth.py +13 -7
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/common.py +12 -5
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/compiles.py +29 -57
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/custom_evaluation_templates.py +17 -9
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/datasets.py +144 -28
- nufi_python-1.1.2.post1/src/nufi/cli/commands/doctor.py +415 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/evaluations.py +92 -32
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/leaderboards.py +39 -17
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/models.py +49 -46
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/monitoring.py +9 -3
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/profile.py +13 -9
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/projects.py +35 -19
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/servings.py +142 -21
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/main.py +2 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/client.py +1 -1
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/config.py +10 -8
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/evaluator.py +151 -31
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/exceptions.py +1 -1
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/__init__.py +12 -1
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/compiles.py +28 -1
- nufi_python-1.1.2.post1/src/nufi/models/custom_evaluation_templates.py +324 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/datasets.py +18 -1
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/evaluations.py +82 -5
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/leaderboards.py +3 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/registry.py +3 -3
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/servings.py +29 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/compiles.py +10 -24
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/datasets.py +62 -5
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/evaluations.py +19 -14
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/leaderboards.py +9 -6
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/models.py +9 -9
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/projects.py +2 -2
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/servings.py +55 -10
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/PKG-INFO +80 -20
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/SOURCES.txt +1 -0
- nufi_python-1.1.1/src/nufi/models/custom_evaluation_templates.py +0 -111
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/LICENSE +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/setup.cfg +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/__init__.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/cli/commands/__init__.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/http_utils.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/monitoring.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/pagination.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/models/projects.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/py.typed +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/__init__.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/base.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/custom_evaluation_templates.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/resources/monitoring.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi/transport.py +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/dependency_links.txt +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/entry_points.txt +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/requires.txt +0 -0
- {nufi_python-1.1.1 → nufi_python-1.1.2.post1}/src/nufi_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nufi-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2.post1
|
|
4
4
|
Summary: Python SDK and CLI for the NuFi platform.
|
|
5
5
|
Author: Dudaji Inc.
|
|
6
6
|
License-Expression: MIT
|
|
@@ -42,8 +42,8 @@ python -m pip install "nufi-python[evaluator]"
|
|
|
42
42
|
|
|
43
43
|
## Configure access
|
|
44
44
|
|
|
45
|
-
Ask your NuFi
|
|
46
|
-
access. Create a
|
|
45
|
+
Ask your NuFi Administrator for the installation's base domain and a Project you can
|
|
46
|
+
access. Create a CLI Profile, log in, and select the project once:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
nufi profile create production --base-domain nufi.example
|
|
@@ -114,19 +114,77 @@ with NuFi.from_profile() as client:
|
|
|
114
114
|
entries = client.leaderboards.entries(leaderboard.id)
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
##
|
|
117
|
+
## Model Evaluation
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
without a client-side allowlist.
|
|
119
|
+
Dataset import and Dataset Profiling complete independently. Wait for the Dataset
|
|
120
|
+
Profile before previewing or creating an Evaluation Method:
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
```bash
|
|
123
|
+
nufi dataset version create mmlu mmlu-aa-test --source huggingface \
|
|
124
|
+
--repository cais/mmlu --subset abstract_algebra --split test --wait
|
|
125
|
+
nufi dataset version profile mmlu mmlu-aa-test --wait --output json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The SDK uses the import result's `dataset_version_id` for the same workflow. A failed
|
|
129
|
+
Dataset Profile is returned as a terminal object so the caller can report its server
|
|
130
|
+
error without sending an Evaluation Method request:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from nufi import NuFi
|
|
134
|
+
|
|
135
|
+
client = NuFi.from_profile()
|
|
136
|
+
dataset_id = "DATASET_ID"
|
|
137
|
+
imported = client.datasets.versions.create_from_huggingface(
|
|
138
|
+
dataset_id,
|
|
139
|
+
"mmlu-aa-test",
|
|
140
|
+
repository="cais/mmlu",
|
|
141
|
+
subset="abstract_algebra",
|
|
142
|
+
split="test",
|
|
143
|
+
wait=True,
|
|
144
|
+
)
|
|
145
|
+
if not imported.dataset_version_id:
|
|
146
|
+
raise RuntimeError("Dataset import completed without a Dataset Version")
|
|
147
|
+
|
|
148
|
+
version_id = imported.dataset_version_id
|
|
149
|
+
profile = client.datasets.versions.wait_for_profile(dataset_id, version_id)
|
|
150
|
+
if profile.status != "ready":
|
|
151
|
+
raise RuntimeError(profile.error or "Dataset Profiling failed")
|
|
152
|
+
|
|
153
|
+
config = {
|
|
154
|
+
"schemaVersion": "nufi.evaluation.method.v2",
|
|
155
|
+
"runnerType": "lm_eval",
|
|
156
|
+
"template": "multiple_choice",
|
|
157
|
+
"datasetMapping": {
|
|
158
|
+
"input": "question",
|
|
159
|
+
"choices": "choices",
|
|
160
|
+
"reference": "answer",
|
|
161
|
+
},
|
|
162
|
+
"nativeConfig": {
|
|
163
|
+
"output_type": "multiple_choice",
|
|
164
|
+
"doc_to_text": "{{input}}",
|
|
165
|
+
"metric_list": [{"metric": "acc"}],
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
preview = client.evaluations.methods.preview(
|
|
169
|
+
dataset_id, version_id, config=config
|
|
170
|
+
)
|
|
171
|
+
method = client.evaluations.methods.create(
|
|
172
|
+
dataset_id, version_id, "mmlu-aa", config=config
|
|
173
|
+
)
|
|
174
|
+
client.close()
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Evaluation Method metadata is unconditional and v2-only. Evaluation Method config is
|
|
178
|
+
owned and validated by the API; the SDK forwards the mapping and any caller-supplied
|
|
179
|
+
Evaluation Method type without a client-side allowlist.
|
|
180
|
+
|
|
181
|
+
The `nufi.evaluator.run` helper exits non-zero when an Evaluation Run or result
|
|
182
|
+
submission fails. NuFi determines Evaluation Run success from Kubernetes Job success
|
|
183
|
+
and durable API acceptance; evaluator output is diagnostic only.
|
|
126
184
|
|
|
127
185
|
`evaluation method templates` currently exposes lm-eval templates, metrics, and
|
|
128
|
-
filters. It is an optional discovery command and is not needed when you already have
|
|
129
|
-
Method
|
|
186
|
+
filters. It is an optional discovery command and is not needed when you already have an
|
|
187
|
+
Evaluation Method configuration.
|
|
130
188
|
|
|
131
189
|
```python
|
|
132
190
|
from nufi import NuFi
|
|
@@ -166,8 +224,9 @@ client.evaluations.cancel(run.id, project=project)
|
|
|
166
224
|
client.close()
|
|
167
225
|
```
|
|
168
226
|
|
|
169
|
-
The CLI accepts Dataset, Dataset Version, and Evaluation Method names or UUIDs.
|
|
170
|
-
arguments remain UUIDs because Runs have no name. Select a
|
|
227
|
+
The CLI accepts Dataset, Dataset Version, and Evaluation Method names or UUIDs.
|
|
228
|
+
Evaluation Run arguments remain UUIDs because Evaluation Runs have no name. Select a
|
|
229
|
+
Model Artifact with
|
|
171
230
|
`--model`, `--model-version`, and `--artifact`; `--model-artifact-id` remains available
|
|
172
231
|
for automation. Config, default-runtime, and runner-config files may be JSON or YAML
|
|
173
232
|
and must have a mapping at the document root.
|
|
@@ -205,10 +264,11 @@ nufi evaluation run get RUN_ID --project team-a
|
|
|
205
264
|
nufi evaluation run cancel RUN_ID --yes --project team-a
|
|
206
265
|
```
|
|
207
266
|
|
|
208
|
-
Run creation defaults to `--cpu 4`, `--memory 8Gi`, and
|
|
209
|
-
pass any option to override its default.
|
|
267
|
+
Evaluation Run creation defaults to `--cpu 4`, `--memory 8Gi`, and
|
|
268
|
+
`--accelerator-count 1`; pass any option to override its default.
|
|
210
269
|
|
|
211
|
-
Run detail table output shows aggregate and diagnostic summaries only. Use
|
|
212
|
-
`--output json` to include the authorized bounded diagnostic input, output,
|
|
213
|
-
score, and error fields returned by the API. Additive response fields are
|
|
214
|
-
legacy Method/Run responses missing required v2
|
|
270
|
+
Evaluation Run detail table output shows aggregate and diagnostic summaries only. Use
|
|
271
|
+
explicit `--output json` to include the authorized bounded diagnostic input, output,
|
|
272
|
+
reference, score, and error fields returned by the API. Additive response fields are
|
|
273
|
+
preserved; legacy Evaluation Method/Evaluation Run responses missing required v2
|
|
274
|
+
fields are rejected.
|
|
@@ -20,8 +20,8 @@ python -m pip install "nufi-python[evaluator]"
|
|
|
20
20
|
|
|
21
21
|
## Configure access
|
|
22
22
|
|
|
23
|
-
Ask your NuFi
|
|
24
|
-
access. Create a
|
|
23
|
+
Ask your NuFi Administrator for the installation's base domain and a Project you can
|
|
24
|
+
access. Create a CLI Profile, log in, and select the project once:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
nufi profile create production --base-domain nufi.example
|
|
@@ -92,19 +92,77 @@ with NuFi.from_profile() as client:
|
|
|
92
92
|
entries = client.leaderboards.entries(leaderboard.id)
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
##
|
|
95
|
+
## Model Evaluation
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
without a client-side allowlist.
|
|
97
|
+
Dataset import and Dataset Profiling complete independently. Wait for the Dataset
|
|
98
|
+
Profile before previewing or creating an Evaluation Method:
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
```bash
|
|
101
|
+
nufi dataset version create mmlu mmlu-aa-test --source huggingface \
|
|
102
|
+
--repository cais/mmlu --subset abstract_algebra --split test --wait
|
|
103
|
+
nufi dataset version profile mmlu mmlu-aa-test --wait --output json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The SDK uses the import result's `dataset_version_id` for the same workflow. A failed
|
|
107
|
+
Dataset Profile is returned as a terminal object so the caller can report its server
|
|
108
|
+
error without sending an Evaluation Method request:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from nufi import NuFi
|
|
112
|
+
|
|
113
|
+
client = NuFi.from_profile()
|
|
114
|
+
dataset_id = "DATASET_ID"
|
|
115
|
+
imported = client.datasets.versions.create_from_huggingface(
|
|
116
|
+
dataset_id,
|
|
117
|
+
"mmlu-aa-test",
|
|
118
|
+
repository="cais/mmlu",
|
|
119
|
+
subset="abstract_algebra",
|
|
120
|
+
split="test",
|
|
121
|
+
wait=True,
|
|
122
|
+
)
|
|
123
|
+
if not imported.dataset_version_id:
|
|
124
|
+
raise RuntimeError("Dataset import completed without a Dataset Version")
|
|
125
|
+
|
|
126
|
+
version_id = imported.dataset_version_id
|
|
127
|
+
profile = client.datasets.versions.wait_for_profile(dataset_id, version_id)
|
|
128
|
+
if profile.status != "ready":
|
|
129
|
+
raise RuntimeError(profile.error or "Dataset Profiling failed")
|
|
130
|
+
|
|
131
|
+
config = {
|
|
132
|
+
"schemaVersion": "nufi.evaluation.method.v2",
|
|
133
|
+
"runnerType": "lm_eval",
|
|
134
|
+
"template": "multiple_choice",
|
|
135
|
+
"datasetMapping": {
|
|
136
|
+
"input": "question",
|
|
137
|
+
"choices": "choices",
|
|
138
|
+
"reference": "answer",
|
|
139
|
+
},
|
|
140
|
+
"nativeConfig": {
|
|
141
|
+
"output_type": "multiple_choice",
|
|
142
|
+
"doc_to_text": "{{input}}",
|
|
143
|
+
"metric_list": [{"metric": "acc"}],
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
preview = client.evaluations.methods.preview(
|
|
147
|
+
dataset_id, version_id, config=config
|
|
148
|
+
)
|
|
149
|
+
method = client.evaluations.methods.create(
|
|
150
|
+
dataset_id, version_id, "mmlu-aa", config=config
|
|
151
|
+
)
|
|
152
|
+
client.close()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Evaluation Method metadata is unconditional and v2-only. Evaluation Method config is
|
|
156
|
+
owned and validated by the API; the SDK forwards the mapping and any caller-supplied
|
|
157
|
+
Evaluation Method type without a client-side allowlist.
|
|
158
|
+
|
|
159
|
+
The `nufi.evaluator.run` helper exits non-zero when an Evaluation Run or result
|
|
160
|
+
submission fails. NuFi determines Evaluation Run success from Kubernetes Job success
|
|
161
|
+
and durable API acceptance; evaluator output is diagnostic only.
|
|
104
162
|
|
|
105
163
|
`evaluation method templates` currently exposes lm-eval templates, metrics, and
|
|
106
|
-
filters. It is an optional discovery command and is not needed when you already have
|
|
107
|
-
Method
|
|
164
|
+
filters. It is an optional discovery command and is not needed when you already have an
|
|
165
|
+
Evaluation Method configuration.
|
|
108
166
|
|
|
109
167
|
```python
|
|
110
168
|
from nufi import NuFi
|
|
@@ -144,8 +202,9 @@ client.evaluations.cancel(run.id, project=project)
|
|
|
144
202
|
client.close()
|
|
145
203
|
```
|
|
146
204
|
|
|
147
|
-
The CLI accepts Dataset, Dataset Version, and Evaluation Method names or UUIDs.
|
|
148
|
-
arguments remain UUIDs because Runs have no name. Select a
|
|
205
|
+
The CLI accepts Dataset, Dataset Version, and Evaluation Method names or UUIDs.
|
|
206
|
+
Evaluation Run arguments remain UUIDs because Evaluation Runs have no name. Select a
|
|
207
|
+
Model Artifact with
|
|
149
208
|
`--model`, `--model-version`, and `--artifact`; `--model-artifact-id` remains available
|
|
150
209
|
for automation. Config, default-runtime, and runner-config files may be JSON or YAML
|
|
151
210
|
and must have a mapping at the document root.
|
|
@@ -183,10 +242,11 @@ nufi evaluation run get RUN_ID --project team-a
|
|
|
183
242
|
nufi evaluation run cancel RUN_ID --yes --project team-a
|
|
184
243
|
```
|
|
185
244
|
|
|
186
|
-
Run creation defaults to `--cpu 4`, `--memory 8Gi`, and
|
|
187
|
-
pass any option to override its default.
|
|
245
|
+
Evaluation Run creation defaults to `--cpu 4`, `--memory 8Gi`, and
|
|
246
|
+
`--accelerator-count 1`; pass any option to override its default.
|
|
188
247
|
|
|
189
|
-
Run detail table output shows aggregate and diagnostic summaries only. Use
|
|
190
|
-
`--output json` to include the authorized bounded diagnostic input, output,
|
|
191
|
-
score, and error fields returned by the API. Additive response fields are
|
|
192
|
-
legacy Method/Run responses missing required v2
|
|
248
|
+
Evaluation Run detail table output shows aggregate and diagnostic summaries only. Use
|
|
249
|
+
explicit `--output json` to include the authorized bounded diagnostic input, output,
|
|
250
|
+
reference, score, and error fields returned by the API. Additive response fields are
|
|
251
|
+
preserved; legacy Evaluation Method/Evaluation Run responses missing required v2
|
|
252
|
+
fields are rejected.
|
|
@@ -4,9 +4,12 @@ from nufi.client import NuFi
|
|
|
4
4
|
from nufi.models import (
|
|
5
5
|
ArtifactValidation,
|
|
6
6
|
CompileRun,
|
|
7
|
+
CompileRunSummary,
|
|
8
|
+
DatasetVersionProfile,
|
|
7
9
|
EvaluationMethod,
|
|
8
10
|
EvaluationMethodTemplates,
|
|
9
11
|
EvaluationRun,
|
|
12
|
+
EvaluationRunSummary,
|
|
10
13
|
HuggingFaceMapping,
|
|
11
14
|
Leaderboard,
|
|
12
15
|
LeaderboardEntry,
|
|
@@ -22,6 +25,7 @@ from nufi.models import (
|
|
|
22
25
|
ProjectAccessTokenCreateResponse,
|
|
23
26
|
RegisteredModel,
|
|
24
27
|
Serving,
|
|
28
|
+
ServingSummary,
|
|
25
29
|
)
|
|
26
30
|
|
|
27
31
|
__version__ = version("nufi-python")
|
|
@@ -30,9 +34,12 @@ __all__ = [
|
|
|
30
34
|
"__version__",
|
|
31
35
|
"ArtifactValidation",
|
|
32
36
|
"CompileRun",
|
|
37
|
+
"CompileRunSummary",
|
|
38
|
+
"DatasetVersionProfile",
|
|
33
39
|
"EvaluationMethod",
|
|
34
40
|
"EvaluationMethodTemplates",
|
|
35
41
|
"EvaluationRun",
|
|
42
|
+
"EvaluationRunSummary",
|
|
36
43
|
"HuggingFaceMapping",
|
|
37
44
|
"Leaderboard",
|
|
38
45
|
"LeaderboardEntry",
|
|
@@ -49,4 +56,5 @@ __all__ = [
|
|
|
49
56
|
"ProjectAccessTokenCreateResponse",
|
|
50
57
|
"RegisteredModel",
|
|
51
58
|
"Serving",
|
|
59
|
+
"ServingSummary",
|
|
52
60
|
]
|
|
@@ -42,12 +42,12 @@ class TokenStore:
|
|
|
42
42
|
def path_for(self, profile_name: str) -> Path:
|
|
43
43
|
if not is_valid_profile_name(profile_name):
|
|
44
44
|
raise AuthenticationError(
|
|
45
|
-
"Invalid
|
|
45
|
+
"Invalid CLI Profile name. Use letters, numbers, dot, underscore, or dash."
|
|
46
46
|
)
|
|
47
47
|
path = (self.token_dir / f"{profile_name}.json").resolve()
|
|
48
48
|
token_dir = self.token_dir.resolve()
|
|
49
49
|
if not path.is_relative_to(token_dir):
|
|
50
|
-
raise AuthenticationError("Invalid
|
|
50
|
+
raise AuthenticationError("Invalid CLI Profile name.")
|
|
51
51
|
return path
|
|
52
52
|
|
|
53
53
|
def save(
|
|
@@ -79,13 +79,13 @@ class TokenStore:
|
|
|
79
79
|
path = self.path_for(profile_name)
|
|
80
80
|
if not path.exists():
|
|
81
81
|
raise AuthenticationError(
|
|
82
|
-
f"No token found for
|
|
82
|
+
f"No token found for CLI Profile '{profile_name}'. Run 'nufi login'."
|
|
83
83
|
)
|
|
84
84
|
try:
|
|
85
85
|
return json.loads(path.read_text())
|
|
86
86
|
except json.JSONDecodeError as exc:
|
|
87
87
|
raise AuthenticationError(
|
|
88
|
-
f"Token file for
|
|
88
|
+
f"Token file for CLI Profile '{profile_name}' is invalid."
|
|
89
89
|
) from exc
|
|
90
90
|
|
|
91
91
|
def delete(self, profile_name: str) -> None:
|
|
@@ -111,7 +111,7 @@ def _request_error_message(
|
|
|
111
111
|
hint = ""
|
|
112
112
|
if host:
|
|
113
113
|
hint = (
|
|
114
|
-
f" Check DNS or /etc/hosts for '{host}', or recreate the
|
|
114
|
+
f" Check DNS or /etc/hosts for '{host}', or recreate the CLI Profile with "
|
|
115
115
|
"`nufi profile create <name> --keycloak-issuer <url>`."
|
|
116
116
|
)
|
|
117
117
|
return f"{context}: could not reach Keycloak issuer {issuer}.{hint} Original error: {exc}"
|
|
@@ -235,7 +235,7 @@ def refresh_access_token(
|
|
|
235
235
|
token_store: TokenStore | None = None,
|
|
236
236
|
now: int | Callable[[], int] | None = None,
|
|
237
237
|
) -> str:
|
|
238
|
-
"""Refresh a
|
|
238
|
+
"""Refresh a CLI Profile access token after the API rejects it."""
|
|
239
239
|
token_store = token_store or TokenStore()
|
|
240
240
|
tokens = token_store.load(profile_name)
|
|
241
241
|
refresh_token = tokens.get("refresh_token")
|
|
@@ -17,7 +17,9 @@ def _resolve(profile_name: str | None) -> tuple[str, config.Profile]:
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def login(
|
|
20
|
-
profile_name: str | None = typer.Option(
|
|
20
|
+
profile_name: str | None = typer.Option(
|
|
21
|
+
None, "--profile", help="CLI Profile name."
|
|
22
|
+
),
|
|
21
23
|
open_browser: bool = typer.Option(
|
|
22
24
|
True,
|
|
23
25
|
"--browser/--no-browser",
|
|
@@ -49,7 +51,9 @@ def login(
|
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
def logout(
|
|
52
|
-
profile_name: str | None = typer.Option(
|
|
54
|
+
profile_name: str | None = typer.Option(
|
|
55
|
+
None, "--profile", help="CLI Profile name."
|
|
56
|
+
),
|
|
53
57
|
):
|
|
54
58
|
try:
|
|
55
59
|
resolved_name, _ = _resolve(profile_name)
|
|
@@ -61,7 +65,9 @@ def logout(
|
|
|
61
65
|
|
|
62
66
|
|
|
63
67
|
def whoami(
|
|
64
|
-
profile_name: str | None = typer.Option(
|
|
68
|
+
profile_name: str | None = typer.Option(
|
|
69
|
+
None, "--profile", help="CLI Profile name."
|
|
70
|
+
),
|
|
65
71
|
):
|
|
66
72
|
try:
|
|
67
73
|
resolved_name, _ = _resolve(profile_name)
|
|
@@ -88,10 +94,10 @@ def whoami(
|
|
|
88
94
|
or str(UUID(token_id)) != token_id
|
|
89
95
|
):
|
|
90
96
|
raise AuthenticationError(
|
|
91
|
-
"NUFI_TOKEN is not a NuFi
|
|
97
|
+
"NUFI_TOKEN is not a NuFi Project Access Token."
|
|
92
98
|
)
|
|
93
99
|
project = projects[0]
|
|
94
|
-
console.print("Authentication:
|
|
100
|
+
console.print("Authentication: Project Access Token")
|
|
95
101
|
console.print(f"Token ID: {token_id}")
|
|
96
102
|
console.print(f"Project: {project.name} ({project.id})")
|
|
97
103
|
return
|
|
@@ -100,7 +106,7 @@ def whoami(
|
|
|
100
106
|
raise typer.Exit(code=1) from exc
|
|
101
107
|
except ValueError as exc:
|
|
102
108
|
console.print(
|
|
103
|
-
"[bold red]Error:[/] NUFI_TOKEN is not a NuFi
|
|
109
|
+
"[bold red]Error:[/] NUFI_TOKEN is not a NuFi Project Access Token."
|
|
104
110
|
)
|
|
105
111
|
raise typer.Exit(code=1) from exc
|
|
106
112
|
except Exception as exc:
|
|
@@ -108,6 +114,6 @@ def whoami(
|
|
|
108
114
|
|
|
109
115
|
username = claims.get("preferred_username") or claims.get("sub") or "-"
|
|
110
116
|
email = claims.get("email") or "-"
|
|
111
|
-
console.print(f"Profile: {resolved_name}")
|
|
117
|
+
console.print(f"CLI Profile: {resolved_name}")
|
|
112
118
|
console.print(f"Username: {username}")
|
|
113
119
|
console.print(f"Email: {email}")
|
|
@@ -165,18 +165,25 @@ def resolve_named_resource(
|
|
|
165
165
|
raise ValidationError(
|
|
166
166
|
f"Multiple {resource}s named '{target}'; matching IDs: {ids}{suffix}."
|
|
167
167
|
)
|
|
168
|
-
raise NotFoundError(f"{resource
|
|
168
|
+
raise NotFoundError(f"{resource} not found: {target}")
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
def
|
|
172
|
-
*,
|
|
171
|
+
def confirm_action(
|
|
172
|
+
*,
|
|
173
|
+
resource: str,
|
|
174
|
+
target: str,
|
|
175
|
+
profile_name: str | None,
|
|
176
|
+
yes: bool,
|
|
177
|
+
action: str = "Delete",
|
|
173
178
|
) -> None:
|
|
174
179
|
if yes:
|
|
175
180
|
return
|
|
176
181
|
|
|
177
|
-
profile_label =
|
|
182
|
+
profile_label = (
|
|
183
|
+
f"CLI Profile '{profile_name}'" if profile_name else "active CLI Profile"
|
|
184
|
+
)
|
|
178
185
|
if typer.confirm(
|
|
179
|
-
f"
|
|
186
|
+
f"{action} {resource} '{target}' from {profile_label}?",
|
|
180
187
|
default=False,
|
|
181
188
|
):
|
|
182
189
|
return
|
|
@@ -5,7 +5,7 @@ import typer
|
|
|
5
5
|
from nufi.cli.commands import common
|
|
6
6
|
|
|
7
7
|
app = typer.Typer(
|
|
8
|
-
help="Manage NuFi
|
|
8
|
+
help="Manage NuFi Compile Runs.",
|
|
9
9
|
invoke_without_command=True,
|
|
10
10
|
context_settings=common.CONTEXT_SETTINGS,
|
|
11
11
|
)
|
|
@@ -76,7 +76,7 @@ def list_compiles(
|
|
|
76
76
|
version: str | None = typer.Option(
|
|
77
77
|
None,
|
|
78
78
|
"--version",
|
|
79
|
-
help="Model
|
|
79
|
+
help="Model Version.",
|
|
80
80
|
show_default=False,
|
|
81
81
|
),
|
|
82
82
|
phase: list[str] | None = typer.Option(
|
|
@@ -97,10 +97,12 @@ def list_compiles(
|
|
|
97
97
|
"--limit",
|
|
98
98
|
min=1,
|
|
99
99
|
max=100,
|
|
100
|
-
help="Runs per page.",
|
|
100
|
+
help="Compile Runs per page.",
|
|
101
101
|
show_default=False,
|
|
102
102
|
),
|
|
103
|
-
profile_name: str | None = typer.Option(
|
|
103
|
+
profile_name: str | None = typer.Option(
|
|
104
|
+
None, "--profile", help="CLI Profile name."
|
|
105
|
+
),
|
|
104
106
|
output: common.OutputChoice = typer.Option(
|
|
105
107
|
common.OutputChoice.table,
|
|
106
108
|
"--output",
|
|
@@ -178,7 +180,7 @@ def create_compile(
|
|
|
178
180
|
help="Project ID.",
|
|
179
181
|
show_default=False,
|
|
180
182
|
),
|
|
181
|
-
version: str = typer.Option(..., "--version", "-v", help="Model
|
|
183
|
+
version: str = typer.Option(..., "--version", "-v", help="Model Version."),
|
|
182
184
|
tensor_parallel_size: int | None = typer.Option(
|
|
183
185
|
None,
|
|
184
186
|
"--tensor-parallel-size",
|
|
@@ -240,7 +242,9 @@ def create_compile(
|
|
|
240
242
|
interval: float = typer.Option(
|
|
241
243
|
5, "--interval", min=0.001, help="Polling interval in seconds."
|
|
242
244
|
),
|
|
243
|
-
profile_name: str | None = typer.Option(
|
|
245
|
+
profile_name: str | None = typer.Option(
|
|
246
|
+
None, "--profile", help="CLI Profile name."
|
|
247
|
+
),
|
|
244
248
|
output: common.OutputChoice = typer.Option(
|
|
245
249
|
common.OutputChoice.table,
|
|
246
250
|
"--output",
|
|
@@ -272,7 +276,7 @@ def create_compile(
|
|
|
272
276
|
)
|
|
273
277
|
if wait:
|
|
274
278
|
typer.echo(
|
|
275
|
-
f"Compile created: {run.cr_name} (ID: {run.id}); resume with "
|
|
279
|
+
f"Compile Run created: {run.cr_name} (ID: {run.id}); resume with "
|
|
276
280
|
f"'nufi compile wait {run.cr_name}'",
|
|
277
281
|
err=True,
|
|
278
282
|
)
|
|
@@ -292,7 +296,7 @@ def create_compile(
|
|
|
292
296
|
_print_run(run, output)
|
|
293
297
|
else:
|
|
294
298
|
common.console.print(
|
|
295
|
-
f"[bold green]Compile created:[/] {run.cr_name} (ID: {run.id})"
|
|
299
|
+
f"[bold green]Compile Run created:[/] {run.cr_name} (ID: {run.id})"
|
|
296
300
|
)
|
|
297
301
|
if run.phase == "Failed" or run.registration_error:
|
|
298
302
|
raise typer.Exit(code=1)
|
|
@@ -300,12 +304,12 @@ def create_compile(
|
|
|
300
304
|
|
|
301
305
|
@app.command("get")
|
|
302
306
|
def get_compile(
|
|
303
|
-
name: str | None = typer.Argument(None, help="Compile
|
|
307
|
+
name: str | None = typer.Argument(None, help="Compile Run name."),
|
|
304
308
|
run_id: int | None = typer.Option(
|
|
305
309
|
None,
|
|
306
310
|
"--run-id",
|
|
307
311
|
min=1,
|
|
308
|
-
help="Compile
|
|
312
|
+
help="Compile Run ID.",
|
|
309
313
|
show_default=False,
|
|
310
314
|
),
|
|
311
315
|
project: str | None = typer.Option(
|
|
@@ -321,9 +325,11 @@ def get_compile(
|
|
|
321
325
|
help="Project ID.",
|
|
322
326
|
show_default=False,
|
|
323
327
|
),
|
|
324
|
-
profile_name: str | None = typer.Option(
|
|
328
|
+
profile_name: str | None = typer.Option(
|
|
329
|
+
None, "--profile", help="CLI Profile name."
|
|
330
|
+
),
|
|
325
331
|
output: common.OutputChoice = typer.Option(
|
|
326
|
-
common.OutputChoice.
|
|
332
|
+
common.OutputChoice.table,
|
|
327
333
|
"--output",
|
|
328
334
|
help="Output format.",
|
|
329
335
|
),
|
|
@@ -355,7 +361,7 @@ def get_compile(
|
|
|
355
361
|
|
|
356
362
|
@app.command("wait")
|
|
357
363
|
def wait_compile(
|
|
358
|
-
target: str = typer.Argument(..., help="Compile
|
|
364
|
+
target: str = typer.Argument(..., help="Compile Run name or numeric ID."),
|
|
359
365
|
project: str | None = typer.Option(
|
|
360
366
|
None,
|
|
361
367
|
"--project",
|
|
@@ -375,7 +381,9 @@ def wait_compile(
|
|
|
375
381
|
interval: float = typer.Option(
|
|
376
382
|
5, "--interval", min=0.001, help="Polling interval in seconds."
|
|
377
383
|
),
|
|
378
|
-
profile_name: str | None = typer.Option(
|
|
384
|
+
profile_name: str | None = typer.Option(
|
|
385
|
+
None, "--profile", help="CLI Profile name."
|
|
386
|
+
),
|
|
379
387
|
output: common.OutputChoice = typer.Option(
|
|
380
388
|
common.OutputChoice.table,
|
|
381
389
|
"--output",
|
|
@@ -409,47 +417,9 @@ def wait_compile(
|
|
|
409
417
|
raise typer.Exit(code=1)
|
|
410
418
|
|
|
411
419
|
|
|
412
|
-
@app.command("retry")
|
|
413
|
-
def retry_compile(
|
|
414
|
-
name: str = typer.Argument(..., help="Compile CR name."),
|
|
415
|
-
step_name: str = typer.Argument(..., help="Step name."),
|
|
416
|
-
project: str | None = typer.Option(
|
|
417
|
-
None,
|
|
418
|
-
"--project",
|
|
419
|
-
help="Project name.",
|
|
420
|
-
show_default=False,
|
|
421
|
-
),
|
|
422
|
-
project_id: int | None = typer.Option(
|
|
423
|
-
None,
|
|
424
|
-
"--project-id",
|
|
425
|
-
min=1,
|
|
426
|
-
help="Project ID.",
|
|
427
|
-
show_default=False,
|
|
428
|
-
),
|
|
429
|
-
profile_name: str | None = typer.Option(None, "--profile", help="Profile name."),
|
|
430
|
-
verbose: bool = typer.Option(False, "--verbose", help="Show detailed errors."),
|
|
431
|
-
):
|
|
432
|
-
client = None
|
|
433
|
-
try:
|
|
434
|
-
resolved_project = common.resolve_cli_project(
|
|
435
|
-
project,
|
|
436
|
-
project_id,
|
|
437
|
-
profile_name=profile_name,
|
|
438
|
-
)
|
|
439
|
-
client = common.make_client(profile_name)
|
|
440
|
-
client.compiles.retry(name, step_name, project=resolved_project)
|
|
441
|
-
except Exception as exc:
|
|
442
|
-
common.handle_cli_error(exc, verbose=verbose)
|
|
443
|
-
finally:
|
|
444
|
-
if client is not None:
|
|
445
|
-
client.close()
|
|
446
|
-
|
|
447
|
-
common.console.print(f"[bold green]Compile step retried:[/] {name}/{step_name}")
|
|
448
|
-
|
|
449
|
-
|
|
450
420
|
@app.command("delete")
|
|
451
421
|
def delete_compile(
|
|
452
|
-
name: str = typer.Argument(..., help="Compile
|
|
422
|
+
name: str = typer.Argument(..., help="Compile Run name."),
|
|
453
423
|
project: str | None = typer.Option(
|
|
454
424
|
None,
|
|
455
425
|
"--project",
|
|
@@ -463,7 +433,9 @@ def delete_compile(
|
|
|
463
433
|
help="Project ID.",
|
|
464
434
|
show_default=False,
|
|
465
435
|
),
|
|
466
|
-
profile_name: str | None = typer.Option(
|
|
436
|
+
profile_name: str | None = typer.Option(
|
|
437
|
+
None, "--profile", help="CLI Profile name."
|
|
438
|
+
),
|
|
467
439
|
yes: bool = typer.Option(False, "--yes", help="Skip delete confirmation."),
|
|
468
440
|
verbose: bool = typer.Option(False, "--verbose", help="Show detailed errors."),
|
|
469
441
|
):
|
|
@@ -476,8 +448,8 @@ def delete_compile(
|
|
|
476
448
|
except Exception as exc:
|
|
477
449
|
common.handle_cli_error(exc, verbose=verbose)
|
|
478
450
|
|
|
479
|
-
common.
|
|
480
|
-
resource="
|
|
451
|
+
common.confirm_action(
|
|
452
|
+
resource="Compile Run",
|
|
481
453
|
target=f"{resolved_project}/{name}",
|
|
482
454
|
profile_name=profile_name,
|
|
483
455
|
yes=yes,
|
|
@@ -492,7 +464,7 @@ def delete_compile(
|
|
|
492
464
|
if client is not None:
|
|
493
465
|
client.close()
|
|
494
466
|
|
|
495
|
-
common.console.print(f"[bold green]Compile deleted:[/] {name}")
|
|
467
|
+
common.console.print(f"[bold green]Compile Run deleted:[/] {name}")
|
|
496
468
|
|
|
497
469
|
|
|
498
470
|
def _parse_env(entries: list[str] | None) -> list[dict[str, str]] | None:
|