11import click
22
33from 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
74from 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
87from paperspace .commands import jobs as jobs_commands
98
109
@@ -20,7 +19,7 @@ def jobs_group():
2019 required = True ,
2120 help = "Delete job with given ID" ,
2221)
23- @common . api_key_option
22+ @api_key_option
2423def delete_job (job_id , api_key = None ):
2524 jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
2625 command = jobs_commands .DeleteJobCommand (api = jobs_api )
@@ -34,7 +33,7 @@ def delete_job(job_id, api_key=None):
3433 required = True ,
3534 help = "Stop job with given ID" ,
3635)
37- @common . api_key_option
36+ @api_key_option
3837def stop_job (job_id , api_key = None ):
3938 jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
4039 command = jobs_commands .StopJobCommand (api = jobs_api )
@@ -57,9 +56,9 @@ def stop_job(job_id, api_key=None):
5756 "experimentId" ,
5857 help = "Use to filter jobs by experiment ID" ,
5958)
60- @common . api_key_option
59+ @api_key_option
6160def list_jobs (api_key , ** filters ):
62- common . del_if_value_is_none (filters )
61+ del_if_value_is_none (filters )
6362 jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
6463 command = jobs_commands .ListJobsCommand (api = jobs_api )
6564 command .execute (filters = filters )
@@ -75,7 +74,8 @@ def list_jobs(api_key, **filters):
7574@click .option ("--workspace" , "workspace" , required = False , help = "Path to workspace directory" )
7675@click .option ("--workspaceArchive" , "workspaceArchive" , required = False , help = "Path to workspace archive" )
7776@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" )
7979@click .option ("--experimentId" , "experimentId" , help = "Experiment Id" )
8080@click .option ("--jobEnv" , "envVars" , type = json_string , help = "Environmental variables " )
8181@click .option ("--useDockerfile" , "useDockerfile" , help = "Flag: using Dockerfile" )
@@ -86,7 +86,7 @@ def list_jobs(api_key, **filters):
8686@click .option ("--relDockerfilePath" , "relDockerfilePath" , help = "Relative path to Dockerfile" )
8787@click .option ("--registryUsername" , "registryUsername" , help = "Docker registry username" )
8888@click .option ("--registryPassword" , "registryPassword" , help = "Docker registry password" )
89- @common . api_key_option
89+ @api_key_option
9090def create_job (api_key , ** kwargs ):
9191 del_if_value_is_none (kwargs )
9292 jobs_api = client .API (config .CONFIG_HOST , api_key = api_key )
@@ -100,8 +100,44 @@ def create_job(api_key, **kwargs):
100100 "job_id" ,
101101 required = True
102102)
103- @common . api_key_option
103+ @api_key_option
104104def list_logs (job_id , api_key = None ):
105105 logs_api = client .API (config .CONFIG_LOG_HOST , api_key = api_key )
106106 command = jobs_commands .JobLogsCommand (api = logs_api )
107107 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