Skip to content

Commit fd621c4

Browse files
committed
testing adding size estimation back
1 parent 95bae96 commit fd621c4

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

singularity/build/main.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from singularity.package import (
1313
build_from_spec,
14-
#estimate_image_size,
14+
estimate_image_size,
1515
package
1616
)
1717

@@ -94,21 +94,23 @@ def run_build(build_dir,params,verbose=True):
9494

9595
# If size is None, set default of 800
9696
if params['size'] in [None,'']:
97-
bot.logger.info("""\n\n--------------------------------------------------------------
97+
bot.logger.info("""\n
98+
--------------------------------------------------------------
9899
Size not detected for build. Will use default of 800MB padding. If
99100
your build fails due to running out of disk space, you can adjust the
100101
size under collection --> edit builder
101102
---------------------------------------------------------------------
102103
\n""")
103104

104-
params['size'] = 800
105-
106-
# In future we can possibly add this back.
107-
#params['size'] = estimate_image_size(spec_file=os.path.abspath(params['spec_file']),
108-
# sudopw='',
109-
# padding=params['padding'])
110-
#bot.logger.info("Size estimated as %s",params['size'])
111-
105+
# Testing estimation of size
106+
try:
107+
params['size'] = estimate_image_size(spec_file=os.path.abspath(params['spec_file']),
108+
sudopw='',
109+
padding=params['padding'])
110+
bot.logger.info("Size estimated as %s",params['size'])
111+
except:
112+
params['size'] = 800
113+
bot.logger.info("Size estimation didn't work, using default %s",params['size'])
112114

113115
# START TIMING
114116
start_time = datetime.now()

singularity/package.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ def estimate_image_size(spec_file,sudopw=None,padding=None):
3939

4040
image_folder = build_from_spec(spec_file=spec_file, # default will package the image
4141
sudopw=sudopw, # with root should not need sudo
42-
build_folder=True)
42+
build_folder=True,
43+
debug=False)
4344
original_size = calculate_folder_size(image_folder)
4445

4546
bot.logger.debug("Original image size calculated as %s",original_size)
4647
padded_size = original_size + padding
4748
bot.logger.debug("Size with padding will be %s",padded_size)
49+
shutil.rmtree(image_folder)
4850
return padded_size
4951

5052

singularity/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.0.2"
1+
__version__ = "1.0.3"
22
AUTHOR = 'Vanessa Sochat'
33
AUTHOR_EMAIL = '[email protected]'
44
NAME = 'singularity'

0 commit comments

Comments
 (0)