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,127 @@
1
+ """``infix resource`` — the hardware vocabulary accepted by create commands."""
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 import enums, resolve
11
+ from infix_cli.domain.dto.resource import ResourceDTO
12
+ from infix_cli.errors import UsageError
13
+
14
+ app = typer.Typer(help="Computing resources available for jobs.", no_args_is_help=True)
15
+
16
+ # PRD 3.4.4's closing lines. They carry the one thing the table cannot show:
17
+ # a row is *one worker's* hardware, and multi-node runs come from --workers
18
+ # rather than from some wider row further down the list.
19
+ _WORKERS_HINT = (
20
+ "Specify --workers to set the number of workers "
21
+ "(each uses the hardware spec above)."
22
+ )
23
+
24
+
25
+ @app.command("list")
26
+ def list_resources(
27
+ ctx: typer.Context,
28
+ task: Optional[str] = typer.Option(
29
+ None, "--task", help="training | spark | notebook | serving. Omit to list every task.",
30
+ ),
31
+ gpu_only: bool = typer.Option(False, "--gpu-only", help="Only list GPU hardware."),
32
+ available_only: bool = typer.Option(
33
+ False, "--available-only",
34
+ help="Hide hardware that cannot be scheduled right now (cluster or queue).",
35
+ ),
36
+ ) -> None:
37
+ """List hardware specs, named the way ``--hardware`` expects them."""
38
+ run = ctx.obj
39
+ if task is not None and task not in enums.RESOURCE_SCOPE.cli_values:
40
+ raise UsageError(
41
+ f'Invalid --task "{task}".',
42
+ f"Valid: {', '.join(enums.RESOURCE_SCOPE.cli_values)}.",
43
+ )
44
+ # Every task, not one merged list: each scope has its own spec rows, and the
45
+ # queue a spec is judged against is the task's, so a shared table would have
46
+ # to answer "available for what?" in a column nobody asked for.
47
+ tasks = [task] if task else list(enums.RESOURCE_SCOPE.cli_values)
48
+ client = run.client()
49
+
50
+ groups = [(name, _hardware_for(run, client, name, gpu_only, available_only))
51
+ for name in tasks]
52
+
53
+ if run.output == "json" or run.quiet:
54
+ _render_flat(run, [dto for _name, dtos in groups for dto in dtos])
55
+ return
56
+
57
+ for index, (name, dtos) in enumerate(groups):
58
+ render.render_list(
59
+ run, dtos, ResourceDTO.columns(),
60
+ # This endpoint returns everything at once; page fields stay null so
61
+ # the shape matches every other list without inventing pagination.
62
+ page=None, page_size=None, total=len(dtos),
63
+ quiet_field="hardware",
64
+ title=f"\nAvailable Hardware Specs ({name}):" if index else
65
+ f"Available Hardware Specs ({name}):",
66
+ empty_message=f"No hardware available for {name}.",
67
+ # One footer under the whole output, not one per section.
68
+ footer=_footer(tasks) if index == len(groups) - 1 else None,
69
+ )
70
+
71
+
72
+ def _hardware_for(
73
+ run, client, task: str, gpu_only: bool, available_only: bool,
74
+ ) -> list[ResourceDTO]:
75
+ # workload is what turns on the queue/capacity check behind `selectable`;
76
+ # without it the endpoint only reconciles against the cluster's GPU models
77
+ # and ignores workspace_id entirely.
78
+ specs = resolve.list_specs(
79
+ client,
80
+ enums.RESOURCE_SCOPE.to_backend(task),
81
+ workspace_id=run.profile.workspace_id,
82
+ workload=enums.RESOURCE_WORKLOAD.to_backend(task),
83
+ )
84
+ dtos = [
85
+ ResourceDTO.from_api(spec, task=task, hardware=resolve.spec_cli_name(spec))
86
+ for spec in resolve.dedupe_by_cli_name(specs)
87
+ ]
88
+ if gpu_only:
89
+ dtos = [d for d in dtos if d.kind == "gpu"]
90
+ if available_only:
91
+ dtos = [d for d in dtos if d.available]
92
+ dtos.sort(key=lambda d: (d.kind != "gpu", d.hardware))
93
+ return dtos
94
+
95
+
96
+ def _render_flat(run, dtos: list[ResourceDTO]) -> None:
97
+ """JSON and quiet output stay one stream: they are parsed, not read.
98
+
99
+ Each row carries its ``scope``, so the sections a reader gets from headings
100
+ a script gets from the field — except in quiet mode, which emits bare names
101
+ and would otherwise repeat the ones several tasks share.
102
+ """
103
+ if run.quiet and run.output != "json":
104
+ seen: set[str] = set()
105
+ for dto in dtos:
106
+ if dto.hardware not in seen:
107
+ seen.add(dto.hardware)
108
+ print(dto.hardware)
109
+ return
110
+ render.render_list(
111
+ run, dtos, ResourceDTO.columns(),
112
+ page=None, page_size=None, total=len(dtos),
113
+ quiet_field="hardware",
114
+ )
115
+
116
+
117
+ def _footer(tasks: list[str]) -> str:
118
+ # "a training job" only reads right when training is what was asked for.
119
+ if tasks == ["serving"]:
120
+ # A service scales by replicas, not workers.
121
+ return (
122
+ "\nUse --hardware <HARDWARE> when creating a model service.\n"
123
+ "Specify --replicas to set the number of replicas "
124
+ "(each uses the hardware spec above)."
125
+ )
126
+ subject = f"a {tasks[0]} job" if len(tasks) == 1 else "a job"
127
+ return f"\nUse --hardware <HARDWARE> when creating {subject}.\n{_WORKERS_HINT}"
@@ -0,0 +1,347 @@
1
+ """``infix spark`` — Spark data-processing jobs (read-only in this phase)."""
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.commands import _control, _create, _delete, _jobs, _logs, _publish
11
+ from infix_cli.domain import enums, resolve
12
+ from infix_cli.domain.dto.spark import SparkJobDTO
13
+ from infix_cli.http.pagination import fetch_page, iter_items, slice_page
14
+
15
+ app = typer.Typer(help="Spark data processing jobs.", no_args_is_help=True)
16
+
17
+
18
+ @app.command("list")
19
+ def list_jobs(
20
+ ctx: typer.Context,
21
+ status: Optional[str] = typer.Option(None, "--status", help="Filter by job status."),
22
+ search: Optional[str] = typer.Option(None, "--search", help="Fuzzy name match."),
23
+ visibility: Optional[str] = typer.Option(
24
+ None, "--visibility", help="private | public",
25
+ ),
26
+ page: int = typer.Option(1, "--page", "-p", min=1),
27
+ page_size: int = typer.Option(None, "--page-size", min=1, max=50),
28
+ ) -> None:
29
+ """List Spark jobs in the current workspace."""
30
+ run = ctx.obj
31
+ size = run.default_page_size(page_size)
32
+ # data-processing exposes neither ?status= nor ?visibility=, so both are
33
+ # applied here. Filtering has to see every job before it can page: applied
34
+ # to one already-fetched page it silently drops matches that sit further
35
+ # down, and the count then moves with --page-size instead of describing
36
+ # the workspace. So a filtered listing walks the endpoint and pages locally.
37
+ wanted = _jobs.validate_status("spark", status)
38
+ wanted_visibility = _jobs.validate_visibility(visibility)
39
+ namer = resolve.HardwareNamer(run.client(), "spark")
40
+
41
+ if wanted or wanted_visibility:
42
+ dtos = [
43
+ SparkJobDTO.from_api(raw, hardware=_hardware_name(namer, raw))
44
+ for raw in iter_items(run.client(), "/data-processing/", params={"search": search})
45
+ ]
46
+ if wanted:
47
+ dtos = [d for d in dtos if d.status == wanted.lower()]
48
+ if wanted_visibility:
49
+ dtos = [d for d in dtos if d.visibility == wanted_visibility.lower()]
50
+ render.render_list(
51
+ run, slice_page(dtos, page, size), SparkJobDTO.columns(),
52
+ page=page, page_size=size, total=len(dtos),
53
+ empty_message="No matching Spark jobs found.",
54
+ )
55
+ return
56
+
57
+ items, page_no, size, total = fetch_page(
58
+ run.client(), "/data-processing/", params={"search": search},
59
+ page=page, page_size=size,
60
+ )
61
+ dtos = [SparkJobDTO.from_api(raw, hardware=_hardware_name(namer, raw)) for raw in items]
62
+ render.render_list(
63
+ run, dtos, SparkJobDTO.columns(),
64
+ page=page_no, page_size=size, total=total,
65
+ empty_message="No Spark jobs found.",
66
+ )
67
+
68
+
69
+ @app.command("get")
70
+ def get_job(
71
+ ctx: typer.Context,
72
+ name: str = typer.Argument(..., help="Job name (or id)."),
73
+ ) -> None:
74
+ """Show one Spark job in detail.
75
+
76
+ A successful query exits 0; the job outcome is in the status field.
77
+ """
78
+ run = ctx.obj
79
+ client = run.client()
80
+ job = resolve.find_job(client, "spark", name)
81
+ detail = client.get(f"/data-processing/{job['id']}")
82
+ raw = detail if isinstance(detail, dict) else job
83
+ namer = resolve.HardwareNamer(client, "spark")
84
+ dto = SparkJobDTO.from_api(raw, detail=True, hardware=_hardware_name(namer, raw))
85
+ render.render_detail(run, dto)
86
+
87
+
88
+ @app.command("create")
89
+ def create_job(
90
+ ctx: typer.Context,
91
+ name: Optional[str] = typer.Option(None, "--name", "-n", help="Job name (3-50 chars).", rich_help_panel="Required"),
92
+ dataset: list[str] = typer.Option(
93
+ [], "--dataset",
94
+ help="workspace/<name>[:<version>] | storage/<path>. Repeatable — spark takes several.",
95
+ rich_help_panel="Required",
96
+ ),
97
+ code: Optional[str] = typer.Option(
98
+ None, "--code", help="workspace/<name>[:<version>] | storage/<path>", rich_help_panel="Required",
99
+ ),
100
+ main_script: Optional[str] = typer.Option(
101
+ None, "--main-script",
102
+ help="Path to the entry script inside the container. Code mounts at "
103
+ "/mnt/code/<name>/ — both asset and storage sources.",
104
+ rich_help_panel="Required",
105
+ ),
106
+ args: Optional[str] = typer.Option(None, "--args", help="Arguments passed to the script."),
107
+ spark_conf: list[str] = typer.Option(
108
+ [], "--spark-conf", help="Spark setting as key=value. Repeatable.",
109
+ ),
110
+ image: Optional[str] = typer.Option(None, "--image", help="Container image."),
111
+ hardware: Optional[str] = typer.Option(
112
+ None, "--hardware", help='Hardware name from "infix resource list --task spark".', rich_help_panel="Required",
113
+ ),
114
+ workers: Optional[int] = typer.Option(None, "--workers", min=1),
115
+ input_format: Optional[str] = typer.Option(None, "--input-format"),
116
+ output_path: Optional[str] = typer.Option(None, "--output-path"),
117
+ visibility: Optional[str] = typer.Option(None, "--visibility", help="private | public"),
118
+ config: Optional[str] = typer.Option(
119
+ None, "--config", help="JSON file of the same options. Task flags cannot be combined with --config. Use - for stdin.",
120
+ ),
121
+ wait: bool = typer.Option(False, "--wait"),
122
+ timeout: Optional[str] = typer.Option(None, "--timeout", help="e.g. 30m, 6h."),
123
+ dry_run: bool = typer.Option(False, "--dry-run", help="Resolve and validate inputs without submitting a job."),
124
+ ) -> None:
125
+ """Submit a Spark data-processing job.
126
+
127
+ Examples:
128
+
129
+ infix spark create -n etl-preprocess --dataset workspace/raw-dialogue:v1.0.0
130
+ --code workspace/etl-scripts --main-script /mnt/code/etl-scripts/main.py
131
+ --hardware cpu_16c_64gb --workers 4 --wait
132
+
133
+ infix spark create --config etl.json
134
+ """
135
+ run = ctx.obj
136
+ cfg = _create.load_config(config)
137
+ pick = _create.pick
138
+
139
+ name = pick(name, cfg, "name", required=True, flag="--name")
140
+ dataset_refs = pick(list(dataset), cfg, "dataset", required=True, flag="--dataset")
141
+ if isinstance(dataset_refs, str):
142
+ dataset_refs = [dataset_refs]
143
+ code_ref = pick(code, cfg, "code", required=True, flag="--code")
144
+ main_script = pick(main_script, cfg, "main_script", required=True, flag="--main-script")
145
+ hardware = pick(hardware, cfg, "hardware", required=True, flag="--hardware")
146
+ workers = int(pick(workers, cfg, "workers", default=1))
147
+ args = pick(args, cfg, "args")
148
+ image = pick(image, cfg, "image")
149
+ input_format = pick(input_format, cfg, "input_format")
150
+ output_path = pick(output_path, cfg, "output_path")
151
+ visibility = pick(visibility, cfg, "visibility", default="private")
152
+ conf = _create.parse_key_values(list(spark_conf) or _conf_from_config(cfg), flag="--spark-conf")
153
+
154
+ client = run.client()
155
+ dataset_slots = [
156
+ _create.resolve_slot(client, ref, kind="dataset", flag="--dataset", check_storage=dry_run)
157
+ for ref in dataset_refs
158
+ ]
159
+ code_slot = _create.resolve_slot(client, code_ref, kind="code", flag="--code", check_storage=dry_run)
160
+ resources = resolve.resolve_spark_resource(client, hardware, workers)
161
+ namer = resolve.HardwareNamer(client, "spark")
162
+
163
+ payload = _create.spark_payload(
164
+ name=name, datasets=dataset_slots, code=code_slot, main_script=main_script,
165
+ resources=resources, args=args, spark_conf=conf, image=image,
166
+ input_format=input_format, output_path=output_path, visibility=visibility,
167
+ )
168
+ _jobs.submit_and_report(
169
+ run, "spark",
170
+ echo={"datasets": ", ".join(dataset_refs)},
171
+ path="/data-processing/", payload=payload,
172
+ detail_path=lambda job_id: f"/data-processing/{job_id}",
173
+ build_dto=lambda raw: SparkJobDTO.from_api(
174
+ raw, detail=True, hardware=_hardware_name(namer, raw),
175
+ ),
176
+ wait=wait, timeout=timeout, dry_run=dry_run,
177
+ )
178
+
179
+
180
+ def _hardware_name(namer, raw: dict) -> str | None:
181
+ """Look the job's flat resource numbers back up in the spec catalogue.
182
+
183
+ Without this the name shown (and written by `clone`) is derived locally and
184
+ does not match what `--hardware` accepts for GPU specs, so a cloned config
185
+ fails to submit.
186
+ """
187
+ return namer.by_resources(
188
+ cpu_cores=int(raw.get("cpu_per_worker") or 0),
189
+ memory_gb=int(raw.get("memory_per_worker") or 0),
190
+ gpu_count=int(raw.get("gpu_per_worker") or 0),
191
+ )
192
+
193
+
194
+ def _conf_from_config(cfg: dict) -> list[str]:
195
+ raw = cfg.get("spark_conf") or {}
196
+ if isinstance(raw, dict):
197
+ return [f"{key}={value}" for key, value in raw.items()]
198
+ return list(raw)
199
+
200
+
201
+ @app.command("logs")
202
+ def job_logs(
203
+ ctx: typer.Context,
204
+ name: str = typer.Argument(..., help="Job name (or id)."),
205
+ worker: Optional[str] = typer.Option(
206
+ None, "--worker", help="Specific pod. Defaults to driver plus executors.",
207
+ ),
208
+ tail: int = typer.Option(500, "--tail", min=1, max=10000, help="Lines per pod."),
209
+ keyword: Optional[str] = typer.Option(
210
+ None, "--keyword", help="Filter locally, within the --tail lines only.",
211
+ ),
212
+ follow: bool = typer.Option(False, "--follow", "-f", help="Stream until interrupted."),
213
+ download: Optional[str] = typer.Option(None, "--download", help="Write to this file."),
214
+ ) -> None:
215
+ """Read a Spark job's logs (driver and executors)."""
216
+ run = ctx.obj
217
+ client = run.client()
218
+ job_id = str(resolve.find_job(client, "spark", name)["id"])
219
+
220
+ if download:
221
+ _logs.download(run, "spark", job_id, worker=worker, tail=tail, dest=download)
222
+ return
223
+ seed = _logs.fetch(client, "spark", job_id, worker=worker, tail=tail)
224
+ if follow:
225
+ _logs.follow(
226
+ run,
227
+ lambda since: _logs.stream_once(client, "spark", job_id, worker=worker, since=since),
228
+ keyword=keyword, seed=seed,
229
+ )
230
+ return
231
+ _logs.render(run, seed, keyword=keyword)
232
+
233
+
234
+ @app.command("stop")
235
+ def stop_job(
236
+ ctx: typer.Context,
237
+ name: str = typer.Argument(..., help="Job name (or id)."),
238
+ ) -> None:
239
+ """Stop a Spark job."""
240
+ run = ctx.obj
241
+ job = resolve.find_job(run.client(), "spark", name)
242
+ updated = _control.stop(run, "spark", job)
243
+ status = enums.status_to_cli(updated.get("status")) or "stopped"
244
+ render.message(run, f'Spark job "{job.get("name")}" is now {status}.')
245
+
246
+
247
+ @app.command("restart")
248
+ def restart_job(
249
+ ctx: typer.Context,
250
+ name: str = typer.Argument(..., help="Job name (or id)."),
251
+ wait: bool = typer.Option(False, "--wait"),
252
+ timeout: Optional[str] = typer.Option(None, "--timeout", help="e.g. 30m, 6h."),
253
+ ) -> None:
254
+ """Resubmit a Spark job."""
255
+ run = ctx.obj
256
+ client = run.client()
257
+ job = resolve.find_job(client, "spark", name)
258
+ _control.restart(run, "spark", job)
259
+ job_id = str(job["id"])
260
+ namer = resolve.HardwareNamer(client, "spark")
261
+ _jobs.report_existing(
262
+ run, "spark", job_id=job_id, name=str(job.get("name") or job_id),
263
+ detail_path=lambda jid: f"/data-processing/{jid}",
264
+ build_dto=lambda raw: SparkJobDTO.from_api(
265
+ raw, detail=True, hardware=_hardware_name(namer, raw),
266
+ ),
267
+ wait=wait, timeout=timeout,
268
+ )
269
+
270
+
271
+ @app.command("wait")
272
+ def wait_job(
273
+ ctx: typer.Context,
274
+ name: str = typer.Argument(..., help="Job name (or id)."),
275
+ timeout: Optional[str] = typer.Option(None, "--timeout", help="e.g. 30m, 6h. Default: 30s."),
276
+ ) -> None:
277
+ """Wait for a Spark job to finish; exit 0 on success, 7 on failure, 6 on timeout.
278
+
279
+ For re-attaching after an interrupted --wait. Ctrl-C stops waiting only;
280
+ the job keeps running.
281
+ """
282
+ run = ctx.obj
283
+ client = run.client()
284
+ job = resolve.find_job(client, "spark", name)
285
+ job_id = str(job["id"])
286
+ namer = resolve.HardwareNamer(client, "spark")
287
+ _jobs.wait_existing(
288
+ run, "spark", job_id=job_id, name=str(job.get("name") or job_id),
289
+ detail_path=lambda jid: f"/data-processing/{jid}",
290
+ build_dto=lambda raw: SparkJobDTO.from_api(
291
+ raw, detail=True, hardware=_hardware_name(namer, raw),
292
+ ),
293
+ timeout=timeout,
294
+ )
295
+
296
+
297
+ @app.command("publish")
298
+ def publish_job(
299
+ ctx: typer.Context,
300
+ name: str = typer.Argument(..., help="Job name (or id)."),
301
+ yes: bool = typer.Option(False, "--yes", "-y", help="Do not ask for confirmation."),
302
+ ) -> None:
303
+ """Make a Spark job public to the workspace. This cannot be undone.
304
+
305
+ Its output directory is shared along with it.
306
+ """
307
+ _publish.publish_job(ctx.obj, "spark", name, yes=yes)
308
+
309
+
310
+ @app.command("delete")
311
+ def delete_job(
312
+ ctx: typer.Context,
313
+ name: str = typer.Argument(..., help="Job name (or id)."),
314
+ force: bool = typer.Option(
315
+ False, "--force", help="Delete even if the job is still queued or running.",
316
+ ),
317
+ yes: bool = typer.Option(False, "--yes", "-y", help="Do not ask for confirmation."),
318
+ ) -> None:
319
+ """Delete a Spark job. This cannot be undone.
320
+
321
+ The output directory stays in Workspace Storage.
322
+ A job that has not finished is refused unless --force is given.
323
+ """
324
+ _delete.delete_job(ctx.obj, "spark", name, force=force, yes=yes)
325
+
326
+
327
+ @app.command("clone")
328
+ def clone_job(
329
+ ctx: typer.Context,
330
+ name: str = typer.Argument(..., help="Job to copy the configuration from."),
331
+ new_name: Optional[str] = typer.Option(
332
+ None, "--name", help="Name for the new job. Default: <original>-clone-1.",
333
+ ),
334
+ save: Optional[str] = typer.Option(None, "--save", help="Write to this file."),
335
+ ) -> None:
336
+ """Print a job's configuration as a create --config file."""
337
+ run = ctx.obj
338
+ client = run.client()
339
+ job = resolve.find_job(client, "spark", name)
340
+ detail = client.get(f"/data-processing/{job['id']}")
341
+ raw = detail if isinstance(detail, dict) else job
342
+ namer = resolve.HardwareNamer(client, "spark")
343
+ dto = SparkJobDTO.from_api(raw, detail=True, hardware=_hardware_name(namer, raw))
344
+ _control.emit_clone(
345
+ run, _control.spark_config(dto, _control.clone_name(dto, new_name), client=client),
346
+ save=save, module="spark",
347
+ )