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.
Files changed (85) hide show
  1. infix_cli/__init__.py +5 -0
  2. infix_cli/__main__.py +6 -0
  3. infix_cli/agent-guide.txt +71 -0
  4. infix_cli/cli_framework.py +96 -0
  5. infix_cli/command_contract.py +157 -0
  6. infix_cli/commands/__init__.py +1 -0
  7. infix_cli/commands/_artifacts.py +142 -0
  8. infix_cli/commands/_comparison.py +443 -0
  9. infix_cli/commands/_confirm.py +26 -0
  10. infix_cli/commands/_control.py +290 -0
  11. infix_cli/commands/_create.py +351 -0
  12. infix_cli/commands/_create_output.py +139 -0
  13. infix_cli/commands/_delete.py +288 -0
  14. infix_cli/commands/_download.py +459 -0
  15. infix_cli/commands/_fusion_common.py +191 -0
  16. infix_cli/commands/_fusion_config.py +394 -0
  17. infix_cli/commands/_fusion_feedback.py +319 -0
  18. infix_cli/commands/_fusion_tasks.py +507 -0
  19. infix_cli/commands/_fusion_tensorboard.py +132 -0
  20. infix_cli/commands/_jobs.py +312 -0
  21. infix_cli/commands/_logs.py +210 -0
  22. infix_cli/commands/_publish.py +123 -0
  23. infix_cli/commands/_register.py +600 -0
  24. infix_cli/commands/_register_output.py +231 -0
  25. infix_cli/commands/_storage_tree.py +62 -0
  26. infix_cli/commands/admin.py +668 -0
  27. infix_cli/commands/asset.py +2012 -0
  28. infix_cli/commands/auth.py +246 -0
  29. infix_cli/commands/deploy.py +850 -0
  30. infix_cli/commands/evaluation.py +360 -0
  31. infix_cli/commands/examples.py +138 -0
  32. infix_cli/commands/fusion.py +1842 -0
  33. infix_cli/commands/merge.py +709 -0
  34. infix_cli/commands/resource.py +127 -0
  35. infix_cli/commands/spark.py +347 -0
  36. infix_cli/commands/storage.py +329 -0
  37. infix_cli/commands/training.py +748 -0
  38. infix_cli/config.py +311 -0
  39. infix_cli/config_input.py +217 -0
  40. infix_cli/context.py +84 -0
  41. infix_cli/discovery.py +459 -0
  42. infix_cli/domain/__init__.py +1 -0
  43. infix_cli/domain/dto/__init__.py +6 -0
  44. infix_cli/domain/dto/admin.py +413 -0
  45. infix_cli/domain/dto/asset.py +390 -0
  46. infix_cli/domain/dto/common.py +136 -0
  47. infix_cli/domain/dto/evaluation.py +296 -0
  48. infix_cli/domain/dto/logs.py +98 -0
  49. infix_cli/domain/dto/resource.py +108 -0
  50. infix_cli/domain/dto/serving.py +156 -0
  51. infix_cli/domain/dto/spark.py +241 -0
  52. infix_cli/domain/dto/storage.py +75 -0
  53. infix_cli/domain/dto/training.py +272 -0
  54. infix_cli/domain/enums.py +359 -0
  55. infix_cli/domain/hyperparams.py +190 -0
  56. infix_cli/domain/refs.py +108 -0
  57. infix_cli/domain/resolve.py +619 -0
  58. infix_cli/errors.py +158 -0
  59. infix_cli/example_data/__init__.py +1 -0
  60. infix_cli/example_data/fusion/README.md +128 -0
  61. infix_cli/example_data/fusion/fusion.json +149 -0
  62. infix_cli/example_data/fusion/prompts/code.jsonl +16 -0
  63. infix_cli/example_data/fusion/prompts/math.jsonl +16 -0
  64. infix_cli/example_data/fusion.zip +0 -0
  65. infix_cli/example_data/merge/README.md +89 -0
  66. infix_cli/example_data/merge/merge.json +26 -0
  67. infix_cli/example_data/merge.zip +0 -0
  68. infix_cli/http/__init__.py +1 -0
  69. infix_cli/http/browser_auth.py +160 -0
  70. infix_cli/http/client.py +575 -0
  71. infix_cli/http/pagination.py +84 -0
  72. infix_cli/http/upload.py +254 -0
  73. infix_cli/main.py +432 -0
  74. infix_cli/pipeline_config_schema.py +122 -0
  75. infix_cli/render/__init__.py +79 -0
  76. infix_cli/render/json_out.py +123 -0
  77. infix_cli/render/progress.py +62 -0
  78. infix_cli/render/text.py +233 -0
  79. infix_cli/update_check.py +177 -0
  80. infix_cli/waiter.py +93 -0
  81. infix_cli/workspace.py +158 -0
  82. infixspeed_cli-0.0.16.dist-info/METADATA +58 -0
  83. infixspeed_cli-0.0.16.dist-info/RECORD +85 -0
  84. infixspeed_cli-0.0.16.dist-info/WHEEL +4 -0
  85. infixspeed_cli-0.0.16.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,329 @@
