77
88
99def parse_args ():
10- parser = argparse .ArgumentParser (description = 'Tool to save docker images from a cwl workflow \n '
11- 'and generate udocker loading commands.' )
10+ parser = argparse .ArgumentParser (
11+ description = 'Tool to save docker images from a cwl workflow \n '
12+ 'and generate udocker loading commands.' )
1213 parser .add_argument ('dir' , help = 'Directory in which to save images' )
1314 parser .add_argument ('input' , help = 'Input CWL workflow' )
1415 return parser .parse_args ()
@@ -36,8 +37,17 @@ def load_docker_image(image_name):
3637
3738
3839def save_docker_image (req , image_name , image_dir ):
39- cmd = ['docker' , 'save' , '-o' , os .path .join (image_dir , image_name ), req ]
40- subprocess .run (" " .join (cmd ), shell = True , check = True )
40+ cmd_pull = ['docker' , 'pull' , req ]
41+ try :
42+ subprocess .run (cmd_pull , check = True , stdout = subprocess .PIPE ,
43+ stderr = subprocess .STDOUT )
44+ except subprocess .CalledProcessError as err :
45+ if err .output :
46+ raise subprocess .SubprocessError (err .output )
47+ raise err
48+ cmd_save = ['docker' , 'save' , '-o' , os .path .join (image_dir , image_name ),
49+ req ]
50+ subprocess .run (cmd_save , check = True )
4151
4252
4353def extract_docker_requirements (process : cwl .Process ):
@@ -59,12 +69,6 @@ def extract_docker_reqs(process: cwl.Process):
5969 process .id , process .loadingOptions )
6070
6171
62- def process_docker_requirement (req : cwl .SoftwarePackage ):
63- if ':' not in req .dockerPull :
64- req .dockerPull += ':latest'
65- return req .dockerPull
66-
67-
6872def traverse (process : cwl .Process ):
6973 yield from extract_docker_requirements (process )
7074 if isinstance (process , cwl .Workflow ):
0 commit comments