Skip to content

Commit c4b50ac

Browse files
committed
final tweaks
1 parent d1a2719 commit c4b50ac

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

singularity/analysis/apps.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
def extract_apps(image, app_names):
3838
''' extract app will extract metadata for one or more apps
39-
4039
Parameters
4140
==========
4241
image: the absolute path to the image
@@ -45,28 +44,24 @@ def extract_apps(image, app_names):
4544
'''
4645
apps = dict()
4746

48-
if not isinstance(app_names,list):
47+
if isinstance(app_names, tuple):
48+
app_names = list(app_names)
49+
if not isinstance(app_names, list):
4950
app_names = [app_names]
50-
5151
if len(app_names) == 0:
5252
return apps
5353

5454
for app_name in app_names:
55-
5655
metadata = dict()
5756

5857
# Inspect: labels, env, runscript, tests, help
59-
6058
try:
6159
inspection = json.loads(Client.inspect(image, app=app_name))
6260
del inspection['data']['attributes']['deffile']
6361
metadata['inspect'] = inspection
6462

6563
# If illegal characters prevent load, not much we can do
66-
6764
except:
6865
pass
69-
7066
apps[app_name] = metadata
71-
7267
return apps

singularity/build/google.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,23 @@ def run_build(logfile='/tmp/.shub-log'):
236236
params=params)
237237

238238
# Output includes:
239-
image_package = output['image_package']
240239
finished_image = output['image']
241240
metadata = output['metadata']
242241
params = output['params']
243242

244243
# Upload image package files to Google Storage
245-
if os.path.exists(image_package):
246-
bot.info("Package %s successfully built" %image_package)
244+
if os.path.exists(finished_image):
245+
bot.info("%s successfully built" %finished_image)
247246
dest_dir = tempfile.mkdtemp(prefix='build')
248-
with zipfile.ZipFile(image_package) as zf:
249-
zf.extractall(dest_dir)
250247

251248
# The path to the images on google drive will be the github url/commit folder
252249
trailing_path = "%s/%s" %(params['commit'], params['version'])
253250
image_path = get_image_path(params['repo_url'], trailing_path)
254251
# commits are no longer unique
255252
# storage is by commit
256253

257-
build_files = glob("%s/*" %(dest_dir))
258-
build_files.append(finished_image)
259-
bot.info("Sending build files to storage:")
254+
build_files = [finished_image]
255+
bot.info("Sending image to storage:")
260256
bot.info('\n'.join(build_files))
261257

262258
# Start the storage service, retrieve the bucket

singularity/build/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
from spython.main import Client
3333

34+
from singularity.analysis.apps import extract_apps
3435
from singularity.build.utils import (
3536
stop_if_result_none,
3637
get_singularity_version,
3738
test_container
3839
)
3940

40-
4141
from singularity.analysis.reproduce import get_image_file_hash
4242
from singularity.utils import download_repo
4343

@@ -129,6 +129,10 @@ def run_build(build_dir, params, verbose=True):
129129
params['version'] = version
130130
pickle.dump(params, open(passing_params,'wb'))
131131

132+
# Rename image to be hash
133+
finished_image = "%s/%s.simg" %(os.path.dirname(image), version)
134+
image = shutil.move(image, finished_image)
135+
132136
final_time = (datetime.now() - start_time).seconds
133137
bot.info("Final time of build %s seconds." %final_time)
134138

@@ -140,10 +144,14 @@ def run_build(build_dir, params, verbose=True):
140144

141145
# Get singularity version
142146
singularity_version = Client.version()
147+
Client.debug = False
143148
inspect = Client.inspect(image) # this is a string
149+
Client.debug = params['debug']
144150

145151
# Get information on apps
152+
Client.debug = False
146153
app_names = Client.apps(image)
154+
Client.debug = params['debug']
147155
apps = extract_apps(image, app_names)
148156

149157
metrics = {'build_time_seconds': final_time,

0 commit comments

Comments
 (0)