1
+ """``infix storage`` — Workspace Storage browsing."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import typer
8
+
9
+ from infix_cli import render
10
+ from infix_cli.domain.dto.storage import StorageEntryDTO
11
+ from infix_cli.errors import CliError, NotFoundError, UsageError
12
+ from infix_cli.http.pagination import slice_page
13
+ from infix_cli.render import progress
14
+
15
+ app = typer.Typer(help="Workspace Storage.", no_args_is_help=True)
16
+
17
+
18
+ @app.command("list")
19
+ def list_entries(
20
+ ctx: typer.Context,
21
+ path: Optional[str] = typer.Argument(None, help="Directory to list; defaults to the storage root."),
22
+ page: int = typer.Option(1, "--page", min=1),
23
+ page_size: int = typer.Option(None, "--page-size", min=1, max=50),
24
+ dir_size: bool = typer.Option(
25
+ True, "--dir-size/--no-dir-size",
26
+ help="Compute folder sizes (slower on large trees).",
27
+ ),
28
+ ) -> None:
29
+ """List files and folders under a Workspace Storage path."""
30
+ run = ctx.obj
31
+ client = run.client()
32
+ target = (path or "").strip().lstrip("/")
33
+ payload = client.get(
34
+ "/storage/list",
35
+ params={"path": target, "include_dir_size": "true" if dir_size else None},
36
+ )
37
+ entries = list((payload or {}).get("entries") or [])
38
+ if not entries and target:
39
+ _assert_path_exists(client, target)
40
+
41
+ dtos = [StorageEntryDTO.from_api(raw, base_path=target) for raw in entries]
42
+ # The backend defines no ordering; without a stable one, local pagination
43
+ # would show different rows for the same page on consecutive calls.
44
+ dtos.sort(key=lambda entry: entry.sort_key())
45
+ size = run.default_page_size(page_size)
46
+
47
+ if run.output == "json":
48
+ from infix_cli.render import json_out
49
+
50
+ json_out.print_raw({
51
+ "path": target,
52
+ "items": [d.to_json() for d in slice_page(dtos, page, size)],
53
+ "page": page,
54
+ "page_size": size,
55
+ "total": len(dtos),
56
+ })
57
+ return
58
+
59
+ render.render_list(
60
+ run, slice_page(dtos, page, size), StorageEntryDTO.columns(),
61
+ page=page, page_size=size, total=len(dtos),
62
+ quiet_field="name",
63
+ empty_message=f'"{target or "/"}" is empty.',
64
+ )
65
+
66
+
67
+ def _assert_path_exists(client, target: str) -> None:
68
+ """Tell "empty directory" apart from "no such directory".
69
+
70
+ ``/storage/list`` returns an empty list for both, so the parent directory
71
+ is listed and searched for the entry — the cheapest way to get a real
72
+ answer without a dedicated endpoint.
73
+ """
74
+ from infix_cli.errors import CliError
75
+
76
+ parent, _, leaf = target.rstrip("/").rpartition("/")
77
+ try:
78
+ payload = client.get("/storage/list", params={"path": parent})
79
+ except CliError:
80
+ return
81
+ names = {str(e.get("name")) for e in (payload or {}).get("entries") or []}
82
+ if leaf and leaf not in names:
83
+ raise NotFoundError(
84
+ f'Path "{target}" does not exist.',
85
+ 'Run "infix storage list" to browse from the storage root.',
86
+ )
87
+
88
+
89
+ @app.command("upload")
90
+ def upload(
91
+ ctx: typer.Context,
92
+ local_path: str = typer.Argument(..., help="Local file or directory to upload."),
93
+ dest: Optional[str] = typer.Option(
94
+ None, "--dest", "-d",
95
+ help="Destination under Upload/. Defaults to Upload/ itself.",
96
+ rich_help_panel="Optional",
97
+ ),
98
+ concurrency: int = typer.Option(
99
+ 4, "--concurrency", min=1, max=8,
100
+ help="Files uploaded in parallel when the source is a directory.",
101
+ rich_help_panel="Optional",
102
+ ),
103
+ no_resume: bool = typer.Option(
104
+ False, "--no-resume",
105
+ help="Start over instead of continuing an interrupted transfer.",
106
+ rich_help_panel="Optional",
107
+ ),
108
+ ) -> None:
109
+ """Upload a file or directory to Workspace Storage.
110
+
111
+ Everything lands under Upload/; --dest names a subdirectory of it.
112
+ Transfers are chunked and resumable — re-running after an interruption
113
+ continues from the last completed part.
114
+
115
+ Examples:
116
+
117
+ infix storage upload ./data/training_v2.jsonl --dest datasets/
118
+
119
+ infix storage upload ./corpus -d datasets/corpus
120
+ """
121
+ from pathlib import Path
122
+
123
+ from infix_cli.http import upload as upload_mod
124
+
125
+ run = ctx.obj
126
+ client = run.client()
127
+ source = Path(local_path).expanduser()
128
+ if not source.exists():
129
+ raise UsageError(f'No such file or directory: "{local_path}".')
130
+
131
+ dest_subpath = _clean_dest(dest)
132
+ if source.is_file():
133
+ results, failures = _upload_one(run, client, source, dest_subpath, resume=not no_resume)
134
+ else:
135
+ results, failures = _upload_tree(
136
+ run, client, source, dest_subpath,
137
+ concurrency=concurrency, resume=not no_resume,
138
+ )
139
+
140
+ _report_uploads(run, results, failures)
141
+
142
+
143
+ @app.command("download")
144
+ def download(
145
+ ctx: typer.Context,
146
+ path: str = typer.Argument(..., help="File or folder in Workspace Storage."),
147
+ dest: Optional[str] = typer.Option(
148
+ None, "--dest", "-d", help="Local directory to download into. Defaults to the current one.",
149
+ rich_help_panel="Optional",
150
+ ),
151
+ owner: Optional[str] = typer.Option(
152
+ None, "--owner",
153
+ help="User id whose storage the path is in, for a file shared with you. Files only.",
154
+ rich_help_panel="Optional",
155
+ ),
156
+ concurrency: int = typer.Option(
157
+ 4, "--concurrency", min=1, max=8,
158
+ help="Files downloaded in parallel when the source is a folder.",
159
+ rich_help_panel="Optional",
160
+ ),
161
+ overwrite: bool = typer.Option(
162
+ False, "--overwrite",
163
+ help="Download from the beginning without reusing local files or partial downloads.",
164
+ rich_help_panel="Optional",
165
+ ),
166
+ ) -> None:
167
+ """Download a file or folder from Workspace Storage.
168
+
169
+ A folder is downloaded with its structure. Re-running can reuse completed
170
+ files and resume partial files when the remote ETag and local metadata match.
171
+
172
+ Examples:
173
+
174
+ infix storage download Upload/datasets/train.jsonl
175
+
176
+ infix storage download Model_Training_Output/sft-run -d ./outputs
177
+ """
178
+ from infix_cli.commands import _download
179
+
180
+ _download.download(
181
+ ctx.obj, path, dest=dest, owner=owner, overwrite=overwrite, concurrency=concurrency,
182
+ )
183
+
184
+
185
+ @app.command("delete")
186
+ def delete(
187
+ ctx: typer.Context,
188
+ paths: list[str] = typer.Argument(..., help="Files or folders to delete. Several may be given."),
189
+ owner: Optional[str] = typer.Option(
190
+ None, "--owner",
191
+ help="User id whose storage the paths are in (workspace admins only). Defaults to you.",
192
+ rich_help_panel="Optional",
193
+ ),
194
+ yes: bool = typer.Option(
195
+ False, "--yes", "-y", help="Do not ask for confirmation.", rich_help_panel="Optional",
196
+ ),
197
+ ) -> None:
198
+ """Delete files or folders from Workspace Storage. This cannot be undone.
199
+
200
+ Folders are deleted with everything in them. Paths are relative to your
201
+ storage root (e.g. Upload/datasets/train.jsonl). The system folders
202
+ (Model_Training_Output and the like) cannot be deleted, but their contents can.
203
+ A path still used by a running job is refused.
204
+ """
205
+ from infix_cli.commands import _delete
206
+
207
+ _delete.delete_storage(ctx.obj, list(paths), owner=owner, yes=yes)
208
+
209
+
210
+ def _clean_dest(dest: Optional[str]) -> str:
211
+ """Normalise --dest.
212
+
213
+ Everything is written under the reserved Upload/ folder server-side, so a
214
+ leading "Upload/" in the flag is accepted and stripped rather than
215
+ producing Upload/Upload/…; ".." is refused outright.
216
+ """
217
+ value = (dest or "").strip().strip("/")
218
+ if not value:
219
+ return ""
220
+ if value == "Upload" or value.startswith("Upload/"):
221
+ value = value[len("Upload"):].strip("/")
222
+ if any(segment == ".." for segment in value.split("/")):
223
+ raise UsageError(f'Invalid --dest "{dest}": path segments may not be "..".')
224
+ return value
225
+
226
+
227
+ def _upload_one(run, client, source, dest_subpath: str, *, resume: bool):
228
+ from infix_cli.http import upload as upload_mod
229
+
230
+ tracker = progress.tracker(run, source.name, source.stat().st_size)
231
+ try:
232
+ result = upload_mod.upload_file(
233
+ client, source, dest_subpath=dest_subpath,
234
+ on_progress=tracker, resume=resume,
235
+ )
236
+ except UsageError:
237
+ # Bad input (over the size limit, not a file) is the user's to fix and
238
+ # keeps its own exit code — degrading it to "1 file failed" would bury
239
+ # the reason under a transfer-failure summary.
240
+ raise
241
+ except CliError as exc:
242
+ return [], [(str(source), exc.message)]
243
+ finally:
244
+ progress.finish(run)
245
+ return [result], []
246
+
247
+
248
+ def _upload_tree(run, client, root, dest_subpath: str, *, concurrency: int, resume: bool):
249
+ """Upload a directory, a bounded number of files at a time."""
250
+ from concurrent.futures import ThreadPoolExecutor
251
+ from infix_cli.http import upload as upload_mod
252
+
253
+ files = list(upload_mod.iter_files(root))
254
+ if not files:
255
+ raise UsageError(f'"{root}" contains no files to upload.')
256
+
257
+ total_bytes = sum(f.stat().st_size for f in files)
258
+ render.message(run, f"Uploading {len(files)} files ({_size_text(total_bytes)})...")
259
+
260
+ results, failures = [], []
261
+
262
+ def send(path):
263
+ try:
264
+ return upload_mod.upload_file(
265
+ client, path,
266
+ dest_subpath=upload_mod.relative_dest(root, path, dest_subpath),
267
+ resume=resume,
268
+ ), None
269
+ except CliError as exc:
270
+ return None, (str(path), exc.message)
271
+
272
+ with ThreadPoolExecutor(max_workers=concurrency) as pool:
273
+ for result, failure in pool.map(send, files):
274
+ if result is not None:
275
+ results.append(result)
276
+ if run.output != "json" and not run.quiet:
277
+ print(f" {result.remote_path}")
278
+ else:
279
+ failures.append(failure)
280
+ return results, failures
281
+
282
+
283
+ def _report_uploads(run, results, failures) -> None:
284
+ from infix_cli.errors import ApiError
285
+
286
+ payload = {
287
+ "uploaded": [
288
+ {"local_path": r.local_path, "remote_path": r.remote_path,
289
+ "size_bytes": r.size_bytes}
290
+ for r in results
291
+ ],
292
+ "total_files": len(results),
293
+ "total_bytes": sum(r.size_bytes for r in results),
294
+ "failed": [{"local_path": path, "error": message} for path, message in failures],
295
+ }
296
+ if run.output == "json":
297
+ from infix_cli.render import json_out
298
+
299
+ json_out.print_raw(payload)
300
+ elif not run.quiet:
301
+ if results:
302
+ render.message(run, "Uploaded successfully.")
303
+ if len(results) == 1:
304
+ from infix_cli.render import text as text_render
305
+
306
+ text_render.print_labeled(run, [
307
+ ("Path", results[0].remote_path),
308
+ ("Size", _size_text(results[0].size_bytes)),
309
+ ])
310
+ else:
311
+ print(f" {len(results)} files, {_size_text(payload['total_bytes'])}")
312
+ for path, message in failures:
313
+ from infix_cli.render import text as text_render
314
+
315
+ text_render.print_error(f"Upload failed for {path}: {message}", no_color=run.no_color)
316
+ elif run.quiet:
317
+ for result in results:
318
+ print(result.remote_path)
319
+
320
+ if failures:
321
+ raise ApiError(
322
+ f"{len(failures)} of {len(results) + len(failures)} files failed to upload.",
323
+ )
324
+
325
+
326
+ def _size_text(size: int) -> str:
327
+ from infix_cli.domain.dto.common import format_bytes
328
+
329
+ return format_bytes(size)