1
1
import click
2
2
3
3
from paperspace import client , config
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 , ClickGroup
7
4
from paperspace .cli .cli import cli
5
+ from paperspace .cli .cli_types import json_string
6
+ from paperspace .cli .common import api_key_option , del_if_value_is_none , ClickGroup
8
7
from paperspace .commands import jobs as jobs_commands
9
8
10
9
@@ -20,7 +19,7 @@ def jobs_group():
20
19
required = True ,
21
20
help = "Delete job with given ID" ,
22
21
)
23
- @common . api_key_option
22
+ @api_key_option
24
23
def delete_job (job_id , api_key = None ):
25
24
jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
26
25
command = jobs_commands .DeleteJobCommand (api = jobs_api )
@@ -34,7 +33,7 @@ def delete_job(job_id, api_key=None):
34
33
required = True ,
35
34
help = "Stop job with given ID" ,
36
35
)
37
- @common . api_key_option
36
+ @api_key_option
38
37
def stop_job (job_id , api_key = None ):
39
38
jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
40
39
command = jobs_commands .StopJobCommand (api = jobs_api )
@@ -57,9 +56,9 @@ def stop_job(job_id, api_key=None):
57
56
"experimentId" ,
58
57
help = "Use to filter jobs by experiment ID" ,
59
58
)
60
- @common . api_key_option
59
+ @api_key_option
61
60
def list_jobs (api_key , ** filters ):
62
- common . del_if_value_is_none (filters )
61
+ del_if_value_is_none (filters )
63
62
jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
64
63
command = jobs_commands .ListJobsCommand (api = jobs_api )
65
64
command .execute (filters = filters )
@@ -75,7 +74,8 @@ def list_jobs(api_key, **filters):
75
74
@click .option ("--workspace" , "workspace" , required = False , help = "Path to workspace directory" )
76
75
@click .option ("--workspaceArchive" , "workspaceArchive" , required = False , help = "Path to workspace archive" )
77
76
@click .option ("--workspaceUrl" , "workspaceUrl" , required = False , help = "Project git repository url" )
78
- @click .option ("--workingDirectory" , "workingDirectory" , help = "Working directory for the experiment" , )
77
+ @click .option ("--workingDirectory" , "workingDirectory" , help = "Working directory for the experiment" )
78
+ @click .option ("--ignoreFiles" , "ignore_files" , help = "Ignore certain files from uploading" )
79
79
@click .option ("--experimentId" , "experimentId" , help = "Experiment Id" )
80
80
@click .option ("--jobEnv" , "envVars" , type = json_string , help = "Environmental variables " )
81
81
@click .option ("--useDockerfile" , "useDockerfile" , help = "Flag: using Dockerfile" )
@@ -86,7 +86,7 @@ def list_jobs(api_key, **filters):
86
86
@click .option ("--relDockerfilePath" , "relDockerfilePath" , help = "Relative path to Dockerfile" )
87
87
@click .option ("--registryUsername" , "registryUsername" , help = "Docker registry username" )
88
88
@click .option ("--registryPassword" , "registryPassword" , help = "Docker registry password" )
89
- @common . api_key_option
89
+ @api_key_option
90
90
def create_job (api_key , ** kwargs ):
91
91
del_if_value_is_none (kwargs )
92
92
jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
@@ -100,8 +100,44 @@ def create_job(api_key, **kwargs):
100
100
"job_id" ,
101
101
required = True
102
102
)
103
- @common . api_key_option
103
+ @api_key_option
104
104
def list_logs (job_id , api_key = None ):
105
105
logs_api = client .API (config .CONFIG_LOG_HOST , api_key = api_key )
106
106
command = jobs_commands .JobLogsCommand (api = logs_api )
107
107
command .execute (job_id )
108
+
109
+
110
+ @jobs_group .group ("artifacts" , help = "Manage jobs' artifacts" , cls = ClickGroup )
111
+ def artifacts ():
112
+ pass
113
+
114
+
115
+ @artifacts .command ("destroy" , help = "Destroy job's artifacts" )
116
+ @click .argument ("job_id" )
117
+ @click .option ("--files" , "files" )
118
+ @api_key_option
119
+ def destroy_artifacts (job_id , api_key = None , files = None ):
120
+ jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
121
+ command = jobs_commands .ArtifactsDestroyCommand (api = jobs_api )
122
+ command .execute (job_id , files = files )
123
+
124
+
125
+ @artifacts .command ("get" , help = "Get job's artifacts" )
126
+ @click .argument ("job_id" )
127
+ @api_key_option
128
+ def get_artifacts (job_id , api_key = None ):
129
+ jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
130
+ command = jobs_commands .ArtifactsGetCommand (api = jobs_api )
131
+ command .execute (job_id )
132
+
133
+
134
+ @artifacts .command ("list" , help = "List job's artifacts" )
135
+ @click .argument ("job_id" )
136
+ @click .option ("--size" , "-s" , "size" , help = "Show file size" , is_flag = True )
137
+ @click .option ("--links" , "-l" , "links" , help = "Show file URL" , is_flag = True )
138
+ @click .option ("--files" , "files" , help = "Get only given file (use at the end * as a wildcard)" )
139
+ @api_key_option
140
+ def list_artifacts (job_id , size , links , files , api_key = None ):
141
+ jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
142
+ command = jobs_commands .ArtifactsListCommand (api = jobs_api )
143
+ command .execute (job_id = job_id , size = size , links = links , files = files )
0 commit comments