|
| 1 | +import functools |
| 2 | + |
1 | 3 | import click |
2 | 4 |
|
3 | 5 | from paperspace import client, config |
@@ -64,28 +66,35 @@ def list_jobs(api_key, **filters): |
64 | 66 | command.execute(filters=filters) |
65 | 67 |
|
66 | 68 |
|
| 69 | +def common_jobs_create_options(f): |
| 70 | + options = [ |
| 71 | + click.option("--name", "name", help="Job name", required=True), |
| 72 | + click.option("--machineType", "machineType", help="Virtual machine type"), |
| 73 | + click.option("--container", "container", default="paperspace/tensorflow-python", help="Docker container"), |
| 74 | + click.option("--command", "command", help="Job command/entrypoint"), |
| 75 | + click.option("--ports", "ports", help="Mapped ports"), |
| 76 | + click.option("--isPublic", "isPublic", help="Flag: is job public"), |
| 77 | + click.option("--workspace", "workspace", required=False, help="Path to workspace directory"), |
| 78 | + click.option("--workspaceArchive", "workspaceArchive", required=False, help="Path to workspace archive"), |
| 79 | + click.option("--workspaceUrl", "workspaceUrl", required=False, help="Project git repository url"), |
| 80 | + click.option("--workingDirectory", "workingDirectory", help="Working directory for the experiment", ), |
| 81 | + click.option("--ignoreFiles", "ignore_files", help="Ignore certain files from uploading"), |
| 82 | + click.option("--experimentId", "experimentId", help="Experiment Id"), |
| 83 | + click.option("--jobEnv", "envVars", type=json_string, help="Environmental variables "), |
| 84 | + click.option("--useDockerfile", "useDockerfile", help="Flag: using Dockerfile"), |
| 85 | + click.option("--isPreemptible", "isPreemptible", help="Flag: isPreemptible"), |
| 86 | + click.option("--project", "project", help="Project name"), |
| 87 | + click.option("--projectId", "projectHandle", help="Project ID"), |
| 88 | + click.option("--startedByUserId", "startedByUserId", help="User ID"), |
| 89 | + click.option("--relDockerfilePath", "relDockerfilePath", help="Relative path to Dockerfile"), |
| 90 | + click.option("--registryUsername", "registryUsername", help="Docker registry username"), |
| 91 | + click.option("--registryPassword", "registryPassword", help="Docker registry password"), |
| 92 | + ] |
| 93 | + return functools.reduce(lambda x, opt: opt(x), reversed(options), f) |
| 94 | + |
| 95 | + |
67 | 96 | @jobs_group.command("create", help="Create job") |
68 | | -@click.option("--name", "name", help="Job name", required=True) |
69 | | -@click.option("--machineType", "machineType", help="Virtual machine type") |
70 | | -@click.option("--container", "container", help="Docker container") |
71 | | -@click.option("--command", "command", help="Job command/entrypoint") |
72 | | -@click.option("--ports", "ports", help="Mapped ports") |
73 | | -@click.option("--isPublic", "isPublic", help="Flag: is job public") |
74 | | -@click.option("--workspace", "workspace", required=False, help="Path to workspace directory") |
75 | | -@click.option("--workspaceArchive", "workspaceArchive", required=False, help="Path to workspace archive") |
76 | | -@click.option("--workspaceUrl", "workspaceUrl", required=False, help="Project git repository url") |
77 | | -@click.option("--workingDirectory", "workingDirectory", help="Working directory for the experiment") |
78 | | -@click.option("--ignoreFiles", "ignore_files", help="Ignore certain files from uploading") |
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("--projectId", "projectHandle", help="Project ID", 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") |
| 97 | +@common_jobs_create_options |
89 | 98 | @api_key_option |
90 | 99 | @click.pass_context |
91 | 100 | def create_job(ctx, api_key, **kwargs): |
|
0 commit comments