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,319 @@
|
|
|
1
|
+
"""仅呈现平台已返回的执行、数据规模和资源证据,不推测训练结果。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
import json
|
|
7
|
+
import math
|
|
8
|
+
import shlex
|
|
9
|
+
|
|
10
|
+
from infix_cli import render
|
|
11
|
+
from infix_cli.render.text import print_error
|
|
12
|
+
|
|
13
|
+
STAGES = {"generate": "distill", "filter": "clean", "sft": "warmup"}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def stage_label(value):
|
|
17
|
+
return STAGES.get(value, value)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def command(*parts):
|
|
21
|
+
return shlex.join(str(part) for part in parts)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def elapsed_seconds(value):
|
|
25
|
+
seconds = value.get("elapsed_seconds")
|
|
26
|
+
if isinstance(seconds, (int, float)) and not isinstance(seconds, bool):
|
|
27
|
+
return seconds if math.isfinite(seconds) and seconds >= 0 else None
|
|
28
|
+
start, end = (
|
|
29
|
+
value.get("started_at") or value.get("created_at"),
|
|
30
|
+
value.get("finished_at"),
|
|
31
|
+
)
|
|
32
|
+
if not start or not end:
|
|
33
|
+
return None
|
|
34
|
+
try:
|
|
35
|
+
clocks = [
|
|
36
|
+
datetime.fromisoformat(str(clock).replace("Z", "+00:00"))
|
|
37
|
+
for clock in (start, end)
|
|
38
|
+
]
|
|
39
|
+
clocks = [
|
|
40
|
+
clock.replace(tzinfo=timezone.utc) if clock.tzinfo is None else clock
|
|
41
|
+
for clock in clocks
|
|
42
|
+
]
|
|
43
|
+
seconds = (clocks[1] - clocks[0]).total_seconds()
|
|
44
|
+
return seconds if seconds >= 0 else None
|
|
45
|
+
except (TypeError, ValueError, OverflowError):
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def metric_rows(value):
|
|
50
|
+
summary = value.get("summary") or {}
|
|
51
|
+
metrics = summary.get("training_metrics") or {}
|
|
52
|
+
loss = metrics.get("final_loss", summary.get("final_loss"))
|
|
53
|
+
rows = []
|
|
54
|
+
if (
|
|
55
|
+
isinstance(loss, (int, float))
|
|
56
|
+
and not isinstance(loss, bool)
|
|
57
|
+
and math.isfinite(loss)
|
|
58
|
+
):
|
|
59
|
+
rows.append(("Final loss", f"{loss:.8g}"))
|
|
60
|
+
elif type(metrics.get("latest_loss")) in {int, float} and math.isfinite(metrics["latest_loss"]):
|
|
61
|
+
rows.append(("Latest observed loss", f"{metrics['latest_loss']:.8g}"))
|
|
62
|
+
if metrics.get("loss_step") is not None:
|
|
63
|
+
rows.append(("Loss step", str(metrics["loss_step"])))
|
|
64
|
+
tensorboard = metrics.get("tensorboard") or {}
|
|
65
|
+
url = tensorboard.get("url") or summary.get("tensorboard_url")
|
|
66
|
+
if url:
|
|
67
|
+
rows.append(("TensorBoard", str(url)))
|
|
68
|
+
elif tensorboard.get("log_dir"):
|
|
69
|
+
rows.append(("TensorBoard logs", str(tensorboard["log_dir"])))
|
|
70
|
+
rows.append(("TensorBoard viewer", "No viewer URL has been published."))
|
|
71
|
+
if metrics.get("status") == "unavailable":
|
|
72
|
+
rows.append(("Training metrics", "Unavailable; inspect the training logs."))
|
|
73
|
+
return rows
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _model_reference(value, labels):
|
|
77
|
+
if not isinstance(value, dict):
|
|
78
|
+
return str(value)
|
|
79
|
+
version = value.get("version_id") or value.get("asset")
|
|
80
|
+
if version:
|
|
81
|
+
return labels.get(version, "asset:" + str(version))
|
|
82
|
+
snapshot = value.get("snapshot_id") or value.get("snapshot")
|
|
83
|
+
if snapshot:
|
|
84
|
+
return "snapshot:" + str(snapshot)
|
|
85
|
+
if value.get("uri"):
|
|
86
|
+
return str(value["uri"])
|
|
87
|
+
if value.get("path"):
|
|
88
|
+
return "storage/" + str(value["path"])
|
|
89
|
+
if value.get("from"):
|
|
90
|
+
return "from:" + str(value["from"])
|
|
91
|
+
return "Unknown"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def plan_rows(plan, *, config=None, reference_labels=None):
|
|
95
|
+
config = config or {}
|
|
96
|
+
reference_labels = reference_labels or {}
|
|
97
|
+
stages = plan.get("stages", [])
|
|
98
|
+
rows = [
|
|
99
|
+
(
|
|
100
|
+
"Stages",
|
|
101
|
+
" → ".join(stage_label(stage["stage_type"]) for stage in stages) or "None",
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
bindings = plan.get("stage_bindings", [])
|
|
105
|
+
skipped = [
|
|
106
|
+
stage_label(item["stage_type"])
|
|
107
|
+
for item in bindings
|
|
108
|
+
if item.get("status") == "skipped"
|
|
109
|
+
]
|
|
110
|
+
if skipped:
|
|
111
|
+
rows.append(("Skipped", ", ".join(skipped)))
|
|
112
|
+
preflight = plan.get("preflight") or {}
|
|
113
|
+
rows.append(("Static preflight", str(preflight.get("status", "unknown"))))
|
|
114
|
+
checks = {check["name"]: check for check in preflight.get("checks", [])}
|
|
115
|
+
for dataset in checks.get("data_format_and_count", {}).get("datasets", []):
|
|
116
|
+
count = dataset.get("rows")
|
|
117
|
+
rows.append(
|
|
118
|
+
(
|
|
119
|
+
"Input " + str(dataset.get("input", "dataset")),
|
|
120
|
+
f"{count} records" if count is not None else "Record count unknown",
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
for item in preflight.get("deferred_inputs", []):
|
|
124
|
+
rows.append(
|
|
125
|
+
("Deferred input", str(item.get("input") or item.get("reason") or item))
|
|
126
|
+
)
|
|
127
|
+
resource_checks = {
|
|
128
|
+
item["stage_type"]: item
|
|
129
|
+
for item in checks.get("resource_availability", {}).get("stages", [])
|
|
130
|
+
}
|
|
131
|
+
totals = []
|
|
132
|
+
for stage in stages:
|
|
133
|
+
label = stage_label(stage["stage_type"])
|
|
134
|
+
if stage["stage_type"] == "merge":
|
|
135
|
+
configured = (config.get("stages", {}).get("merge") or {}).get("inputs", {})
|
|
136
|
+
inputs = stage.get("inputs") or stage.get("raw_inputs") or configured
|
|
137
|
+
base = inputs.get("base") or config.get("base")
|
|
138
|
+
if base:
|
|
139
|
+
rows.append(("merge base model", _model_reference(base, reference_labels)))
|
|
140
|
+
experts = inputs.get("expert") or config.get("experts") or {}
|
|
141
|
+
for key, value in experts.items():
|
|
142
|
+
rows.append(("merge expert " + key, _model_reference(value, reference_labels)))
|
|
143
|
+
rows.append(
|
|
144
|
+
(
|
|
145
|
+
label + " parameters",
|
|
146
|
+
json.dumps(stage.get("params", {}), ensure_ascii=False),
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
evidence = resource_checks.get(stage["stage_type"], {})
|
|
150
|
+
if not evidence.get("groups"):
|
|
151
|
+
rows.append(
|
|
152
|
+
(label + " resources", str(stage.get("resources") or "Unknown"))
|
|
153
|
+
)
|
|
154
|
+
for group in evidence.get("groups", []):
|
|
155
|
+
rows.append(
|
|
156
|
+
(
|
|
157
|
+
label + " " + group["role"],
|
|
158
|
+
f"{group['count']} worker(s) × {group['gpu']} GPU ({group.get('gpu_type') or 'CPU'}), {group['cpu_milli'] / 1000:g} CPU and {group['memory_bytes']} bytes per worker",
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
total = evidence.get("total", {}).get("gpu")
|
|
162
|
+
rows.append(
|
|
163
|
+
(label + " total GPUs", str(total) if total is not None else "Unknown")
|
|
164
|
+
)
|
|
165
|
+
rows.append((label + " availability", str(evidence.get("status", "unknown"))))
|
|
166
|
+
if total is not None:
|
|
167
|
+
totals.append(total)
|
|
168
|
+
if totals:
|
|
169
|
+
rows.append(
|
|
170
|
+
(
|
|
171
|
+
"Peak planned GPUs",
|
|
172
|
+
str(max(totals))
|
|
173
|
+
if len(totals) == len(stages)
|
|
174
|
+
else "Unknown; some stages are unresolved",
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
pending = plan.get("pending_checks") or []
|
|
178
|
+
rows.append(("Checks pending", ", ".join(pending) or "None"))
|
|
179
|
+
return rows
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def execution_feedback(ctx, payload, *, kind, task):
|
|
183
|
+
execution = payload.get("execution") or {}
|
|
184
|
+
detail = payload.get("details") or {}
|
|
185
|
+
summary = detail.get("summary") or {}
|
|
186
|
+
status = execution.get("status") or payload.get("status")
|
|
187
|
+
reason = execution.get("stop_reason") or payload.get("stop_reason")
|
|
188
|
+
number = execution.get("number")
|
|
189
|
+
rows = [
|
|
190
|
+
("Task", str(payload.get("name") or task)),
|
|
191
|
+
("Status", str(status or "unknown")),
|
|
192
|
+
]
|
|
193
|
+
if number:
|
|
194
|
+
rows.append(("Run", f"run-{number}"))
|
|
195
|
+
seconds = elapsed_seconds(execution)
|
|
196
|
+
if seconds is None:
|
|
197
|
+
seconds = elapsed_seconds(summary)
|
|
198
|
+
if seconds is not None:
|
|
199
|
+
rows.append(("Elapsed", f"{seconds:.1f}s"))
|
|
200
|
+
if payload.get("output_name") or summary.get("output_name"):
|
|
201
|
+
rows.append(
|
|
202
|
+
("Output name", str(payload.get("output_name") or summary["output_name"]))
|
|
203
|
+
)
|
|
204
|
+
errors = []
|
|
205
|
+
for slot in detail.get("stages", []):
|
|
206
|
+
value = slot.get("run") or {}
|
|
207
|
+
stage = stage_label(slot.get("stage_type", "stage"))
|
|
208
|
+
if value.get("error_message"):
|
|
209
|
+
errors.append(stage + ": " + value["error_message"])
|
|
210
|
+
for name, output in (value.get("outputs") or {}).items():
|
|
211
|
+
path = output.get("path") if isinstance(output, dict) else output
|
|
212
|
+
if isinstance(path, str):
|
|
213
|
+
rows.append((stage + " " + name, path))
|
|
214
|
+
if value.get("output_path") and not value.get("outputs"):
|
|
215
|
+
rows.append((stage + " output directory", str(value["output_path"])))
|
|
216
|
+
rows.extend((stage + " " + key, value) for key, value in metric_rows(value))
|
|
217
|
+
if (
|
|
218
|
+
(value.get("summary") or {})
|
|
219
|
+
.get("training_metrics", {})
|
|
220
|
+
.get("tensorboard", {})
|
|
221
|
+
.get("log_dir")
|
|
222
|
+
):
|
|
223
|
+
rows.append(
|
|
224
|
+
(
|
|
225
|
+
stage + " TensorBoard",
|
|
226
|
+
command(
|
|
227
|
+
"infix",
|
|
228
|
+
"fusion",
|
|
229
|
+
"tensorboard",
|
|
230
|
+
task,
|
|
231
|
+
"--stage",
|
|
232
|
+
stage,
|
|
233
|
+
*(["--run", f"run-{number}"] if number else []),
|
|
234
|
+
"--wait",
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
counts = value.get("summary") or {}
|
|
239
|
+
counts = {
|
|
240
|
+
key: counts[key]
|
|
241
|
+
for key in ("input", "kept", "rejected", "success", "failed")
|
|
242
|
+
if key in counts
|
|
243
|
+
}
|
|
244
|
+
if counts:
|
|
245
|
+
rows.append(
|
|
246
|
+
(
|
|
247
|
+
stage + " records",
|
|
248
|
+
", ".join(f"{key}={count}" for key, count in counts.items()),
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
if slot.get("reused"):
|
|
252
|
+
rows.append((stage + " source", "Reused completed output"))
|
|
253
|
+
logs = command("infix", kind, "logs", task)
|
|
254
|
+
if kind == "fusion" and number:
|
|
255
|
+
logs += " " + command("--run", f"run-{number}")
|
|
256
|
+
if status == "failed" and ctx.output != "json":
|
|
257
|
+
message = (
|
|
258
|
+
"; ".join(errors)
|
|
259
|
+
or execution.get("error_message")
|
|
260
|
+
or "Execution failed; inspect the stage logs for the cause."
|
|
261
|
+
)
|
|
262
|
+
print_error(message, hint=logs, no_color=ctx.no_color)
|
|
263
|
+
elif status == "stopped" and reason != "awaiting_next_stage" and ctx.output != "json":
|
|
264
|
+
hint = (
|
|
265
|
+
command("infix", "fusion", "resume", task, "--accept-data", "--wait")
|
|
266
|
+
if reason == "data_quality_confirmation"
|
|
267
|
+
else logs
|
|
268
|
+
)
|
|
269
|
+
print_error(
|
|
270
|
+
"Data quality confirmation required."
|
|
271
|
+
if reason == "data_quality_confirmation"
|
|
272
|
+
else "Execution stopped: " + str(reason or "unknown reason"),
|
|
273
|
+
hint=hint,
|
|
274
|
+
no_color=ctx.no_color,
|
|
275
|
+
)
|
|
276
|
+
if ctx.output == "json" or ctx.quiet:
|
|
277
|
+
return
|
|
278
|
+
if status == "succeeded" or (
|
|
279
|
+
status == "stopped" and reason == "awaiting_next_stage"
|
|
280
|
+
):
|
|
281
|
+
render.message(ctx, "Requested stages completed.")
|
|
282
|
+
if reason:
|
|
283
|
+
rows.append(("Pause reason", str(reason)))
|
|
284
|
+
rows.append(("Inspect", command("infix", kind, "get", task)))
|
|
285
|
+
if kind == "fusion":
|
|
286
|
+
rows.append(
|
|
287
|
+
(
|
|
288
|
+
"Artifacts",
|
|
289
|
+
command(
|
|
290
|
+
"infix",
|
|
291
|
+
kind,
|
|
292
|
+
"artifacts",
|
|
293
|
+
task,
|
|
294
|
+
*(["--run", f"run-{number}"] if number else []),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
if reason == "awaiting_next_stage":
|
|
299
|
+
rows.append(
|
|
300
|
+
("Continue", command("infix", "fusion", "resume", task, "--wait"))
|
|
301
|
+
)
|
|
302
|
+
elif status == "succeeded":
|
|
303
|
+
rows.append(
|
|
304
|
+
(
|
|
305
|
+
"Evaluate",
|
|
306
|
+
command(
|
|
307
|
+
"infix", "evaluation", "compare", "--candidate-from-merge", task
|
|
308
|
+
)
|
|
309
|
+
+ " --baseline <base-model-ref> --eval-type official --dataset <dataset-ref> --wait",
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
rows.append(
|
|
313
|
+
(
|
|
314
|
+
"Register",
|
|
315
|
+
command("infix", "merge", "register", task)
|
|
316
|
+
+ " --name <model-name> --wait",
|
|
317
|
+
)
|
|
318
|
+
)
|
|
319
|
+
render.render_object(ctx, payload, rows)
|