infixspeed-cli 0.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- infix_cli/__init__.py +5 -0
- infix_cli/__main__.py +6 -0
- infix_cli/agent-guide.txt +71 -0
- infix_cli/cli_framework.py +96 -0
- infix_cli/command_contract.py +157 -0
- infix_cli/commands/__init__.py +1 -0
- infix_cli/commands/_artifacts.py +142 -0
- infix_cli/commands/_comparison.py +443 -0
- infix_cli/commands/_confirm.py +26 -0
- infix_cli/commands/_control.py +290 -0
- infix_cli/commands/_create.py +351 -0
- infix_cli/commands/_create_output.py +139 -0
- infix_cli/commands/_delete.py +288 -0
- infix_cli/commands/_download.py +459 -0
- infix_cli/commands/_fusion_common.py +191 -0
- infix_cli/commands/_fusion_config.py +394 -0
- infix_cli/commands/_fusion_feedback.py +319 -0
- infix_cli/commands/_fusion_tasks.py +507 -0
- infix_cli/commands/_fusion_tensorboard.py +132 -0
- infix_cli/commands/_jobs.py +312 -0
- infix_cli/commands/_logs.py +210 -0
- infix_cli/commands/_publish.py +123 -0
- infix_cli/commands/_register.py +600 -0
- infix_cli/commands/_register_output.py +231 -0
- infix_cli/commands/_storage_tree.py +62 -0
- infix_cli/commands/admin.py +668 -0
- infix_cli/commands/asset.py +2012 -0
- infix_cli/commands/auth.py +246 -0
- infix_cli/commands/deploy.py +850 -0
- infix_cli/commands/evaluation.py +360 -0
- infix_cli/commands/examples.py +138 -0
- infix_cli/commands/fusion.py +1842 -0
- infix_cli/commands/merge.py +709 -0
- infix_cli/commands/resource.py +127 -0
- infix_cli/commands/spark.py +347 -0
- infix_cli/commands/storage.py +329 -0
- infix_cli/commands/training.py +748 -0
- infix_cli/config.py +311 -0
- infix_cli/config_input.py +217 -0
- infix_cli/context.py +84 -0
- infix_cli/discovery.py +459 -0
- infix_cli/domain/__init__.py +1 -0
- infix_cli/domain/dto/__init__.py +6 -0
- infix_cli/domain/dto/admin.py +413 -0
- infix_cli/domain/dto/asset.py +390 -0
- infix_cli/domain/dto/common.py +136 -0
- infix_cli/domain/dto/evaluation.py +296 -0
- infix_cli/domain/dto/logs.py +98 -0
- infix_cli/domain/dto/resource.py +108 -0
- infix_cli/domain/dto/serving.py +156 -0
- infix_cli/domain/dto/spark.py +241 -0
- infix_cli/domain/dto/storage.py +75 -0
- infix_cli/domain/dto/training.py +272 -0
- infix_cli/domain/enums.py +359 -0
- infix_cli/domain/hyperparams.py +190 -0
- infix_cli/domain/refs.py +108 -0
- infix_cli/domain/resolve.py +619 -0
- infix_cli/errors.py +158 -0
- infix_cli/example_data/__init__.py +1 -0
- infix_cli/example_data/fusion/README.md +128 -0
- infix_cli/example_data/fusion/fusion.json +149 -0
- infix_cli/example_data/fusion/prompts/code.jsonl +16 -0
- infix_cli/example_data/fusion/prompts/math.jsonl +16 -0
- infix_cli/example_data/fusion.zip +0 -0
- infix_cli/example_data/merge/README.md +89 -0
- infix_cli/example_data/merge/merge.json +26 -0
- infix_cli/example_data/merge.zip +0 -0
- infix_cli/http/__init__.py +1 -0
- infix_cli/http/browser_auth.py +160 -0
- infix_cli/http/client.py +575 -0
- infix_cli/http/pagination.py +84 -0
- infix_cli/http/upload.py +254 -0
- infix_cli/main.py +432 -0
- infix_cli/pipeline_config_schema.py +122 -0
- infix_cli/render/__init__.py +79 -0
- infix_cli/render/json_out.py +123 -0
- infix_cli/render/progress.py +62 -0
- infix_cli/render/text.py +233 -0
- infix_cli/update_check.py +177 -0
- infix_cli/waiter.py +93 -0
- infix_cli/workspace.py +158 -0
- infixspeed_cli-0.0.16.dist-info/METADATA +58 -0
- infixspeed_cli-0.0.16.dist-info/RECORD +85 -0
- infixspeed_cli-0.0.16.dist-info/WHEEL +4 -0
- infixspeed_cli-0.0.16.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
"""固定来源后提交评测对比,并按每个数据集/指标显示差值。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from infix_cli.commands import _confirm
|
|
8
|
+
from infix_cli.commands._fusion_common import (
|
|
9
|
+
comparison_reference,
|
|
10
|
+
output,
|
|
11
|
+
print_table,
|
|
12
|
+
request_key,
|
|
13
|
+
run_number,
|
|
14
|
+
segment,
|
|
15
|
+
)
|
|
16
|
+
from infix_cli.errors import SubmissionUnknown, UsageError
|
|
17
|
+
from infix_cli.waiter import parse_timeout, wait_until_terminal
|
|
18
|
+
|
|
19
|
+
PATH = "/evaluation/comparisons"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def show(run, payload):
|
|
23
|
+
if run.output == "json" or run.quiet:
|
|
24
|
+
output(run, payload)
|
|
25
|
+
return
|
|
26
|
+
from rich.table import Table
|
|
27
|
+
from rich.text import Text
|
|
28
|
+
from infix_cli.render.text import _console
|
|
29
|
+
|
|
30
|
+
console = _console(run)
|
|
31
|
+
console.print("Comparison: " + payload["comparison"], markup=False)
|
|
32
|
+
console.print("Status: " + payload["status"], markup=False)
|
|
33
|
+
for dataset in payload.get("results", []):
|
|
34
|
+
table = Table(show_edge=False)
|
|
35
|
+
for label in (
|
|
36
|
+
"DATASET",
|
|
37
|
+
"METRIC",
|
|
38
|
+
"BASELINE",
|
|
39
|
+
*[row["candidate"] for row in dataset["rows"]],
|
|
40
|
+
):
|
|
41
|
+
table.add_column(Text(label), no_wrap=True)
|
|
42
|
+
for policy in dataset["metric_policies"]:
|
|
43
|
+
metric = policy["name"]
|
|
44
|
+
normalized = policy["normalized"]
|
|
45
|
+
|
|
46
|
+
def value(number):
|
|
47
|
+
if number is None:
|
|
48
|
+
return "—"
|
|
49
|
+
return f"{number * 100:.1f}%" if normalized else f"{number:.5g}"
|
|
50
|
+
|
|
51
|
+
cells = [
|
|
52
|
+
dataset["dataset"],
|
|
53
|
+
metric,
|
|
54
|
+
Text(value(dataset["baseline"]["metrics"].get(metric)), style="grey50"),
|
|
55
|
+
]
|
|
56
|
+
for row in dataset["rows"]:
|
|
57
|
+
result = row["metrics"][metric]
|
|
58
|
+
cell = Text(
|
|
59
|
+
value(result["value"]), style="green" if result["is_best"] else ""
|
|
60
|
+
)
|
|
61
|
+
if result["delta"] is not None:
|
|
62
|
+
delta = result["delta"] * (100 if normalized else 1)
|
|
63
|
+
arrow = {"up": "^", "down": "v", "flat": "-"}[result["trend"]]
|
|
64
|
+
style = {"up": "blue", "down": "red", "flat": "grey50"}[
|
|
65
|
+
result["trend"]
|
|
66
|
+
]
|
|
67
|
+
cell.append(
|
|
68
|
+
f" ({delta:+.1f} {arrow})"
|
|
69
|
+
if normalized
|
|
70
|
+
else f" ({delta:+.5g} {arrow})",
|
|
71
|
+
style=style,
|
|
72
|
+
)
|
|
73
|
+
if result["is_best"]:
|
|
74
|
+
cell.append("*", style="green")
|
|
75
|
+
cells.append(cell)
|
|
76
|
+
table.add_row(*cells)
|
|
77
|
+
print_table(run, table)
|
|
78
|
+
for row in [dataset["baseline"], *dataset["rows"]]:
|
|
79
|
+
if row.get("error_message"):
|
|
80
|
+
console.print(str(row["error_message"]), markup=False)
|
|
81
|
+
if row["status"] in {
|
|
82
|
+
"failed",
|
|
83
|
+
"stopped",
|
|
84
|
+
"canceled",
|
|
85
|
+
"collection_failed",
|
|
86
|
+
} and row.get("job_name"):
|
|
87
|
+
console.print(
|
|
88
|
+
"Retry: infix evaluation restart " + row["job_name"], markup=False
|
|
89
|
+
)
|
|
90
|
+
console.print(
|
|
91
|
+
"* marks the best candidates per dataset/metric; normalized differences use percentage points.",
|
|
92
|
+
markup=False,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def compare(
|
|
97
|
+
ctx: typer.Context,
|
|
98
|
+
baseline: str = typer.Option(
|
|
99
|
+
..., "--baseline",
|
|
100
|
+
help=(
|
|
101
|
+
'Required baseline model reference: official/NAME, workspace/NAME:VERSION or '
|
|
102
|
+
'storage/PATH.'
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
candidate: list[str] = typer.Option(
|
|
106
|
+
None, "--candidate",
|
|
107
|
+
help=(
|
|
108
|
+
'Candidate model reference; repeat. Can be combined with Merge and Fusion '
|
|
109
|
+
'candidate sources.'
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
candidate_from_merge: list[str] = typer.Option(
|
|
113
|
+
None, "--candidate-from-merge",
|
|
114
|
+
help=(
|
|
115
|
+
'Successful Merge task name or ID; repeat to compare several Merge outputs.'
|
|
116
|
+
),
|
|
117
|
+
),
|
|
118
|
+
candidate_from_fusion: str | None = typer.Option(
|
|
119
|
+
None, "--candidate-from-fusion",
|
|
120
|
+
help=(
|
|
121
|
+
'Fusion task name or ID; selects complete OPD checkpoints, default: latest 3.'
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
dataset: list[str] = typer.Option(
|
|
125
|
+
..., "--dataset",
|
|
126
|
+
help=(
|
|
127
|
+
'Registered dataset reference, official/NAME or workspace/NAME:VERSION; repeat. '
|
|
128
|
+
'Every model uses the same fixed versions.'
|
|
129
|
+
),
|
|
130
|
+
),
|
|
131
|
+
eval_type: str = typer.Option(
|
|
132
|
+
..., "--eval-type",
|
|
133
|
+
help=(
|
|
134
|
+
'Required evaluation type: official or custom. custom requires --custom-format.'
|
|
135
|
+
),
|
|
136
|
+
),
|
|
137
|
+
name: str | None = typer.Option(
|
|
138
|
+
None, "--name", "-n",
|
|
139
|
+
help=(
|
|
140
|
+
'New comparison name, unique within this workspace; default: automatically '
|
|
141
|
+
'generated cmp-ID.'
|
|
142
|
+
),
|
|
143
|
+
),
|
|
144
|
+
run: str | None = typer.Option(
|
|
145
|
+
None, "--run",
|
|
146
|
+
help=(
|
|
147
|
+
'Historical logical execution number, e.g. 2 or run-2; default: current '
|
|
148
|
+
'execution. This is not a stage attempt.'
|
|
149
|
+
),
|
|
150
|
+
),
|
|
151
|
+
last: int | None = typer.Option(
|
|
152
|
+
None, "--last",
|
|
153
|
+
min=1,
|
|
154
|
+
max=10,
|
|
155
|
+
help=(
|
|
156
|
+
'Latest N complete Fusion checkpoints, 1-10; default: 3. Cannot combine with '
|
|
157
|
+
'--checkpoint or --all-checkpoints.'
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
checkpoint: list[str] = typer.Option(
|
|
161
|
+
None, "--checkpoint",
|
|
162
|
+
help=(
|
|
163
|
+
'One complete Fusion checkpoint name; repeat for explicit selection. Cannot '
|
|
164
|
+
'combine with --last or --all-checkpoints.'
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
all_checkpoints: bool = typer.Option(
|
|
168
|
+
False, "--all-checkpoints",
|
|
169
|
+
help=(
|
|
170
|
+
'Evaluate all currently complete Fusion checkpoints; preview and confirm job '
|
|
171
|
+
'count first. Cannot combine with --last or --checkpoint.'
|
|
172
|
+
),
|
|
173
|
+
),
|
|
174
|
+
yes: bool = typer.Option(False, "--yes", help='Skip the --all-checkpoints job-count confirmation for scripts.'),
|
|
175
|
+
custom_format: str | None = typer.Option(
|
|
176
|
+
None, "--custom-format",
|
|
177
|
+
help=(
|
|
178
|
+
'Required for custom evaluation: single-choice or question-answering; omit for '
|
|
179
|
+
'official.'
|
|
180
|
+
),
|
|
181
|
+
),
|
|
182
|
+
max_parallel: int = typer.Option(
|
|
183
|
+
4, "--max-parallel",
|
|
184
|
+
min=1,
|
|
185
|
+
max=64,
|
|
186
|
+
help=(
|
|
187
|
+
'Maximum simultaneous evaluations, 1-64; default: 4. Slots are reused after '
|
|
188
|
+
'actual resources are released.'
|
|
189
|
+
),
|
|
190
|
+
),
|
|
191
|
+
gpu_count: int = typer.Option(2, "--gpu-count", help='Inference GPUs per evaluation: 1, 2 or 4; default: 2.'),
|
|
192
|
+
chat_template: str = typer.Option(
|
|
193
|
+
"model", "--chat-template",
|
|
194
|
+
help='model uses each tokenizer template (default); plain uses the same text-only prompt format for every model.',
|
|
195
|
+
),
|
|
196
|
+
wait: bool = typer.Option(
|
|
197
|
+
False, "--wait",
|
|
198
|
+
help=(
|
|
199
|
+
'Wait for this requested execution or registration to finish. Without it, '
|
|
200
|
+
'return after submission; Ctrl-C only stops local waiting.'
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
timeout: str | None = typer.Option(
|
|
204
|
+
None, "--timeout",
|
|
205
|
+
help=(
|
|
206
|
+
'Local --wait limit, e.g. 90 (seconds), 30m, 6h or 2d; default: 30s. '
|
|
207
|
+
'Timeout does not stop the remote task.'
|
|
208
|
+
),
|
|
209
|
+
metavar='DURATION',
|
|
210
|
+
),
|
|
211
|
+
idempotency_key: str | None = typer.Option(None, "--idempotency-key", help="Stable key for retrying the same comparison request (1-128 characters)."),
|
|
212
|
+
dry_run: bool = typer.Option(False, "--dry-run", help="Preview fixed evaluation jobs without creating a comparison."),
|
|
213
|
+
):
|
|
214
|
+
"""Compare fixed models against a baseline on common dataset versions.
|
|
215
|
+
|
|
216
|
+
Provide at least one candidate source; asset, Merge and Fusion sources can be combined. Fusion
|
|
217
|
+
selects the latest 3 complete OPD checkpoints by default. --last, --checkpoint and
|
|
218
|
+
--all-checkpoints are mutually exclusive and need --candidate-from-fusion. Custom evaluation
|
|
219
|
+
needs --custom-format. --wait returns the final table; some failed/stopped evaluations exit 10,
|
|
220
|
+
all failed exit 7. Control individual evaluations with evaluation stop/delete/restart.
|
|
221
|
+
|
|
222
|
+
Examples:
|
|
223
|
+
|
|
224
|
+
infix evaluation compare --baseline workspace/base:v1.0.0 --candidate-from-merge merge-business --eval-type official --dataset official/gsm8k --wait
|
|
225
|
+
|
|
226
|
+
infix evaluation compare --baseline workspace/student:v1.0.0 --candidate-from-fusion fusion-business --eval-type custom --custom-format single-choice --dataset workspace/business-test:v1.0.0 --wait
|
|
227
|
+
"""
|
|
228
|
+
if not candidate and not candidate_from_merge and not candidate_from_fusion:
|
|
229
|
+
raise UsageError("Provide at least one candidate source.")
|
|
230
|
+
if sum((last is not None, bool(checkpoint), all_checkpoints)) > 1:
|
|
231
|
+
raise UsageError(
|
|
232
|
+
"--last, --checkpoint, and --all-checkpoints are mutually exclusive."
|
|
233
|
+
)
|
|
234
|
+
if not candidate_from_fusion and (
|
|
235
|
+
run is not None or last is not None or checkpoint or all_checkpoints
|
|
236
|
+
):
|
|
237
|
+
raise UsageError("Checkpoint/run selection requires --candidate-from-fusion.")
|
|
238
|
+
if eval_type not in {"official", "custom"} or (eval_type == "custom") != (
|
|
239
|
+
custom_format is not None
|
|
240
|
+
):
|
|
241
|
+
raise UsageError(
|
|
242
|
+
"eval-type must be official/custom; custom requires --custom-format."
|
|
243
|
+
)
|
|
244
|
+
if custom_format is not None and custom_format not in {
|
|
245
|
+
"single-choice",
|
|
246
|
+
"question-answering",
|
|
247
|
+
}:
|
|
248
|
+
raise UsageError("custom-format must be single-choice or question-answering.")
|
|
249
|
+
if gpu_count not in {1, 2, 4}:
|
|
250
|
+
raise UsageError("gpu-count must be 1, 2, or 4.")
|
|
251
|
+
if chat_template not in {"model", "plain"}:
|
|
252
|
+
raise UsageError("chat-template must be model or plain.")
|
|
253
|
+
seconds = parse_timeout(timeout)
|
|
254
|
+
if idempotency_key is not None and (not idempotency_key.strip() or len(idempotency_key) > 128 or not idempotency_key.isascii() or any(ord(char) < 33 or ord(char) > 126 for char in idempotency_key)):
|
|
255
|
+
raise UsageError("idempotency-key must contain 1-128 printable ASCII characters without whitespace.", details={"field": "idempotency_key"})
|
|
256
|
+
key = idempotency_key or request_key()
|
|
257
|
+
import hashlib
|
|
258
|
+
|
|
259
|
+
number = run_number(run)
|
|
260
|
+
context = ctx.obj
|
|
261
|
+
client = context.client()
|
|
262
|
+
body = {
|
|
263
|
+
"name": name or "cmp-" + hashlib.sha256(key.encode()).hexdigest()[:16],
|
|
264
|
+
"baseline": comparison_reference(client, baseline),
|
|
265
|
+
"candidates": [
|
|
266
|
+
comparison_reference(client, value) for value in candidate or []
|
|
267
|
+
],
|
|
268
|
+
"candidate_from_merge": [
|
|
269
|
+
{"task_ref": value} for value in candidate_from_merge or []
|
|
270
|
+
],
|
|
271
|
+
"datasets": [
|
|
272
|
+
comparison_reference(client, value, kind="dataset") for value in dataset
|
|
273
|
+
],
|
|
274
|
+
"eval_type": eval_type,
|
|
275
|
+
"max_parallel": max_parallel,
|
|
276
|
+
"gpu_count": gpu_count,
|
|
277
|
+
}
|
|
278
|
+
if custom_format:
|
|
279
|
+
body["custom_format"] = custom_format
|
|
280
|
+
if chat_template != "model":
|
|
281
|
+
# 老后端禁止未知顶层字段,明确拒绝而不是忽略模板后占用 GPU。
|
|
282
|
+
body["chat_template"] = chat_template
|
|
283
|
+
if candidate_from_fusion:
|
|
284
|
+
body["candidate_from_fusion"] = {
|
|
285
|
+
"task_ref": candidate_from_fusion,
|
|
286
|
+
**({"run": number} if number is not None else {}),
|
|
287
|
+
**({"last": last} if last is not None else {}),
|
|
288
|
+
"checkpoints": checkpoint or [],
|
|
289
|
+
"all_checkpoints": all_checkpoints,
|
|
290
|
+
}
|
|
291
|
+
submitted_name = body["name"]
|
|
292
|
+
notes = []
|
|
293
|
+
if all_checkpoints or dry_run:
|
|
294
|
+
preview = client.post(PATH + "/preview", json=body)
|
|
295
|
+
if dry_run:
|
|
296
|
+
output(context, {"dry_run": True, "name": body["name"], "plan": preview})
|
|
297
|
+
return
|
|
298
|
+
_confirm.require(
|
|
299
|
+
context,
|
|
300
|
+
title="Evaluate all currently complete checkpoints",
|
|
301
|
+
rows=[
|
|
302
|
+
("Candidates", str(preview["candidate_count"])),
|
|
303
|
+
("Datasets", str(preview["dataset_count"])),
|
|
304
|
+
("Evaluation jobs", str(preview["job_count"])),
|
|
305
|
+
("Concurrency limit", str(max_parallel)),
|
|
306
|
+
],
|
|
307
|
+
yes=yes,
|
|
308
|
+
)
|
|
309
|
+
body = preview["fixed_request"]
|
|
310
|
+
notes = preview.get("notes", [])
|
|
311
|
+
try:
|
|
312
|
+
result = client.request(
|
|
313
|
+
"POST", PATH, json=body, headers={"Idempotency-Key": key}
|
|
314
|
+
)
|
|
315
|
+
except SubmissionUnknown as exc:
|
|
316
|
+
exc.details = {
|
|
317
|
+
**(exc.details or {}),
|
|
318
|
+
"name": submitted_name,
|
|
319
|
+
"idempotency_key": key,
|
|
320
|
+
"query_argv": ["infix", "evaluation", "compare-get", submitted_name],
|
|
321
|
+
}
|
|
322
|
+
exc.hint = "Query the comparison by name. Repeat only with the same key and fixed request."
|
|
323
|
+
raise
|
|
324
|
+
if wait:
|
|
325
|
+
|
|
326
|
+
def fetch():
|
|
327
|
+
value = client.get(PATH + "/" + segment(result["id"]))
|
|
328
|
+
return value["status"], value
|
|
329
|
+
|
|
330
|
+
_, result = wait_until_terminal(
|
|
331
|
+
fetch,
|
|
332
|
+
terminal=frozenset({"completed", "partial_failed", "failed", "stopped"}),
|
|
333
|
+
ctx=context,
|
|
334
|
+
timeout=seconds,
|
|
335
|
+
label=result["comparison"],
|
|
336
|
+
recheck_hint="infix evaluation compare-get " + result["comparison"],
|
|
337
|
+
)
|
|
338
|
+
if notes:
|
|
339
|
+
result["submission_notes"] = notes
|
|
340
|
+
show(context, result)
|
|
341
|
+
if wait and result["status"] != "completed":
|
|
342
|
+
from infix_cli.errors import JobFailed, PartialFailure
|
|
343
|
+
|
|
344
|
+
error = PartialFailure if result["status"] in {"partial_failed", "stopped"} else JobFailed
|
|
345
|
+
raise error("Comparison did not complete successfully.", details={"id": result["id"], "status": result["status"]})
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def get(
|
|
349
|
+
ctx: typer.Context,
|
|
350
|
+
name: str = typer.Argument(..., help='Comparison group name or ID.'),
|
|
351
|
+
dataset: str | None = typer.Option(None, "--dataset", help='Filter by a dataset reference used in this comparison.'),
|
|
352
|
+
sort: str | None = typer.Option(
|
|
353
|
+
None, "--sort",
|
|
354
|
+
help=(
|
|
355
|
+
'Sort candidates by this metric using its configured direction, e.g. '
|
|
356
|
+
'overall_score.'
|
|
357
|
+
),
|
|
358
|
+
),
|
|
359
|
+
):
|
|
360
|
+
"""Show comparison scores, differences and best candidates per metric.
|
|
361
|
+
|
|
362
|
+
Target NAME: Comparison group name or ID.
|
|
363
|
+
|
|
364
|
+
A successful query exits 0 regardless of comparison state. Normalized deltas use percentage
|
|
365
|
+
points in text and 0-1 values in JSON. Failed scores remain null; each metric chooses its own
|
|
366
|
+
best candidates. Use --output json for job IDs and source references, then inspect an
|
|
367
|
+
individual evaluation.
|
|
368
|
+
|
|
369
|
+
Examples:
|
|
370
|
+
|
|
371
|
+
infix evaluation compare-get cmp-business --dataset workspace/business-test:v1.0.0 --sort overall_score --output json
|
|
372
|
+
"""
|
|
373
|
+
client = ctx.obj.client()
|
|
374
|
+
# 名称/版本与提交命令使用同一解析;冻结 ID 和历史展示名仍可直接筛选。
|
|
375
|
+
if dataset is not None and dataset.startswith(("official/", "workspace/")):
|
|
376
|
+
dataset = comparison_reference(client, dataset, kind="dataset")["version_id"]
|
|
377
|
+
result = client.get(
|
|
378
|
+
PATH + "/" + segment(name), params={"dataset": dataset, "sort": sort}
|
|
379
|
+
)
|
|
380
|
+
show(ctx.obj, result)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def history(
|
|
384
|
+
ctx: typer.Context,
|
|
385
|
+
status: str | None = typer.Option(
|
|
386
|
+
None, "--status",
|
|
387
|
+
help=(
|
|
388
|
+
'queued, running, completed, partial_failed, failed or stopped. '
|
|
389
|
+
'Case-insensitive; PartialFailed is also accepted.'
|
|
390
|
+
),
|
|
391
|
+
),
|
|
392
|
+
creator: str | None = typer.Option(None, "--creator", help='Filter by creator user ID.'),
|
|
393
|
+
page: int = typer.Option(1, "--page", min=1, help='Page number, starting at 1; default: 1.'),
|
|
394
|
+
page_size: int = typer.Option(10, "--page-size", min=1, max=50, help='Results per page; default: 10, maximum: 50.'),
|
|
395
|
+
):
|
|
396
|
+
"""List comparison groups in the current workspace.
|
|
397
|
+
|
|
398
|
+
Groups reflect current child evaluation states, including restarts. Use compare-get for results
|
|
399
|
+
and individual evaluation commands for stop/delete/restart.
|
|
400
|
+
|
|
401
|
+
Examples:
|
|
402
|
+
|
|
403
|
+
infix evaluation compare-list --status partial_failed --page-size 10
|
|
404
|
+
"""
|
|
405
|
+
if status:
|
|
406
|
+
aliases = {"partialfailed": "partial_failed"}
|
|
407
|
+
status = aliases.get(status.lower(), status.lower())
|
|
408
|
+
if status not in {
|
|
409
|
+
"queued",
|
|
410
|
+
"running",
|
|
411
|
+
"completed",
|
|
412
|
+
"partial_failed",
|
|
413
|
+
"failed",
|
|
414
|
+
"stopped",
|
|
415
|
+
}:
|
|
416
|
+
raise UsageError("Invalid comparison status.")
|
|
417
|
+
result = ctx.obj.client().get(
|
|
418
|
+
PATH,
|
|
419
|
+
params={
|
|
420
|
+
"status": status,
|
|
421
|
+
"creator": creator,
|
|
422
|
+
"page": page,
|
|
423
|
+
"page_size": page_size,
|
|
424
|
+
},
|
|
425
|
+
)
|
|
426
|
+
if ctx.obj.output == "json":
|
|
427
|
+
output(ctx.obj, result)
|
|
428
|
+
elif ctx.obj.quiet:
|
|
429
|
+
for row in result["items"]:
|
|
430
|
+
print(row["comparison"])
|
|
431
|
+
else:
|
|
432
|
+
from rich.table import Table
|
|
433
|
+
|
|
434
|
+
table = Table("COMPARISON", "STATUS", "JOBS", "PARALLEL", "CREATOR")
|
|
435
|
+
for row in result["items"]:
|
|
436
|
+
table.add_row(
|
|
437
|
+
row["comparison"],
|
|
438
|
+
row["status"],
|
|
439
|
+
str(row["job_count"]),
|
|
440
|
+
str(row["max_parallel"]),
|
|
441
|
+
row["created_by"],
|
|
442
|
+
)
|
|
443
|
+
print_table(ctx.obj, table)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""不可逆操作只接受显式确认参数,不读取终端或 stdin。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from infix_cli.errors import ConfirmationRequired
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def require(
|
|
11
|
+
run: Any,
|
|
12
|
+
*,
|
|
13
|
+
title: str,
|
|
14
|
+
rows: list[tuple[str, str]] | None = None,
|
|
15
|
+
yes: bool,
|
|
16
|
+
type_to_confirm: str | None = None,
|
|
17
|
+
flag: str = "--yes",
|
|
18
|
+
) -> None:
|
|
19
|
+
"""检查调用者是否提供了当前操作需要的确认参数。"""
|
|
20
|
+
if yes:
|
|
21
|
+
return
|
|
22
|
+
raise ConfirmationRequired(
|
|
23
|
+
f"{title.rstrip('.')} — explicit confirmation required.",
|
|
24
|
+
f"Re-run with {flag} to confirm.",
|
|
25
|
+
details={"confirmation_flag": flag, "operation": title, "resources": [{"label": label, "value": value} for label, value in rows or []]},
|
|
26
|
+
)
|