Skip to content

Commit 640faa4

Browse files
committed
updating client to not have option to export to file, no longer supported by Singularity (tar stream/pipe only supported option)
1 parent 95c6951 commit 640faa4

File tree

4 files changed

+7
-32
lines changed

4 files changed

+7
-32
lines changed

docs/cli/run_singularity/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ Execute assumes that you want the output, and by default returns it.
136136

137137
## Export
138138

139-
Here you can export an image. The default export_type="tar", pipe=False, and output_file = None. Not specifying an output file will produce file in a temporary directory:
139+
Here you can export an image. The default export_type="tar", and it must be a pipe.
140140

141141
```python
142-
tmptar = S.export(image_path=image)
142+
S.export(image_path=image)
143143
```
144144

145-
You might want an in memory tar to work with, and if this is the case, you want a function from the [reproduce.py](../../singularity/reproduce.py) module:
145+
This is going to pipe the image into your stdout, which you probably don't want to do. Instead, you might want an in memory tar to work with, and if this is the case, you want a function from the [reproduce.py](../../singularity/reproduce.py) module:
146146

147147
```python
148148
from singularity.reproduce import get_memory_tar

docs/cli/run_singularity/singularity_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
S.help(command="exec")
4040

4141
# export an image as a byte array
42-
byte_array = S.export(image,pipe=True)
42+
byte_array = S.export(image)
4343

4444
# Get an in memory tar
4545
from singularity.reproduce import get_memory_tar

singularity/cli.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,9 @@ def execute(self,image_path,command,writable=False,contain=False):
172172

173173

174174

175-
def export(self,image_path,pipe=False,output_file=None,export_format="tar"):
175+
def export(self,image_path,export_format="tar"):
176176
'''export will export an image, sudo must be used.
177177
:param image_path: full path to image
178-
:param pipe: export to pipe and not file (default, False)
179-
:param output_file: if pipe=False, export tar to this file. If not specified,
180178
will generate temporary directory.
181179
:param export_format: the export format (only tar currently supported)
182180
'''
@@ -186,31 +184,8 @@ def export(self,image_path,pipe=False,output_file=None,export_format="tar"):
186184
print("Currently only supported export format is tar.")
187185
return None
188186

189-
# If the user has specified export to pipe, we don't need a file
190-
if pipe == True:
191-
cmd.append(image_path)
192-
else:
193-
_,tmptar = tempfile.mkstemp(suffix=".%s" %export_format)
194-
os.remove(tmptar)
195-
cmd = cmd + ['-f',tmptar,image_path]
196-
self.run_command(cmd,sudo=False)
197-
198-
# Was there an error?
199-
if not os.path.exists(tmptar):
200-
print('Error generating image tar')
201-
return None
202-
203-
# if user has specified output file, move it there, return path
204-
if output_file is not None:
205-
shutil.copyfile(tmptar,output_file)
206-
return output_file
207-
else:
208-
return tmptar
209-
210-
# Otherwise, return output of pipe
187+
cmd.append(image_path)
211188
output = self.run_command(cmd,sudo=False)
212-
if pipe is False:
213-
self.println(output)
214189
return output
215190

216191

singularity/reproduce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def get_memory_tar(image_path):
510510
cli = Singularity()
511511
if "pancakes" in os.environ:
512512
del os.environ['pancakes']
513-
byte_array = cli.export(image_path,pipe=True)
513+
byte_array = cli.export(image_path)
514514
file_object = io.BytesIO(byte_array)
515515
tar = tarfile.open(mode="r|*", fileobj=file_object)
516516
return (file_object,tar)

0 commit comments

Comments
 (0)