|
2 | 2 |
|
3 | 3 | from paperspace import client, config |
4 | 4 | from paperspace.cli import common |
| 5 | +from paperspace.cli.cli_types import json_string |
| 6 | +from paperspace.cli.common import del_if_value_is_none |
5 | 7 | from paperspace.cli.cli import cli |
6 | 8 | from paperspace.commands import jobs as jobs_commands |
7 | 9 |
|
@@ -63,6 +65,35 @@ def list_jobs(api_key, **filters): |
63 | 65 | command.execute(filters) |
64 | 66 |
|
65 | 67 |
|
| 68 | +@jobs_group.command("create", help="Create job") |
| 69 | +@click.option("--name", "name", help="Job name", required=True) |
| 70 | +@click.option("--machineType", "machineType", help="Virtual machine type") |
| 71 | +@click.option("--container", "container", help="Docker container") |
| 72 | +@click.option("--command", "command", help="Job command/entrypoint") |
| 73 | +@click.option("--ports", "ports", help="Mapped ports") |
| 74 | +@click.option("--isPublic", "isPublic", help="Flag: is job public") |
| 75 | +@click.option("--workspace", "workspace", required=False, help="Path to workspace directory") |
| 76 | +@click.option("--workspaceArchive", "workspaceArchive", required=False, help="Path to workspace archive") |
| 77 | +@click.option("--workspaceUrl", "workspaceUrl", required=False, help="Project git repository url") |
| 78 | +@click.option("--workingDirectory", "workingDirectory", help="Working directory for the experiment", ) |
| 79 | +@click.option("--experimentId", "experimentId", help="Experiment Id") |
| 80 | +@click.option("--jobEnv", "envVars", type=json_string, help="Environmental variables ") |
| 81 | +@click.option("--useDockerfile", "useDockerfile", help="Flag: using Dockerfile") |
| 82 | +@click.option("--isPreemptible", "isPreemptible", help="Flag: isPreemptible") |
| 83 | +@click.option("--project", "project", help="Project name") |
| 84 | +@click.option("--projectHandle", "--projectId", "projectHandle", help="Project handle", required=True) |
| 85 | +@click.option("--startedByUserId", "startedByUserId", help="User ID") |
| 86 | +@click.option("--relDockerfilePath", "relDockerfilePath", help="Relative path to Dockerfile") |
| 87 | +@click.option("--registryUsername", "registryUsername", help="Docker registry username") |
| 88 | +@click.option("--registryPassword", "registryPassword", help="Docker registry password") |
| 89 | +@common.api_key_option |
| 90 | +def create_job(api_key, **kwargs): |
| 91 | + del_if_value_is_none(kwargs) |
| 92 | + jobs_api = client.API(config.CONFIG_HOST, api_key=api_key) |
| 93 | + command = jobs_commands.CreateJobCommand(api=jobs_api) |
| 94 | + command.execute(kwargs) |
| 95 | + |
| 96 | + |
66 | 97 | @jobs_group.command("log", help="List job logs") |
67 | 98 | @click.option( |
68 | 99 | "--jobId", |
|
0 commit comments