Skip to content

Commit d0044b5

Browse files
authored
Add datachain job run --repository (#1074)
1 parent 737155d commit d0044b5

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

docs/commands/job/run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ datachain job run --workers 4 --files utils.py config.json query.py
6060
datachain job run --env API_KEY=123 --req pandas numpy query.py
6161
```
6262

63+
6. Run a job with a repository (will be cloned in the job working directory):
64+
```bash
65+
datachain job run --repository https://github.com/iterative/datachain query.py
66+
```
67+
6368
## Notes
6469

6570
* Closing the logs command (e.g., with Ctrl+C) will only stop displaying the logs but will not cancel the job execution

file

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
date

src/datachain/cli/parser/job.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def add_jobs_parser(subparsers, parent_parser) -> None:
1313
)
1414
jobs_subparser = jobs_parser.add_subparsers(
1515
dest="cmd",
16-
help="Use `datachain auth CMD --help` to display command-specific help",
16+
help="Use `datachain job CMD --help` to display command-specific help",
1717
)
1818

1919
studio_run_help = "Run a job in Studio"
@@ -66,6 +66,11 @@ def add_jobs_parser(subparsers, parent_parser) -> None:
6666
action="store",
6767
help="Python version for the job (e.g., 3.9, 3.10, 3.11)",
6868
)
69+
studio_run_parser.add_argument(
70+
"--repository",
71+
action="store",
72+
help="Repository URL to clone before running the job",
73+
)
6974
studio_run_parser.add_argument(
7075
"--req-file",
7176
action="store",

src/datachain/remote/studio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ def create_job(
387387
files: Optional[list[str]] = None,
388388
python_version: Optional[str] = None,
389389
requirements: Optional[str] = None,
390+
repository: Optional[str] = None,
390391
) -> Response[JobData]:
391392
data = {
392393
"query": query,
@@ -397,6 +398,7 @@ def create_job(
397398
"files": files,
398399
"python_version": python_version,
399400
"requirements": requirements,
401+
"repository": repository,
400402
}
401403
return self._send_request("datachain/job", data)
402404

src/datachain/studio.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def process_jobs_args(args: "Namespace"):
3535
args.workers,
3636
args.files,
3737
args.python_version,
38+
args.repository,
3839
args.req,
3940
args.req_file,
4041
)
@@ -256,6 +257,7 @@ def create_job(
256257
workers: Optional[int] = None,
257258
files: Optional[list[str]] = None,
258259
python_version: Optional[str] = None,
260+
repository: Optional[str] = None,
259261
req: Optional[list[str]] = None,
260262
req_file: Optional[str] = None,
261263
):
@@ -284,6 +286,7 @@ def create_job(
284286
query_name=os.path.basename(query_file),
285287
files=file_ids,
286288
python_version=python_version,
289+
repository=repository,
287290
requirements=requirements,
288291
)
289292
if not response.ok:

tests/test_cli_studio.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ def test_studio_run(capsys, mocker, tmp_dir):
381381
"reqs.txt",
382382
"--req",
383383
"stupidity",
384+
"--repository",
385+
"https://github.com/iterative/datachain",
384386
]
385387
)
386388
== 0
@@ -417,4 +419,5 @@ def test_studio_run(capsys, mocker, tmp_dir):
417419
"python_version": "3.12",
418420
"requirements": "pyjokes\nstupidity",
419421
"team_name": "team_name",
422+
"repository": "https://github.com/iterative/datachain",
420423
}

0 commit comments

Comments
 (0)