@@ -103,7 +103,7 @@ def image_cli():
103103
104104@image_cli .command (
105105 help = "Build a compute engine as a Docker image, optionally generating an "
106- "Application Package"
106+ "Application Package"
107107)
108108@click .option (
109109 "-b" ,
@@ -119,7 +119,7 @@ def image_cli():
119119 help = "Conda environment file to use in Docker image. "
120120 "If no environment file is specified here or in the notebook, and if "
121121 "there is no file named environment.yml in the notebook's directory, "
122- "xcetool will try to reproduce the current environment."
122+ "xcetool will try to reproduce the current environment." ,
123123)
124124@click .option (
125125 "-t" ,
@@ -147,10 +147,12 @@ def build(
147147) -> None :
148148 if environment is None :
149149 LOGGER .info ("No environment file specified on command line." )
150+
150151 class InitArgs (TypedDict ):
151152 notebook : pathlib .Path
152153 environment : pathlib .Path
153154 tag : str
155+
154156 init_args = InitArgs (notebook = notebook , environment = environment , tag = tag )
155157 if build_dir :
156158 image_builder = ImageBuilder (build_dir = build_dir , ** init_args )
@@ -163,9 +165,11 @@ class InitArgs(TypedDict):
163165 )
164166 image = image_builder .build ()
165167 if eoap :
168+
166169 class IndentDumper (yaml .Dumper ):
167170 def increase_indent (self , flow = False , indentless = False ):
168171 return super (IndentDumper , self ).increase_indent (flow , False )
172+
169173 eoap .write_text (
170174 yaml .dump (
171175 image_builder .create_cwl (),
@@ -176,7 +180,14 @@ def increase_indent(self, flow=False, indentless=False):
176180 print (f"Built image with tags { image .tags } " )
177181
178182
179- @image_cli .command (help = "Run a compute engine image as a Docker container." )
183+ @image_cli .command (
184+ help = "Run a compute engine image as a Docker container. "
185+ "Any arguments provided after IMAGE will be passed on to the command "
186+ "executed inside the container." ,
187+ context_settings = dict (
188+ ignore_unknown_options = True ,
189+ ),
190+ )
180191@click .option (
181192 "-b" ,
182193 "--batch" ,
@@ -213,6 +224,12 @@ def increase_indent(self, flow=False, indentless=False):
213224 help = "Keep container after it has finished running." ,
214225)
215226@click .argument ("image" , type = str )
227+ @click .argument (
228+ "script_args" ,
229+ nargs = - 1 ,
230+ type = click .UNPROCESSED ,
231+ metavar = "[CONTAINER_ARGUMENT]..." ,
232+ )
216233@click .pass_context
217234def run (
218235 ctx : click .Context ,
@@ -223,6 +240,7 @@ def run(
223240 keep : bool ,
224241 image : str ,
225242 output : pathlib .Path ,
243+ script_args ,
226244) -> None :
227245 runner = ContainerRunner (image = image , output_dir = output )
228246 port_specified_explicitly = (
@@ -243,4 +261,5 @@ def run(
243261 host_port = actual_port ,
244262 from_saved = from_saved ,
245263 keep = keep ,
264+ script_args = list (script_args ),
246265 )
0 commit comments