Skip to content

Commit 6d44385

Browse files
committed
fixes for builder
1 parent 2ed5798 commit 6d44385

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name="singularity",
88

99
# Version number:
10-
version="0.39",
10+
version="0.40",
1111

1212
# Application author details:
1313
author="Vanessa Sochat",

singularity/build/google.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
192192
if os.path.exists(spec_file):
193193
bot.logger.info("Found spec file %s in repository",spec_file)
194194

195-
# If size is None, get from image + 200 padding
195+
# If size is None, get from image + 50 padding
196196
if params['size'] == None:
197197
bot.logger.info("Size not detected for build. Will estimate with 200MB padding.")
198198
params['size'] = estimate_image_size(spec_file=spec_file,

singularity/build/scripts/singularity-build-latest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sudo pip3 install --upgrade google
1212
sudo pip3 install oauth2client==3.0.0
1313
sudo pip3 install gitpython
1414
cd /tmp && git clone https://github.com/singularityware/singularity-python
15-
cd singularity-python && python3 setup.py sdist && sudo python3 setup.py install
15+
cd singularity-python && python3 setup.py sdist && sudo python3 setup.py install && cd ..
1616
python3 -c "from singularity.build.google import run_build; run_build()" > /tmp/.shub-log 2>&1
1717
command=$(echo "from singularity.build.google import finish_build; finish_build(logfile='/tmp/.shub-log')")
1818
python3 -c "$command"

singularity/package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import os
2525

2626

27-
def estimate_image_size(spec_file=None,sudopw=None,padding=200):
27+
def estimate_image_size(spec_file=None,sudopw=None,padding=50):
2828
'''estimate_image_size will generate an image in a directory, and add
2929
some padding to it to estimate the size of the image file to generate
3030
:param sudopw: the sudopw for Singularity, root should provide ''

singularity/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,22 @@ def read_file(filename,mode="r"):
234234
############################################################################
235235

236236

237-
def calculate_folder_size(folder_path):
237+
def calculate_folder_size(folder_path,truncate=True):
238238
'''calculate_folder size recursively walks a directory to calculate
239-
a total size (in)
239+
a total size (in MB)
240240
:param folder_path: the path to calculate size for
241+
:param truncate: if True, converts size to an int
241242
'''
242243
total_size = 0
243244
for dirpath, dirnames, filenames in os.walk(folder_path):
244245
for filey in filenames:
245-
fp = os.path.join(dirpath, filey)
246-
total_size += os.path.getsize(fp)
247-
return total_size
246+
file_path = os.path.join(dirpath, filey)
247+
if os.path.isfile(file_path) and not os.path.islink(file_path):
248+
total_size += os.path.getsize(file_path) # this is bytes
249+
size_mb = total_size / 1000000
250+
if truncate == True:
251+
size_mb = int(size_mb)
252+
return size_mb
248253

249254

250255
def remove_unicode_dict(input_dict):

0 commit comments

Comments
 (0)