Skip to content

Commit c25d94c

Browse files
committed
updating build scripts!
1 parent d44d70b commit c25d94c

File tree

4 files changed

+38
-46
lines changed

4 files changed

+38
-46
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.72",
10+
version="0.73",
1111

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

singularity/build/google.py

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
api_put
1111
)
1212

13-
from singularity.build.utils import sniff_metadata
13+
from singularity.build.utils import sniff_extension
1414

1515
from singularity.build.main import (
1616
run_build as run_build_main,
@@ -33,6 +33,7 @@
3333

3434
import io
3535
import os
36+
import pickle
3637
import re
3738
import requests
3839
import sys
@@ -104,9 +105,10 @@ def list_bucket(bucket,storage_service):
104105
return objects
105106

106107

108+
107109
def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,bucket_name=None,
108110
repo_id=None,commit=None,verbose=True,response_url=None,secret=None,branch=None,
109-
padding=None):
111+
padding=None,logfile=None):
110112

111113
'''run_build will generate the Singularity build from a spec_file from a repo_url.
112114
@@ -155,25 +157,32 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
155157
{'key': 'size', 'value': size, 'return_text': True },
156158
{'key': 'branch', 'value': branch, 'return_text': True },
157159
{'key': 'spec_file', 'value': spec_file, 'return_text': True },
158-
{'key': 'padding', 'value': padding, 'return_text': True }]
160+
{'key': 'padding', 'value': padding, 'return_text': True },
161+
{'key': 'logging_url', 'value': logging_url, 'return_text': True },
162+
{'key': 'logfile', 'value': logfile, 'return_text': True }]
163+
159164

160165
# Obtain values from build
161166
params = get_build_params(metadata)
162-
167+
163168
# Default spec file is Singularity
164169
if params['spec_file'] == None:
165170
params['spec_file'] = "Singularity"
166-
171+
167172
if params['bucket_name'] == None:
168173
params['bucket_name'] = "singularity-hub"
169174

175+
if params['padding'] == None:
176+
params['padding'] = 50
177+
170178
output = run_build_main(build_dir=build_dir,
171179
params=params)
172180

173181
# Output includes:
174182
image_package = output['image_package']
175183
compressed_image = output['image']
176-
metadata = output['metadata']
184+
metadata = output['metadata']
185+
params = output['params']
177186

178187
# Upload image package files to Google Storage
179188
if os.path.exists(image_package):
@@ -233,21 +242,16 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
233242
response_url=params['response_url'],
234243
data=response)
235244

245+
# Dump final params, for logger to retrieve
246+
passing_params = "%s/params.pkl" %os.environ['HOME']
247+
pickle.dump(params,open(passing_params,'wb'))
248+
236249

237250

238-
def finish_build(logfile=None,repo_url=None,bucket_name=None,commit=None,repo_id=None,
239-
logging_url=None,secret=None,token=None,verbose=True):
251+
def finish_build(verbose=True):
240252
'''finish_build will finish the build by way of sending the log to the same bucket.
241-
:param build_dir: directory to do the build in. If not specified,
242-
will use temporary.
243-
:param logfile: the logfile to send.
244-
:param repo_url: the url to download the repo from
245-
:param repo_id: the repo_id to uniquely identify the repo (in case name changes)
246-
:param commit: the commit to checkout. If none provided, will use most recent.
247-
:param bucket_name: the name of the bucket to send files to
248-
:param verbose: print out extra details as we go (default True)
249-
:param secret: a secret to match to the correct container
250-
:param logging_url: the logging response url to send the response back to.
253+
the params are loaded from the previous function that built the image, expected in
254+
$HOME/params.pkl
251255
:: note: this function is currently configured to work with Google Compute
252256
Engine metadata api, and should (will) be customized if needed to work elsewhere
253257
'''
@@ -256,25 +260,13 @@ def finish_build(logfile=None,repo_url=None,bucket_name=None,commit=None,repo_id
256260
if go == None:
257261
sys.exit(0)
258262

259-
# Get variables from the instance metadata API
260-
metadata = [{'key': 'logging_url', 'value': logging_url, 'return_text': True },
261-
{'key': 'repo_url', 'value': repo_url, 'return_text': False },
262-
{'key': 'repo_id', 'value': repo_id, 'return_text': True },
263-
{'key': 'token', 'value': token, 'return_text': False },
264-
{'key': 'commit', 'value': commit, 'return_text': True },
265-
{'key': 'bucket_name', 'value': bucket_name, 'return_text': True },
266-
{'key': 'secret', 'value': secret, 'return_text': True },
267-
{'key': 'logfile', 'value': logfile, 'return_text': True }]
268-
269-
if bucket_name == None:
270-
bucket_name = "singularity-hub"
271-
272-
# Obtain values from build
273-
params = get_build_params(metadata)
263+
# Load metadata
264+
passing_params = "%s/params.pkl" %os.environ['HOME']
265+
params = pickle.load(open(passing_params,'rb'))
274266

275267
# Start the storage service, retrieve the bucket
276268
storage_service = get_storage_service()
277-
bucket = get_bucket(storage_service,bucket_name)
269+
bucket = get_bucket(storage_service,params['bucket_name'])
278270
image_path = "%s/%s" %(re.sub('^http.+//www[.]','',params['repo_url']),params['commit'])
279271

280272
# Upload the log file

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ sudo apt-get -y install git \
1313
sudo pip3 install --upgrade pip &&
1414
sudo pip3 install --upgrade google-api-python-client &&
1515
sudo pip3 install --upgrade google &&
16-
sudo pip3 install oauth2client==3.0.0 gitpython
16+
sudo pip3 install oauth2client==3.0.0
17+
sudo pip3 install gitpython
1718
sudo pip3 install singularity --upgrade
1819

1920
# Main running script

singularity/views/trees.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77

88
import json
99

10-
from matplotlib import pyplot as plt
11-
from scipy.cluster.hierarchy import (
12-
dendrogram,
13-
linkage
14-
)
15-
16-
from scipy.cluster.hierarchy import cophenet
17-
from scipy.spatial.distance import pdist
18-
import numpy as np
19-
2010
from singularity.logman import bot
2111

2212
from singularity.views.utils import get_container_contents
@@ -205,6 +195,15 @@ def make_package_tree(matrix=None,labels=None,width=25,height=10,title=None):
205195
:param title: a title for the plot, if not defined, will be left out.
206196
:returns a plot that can be saved with savefig
207197
'''
198+
from matplotlib import pyplot as plt
199+
from scipy.cluster.hierarchy import (
200+
dendrogram,
201+
linkage
202+
)
203+
204+
from scipy.cluster.hierarchy import cophenet
205+
from scipy.spatial.distance import pdist
206+
208207
if not isinstance(matrix,pandas.DataFrame):
209208
bot.logger.info("No pandas DataFrame (matrix) of similarities defined, will use default.")
210209
matrix = compare_packages()['files.txt']

0 commit comments

Comments
 (0)