Skip to content

Commit 1b38684

Browse files
authored
Merge pull request #80 from vsoch/development
Development
2 parents 9d18441 + c2183e2 commit 1b38684

File tree

24 files changed

+77
-135
lines changed

24 files changed

+77
-135
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# CHANGELOG
2+
3+
This is a manually generated log to track changes to the repository for each release.
4+
Each section should include general headers such as **Implemented enhancements**
5+
and **Merged pull requests**. All closed issued and bug fixes should be
6+
represented by the pull requests that fixed them. This log originated with Singularity 2.4
7+
and changes prior to that are (unfortunately) done retrospectively. Critical items to know are:
8+
9+
- renamed commands
10+
- deprecated / removed commands
11+
- changed defaults
12+
- backward incompatible changes (recipe file format? image file format?)
13+
- migration guidance (how to convert images?)
14+
- changed behaviour (recipe sections work differently)
15+
16+
17+
## [vxx](https://github.com/singularityware/singularity-python/tree/development) (development)
18+
19+
**changed defaults**
20+
- *sregistry client*: to support use of squashfs images and singularity 2.4, the default upload is not compressed, assuming squashfs, and the default download is not decompressed. To still compress an image add the `--compress` flag on push, and the `--decompress` flag on pull.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ recursive-include singularity *
33
recursive-exclude * __pycache__
44
recursive-exclude * *.pyc
55
recursive-exclude * *.pyo
6+
recursive-exclude * *.simg
7+
recursive-exclude * *.img

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Singularity Python is a python module and command line tool for working with <a href="https://singularityware.github.io" target="_blank">Singularity</a> containers, specifically providing functions to visualize, package, and compare containers. Currently, most functions use Singularity on the command line, and some require sudo.
66

7-
We currently require Python > version 3 to use various timezone functions. If you are unable to install version 3.0, we provide a [Singularity.container](Singularity.container) for you to use instead. See the [installation docs](https://github.com/singularityware/singularity-python/wiki/Installation) for your different options.
7+
We currently require Python > version 3 to use various timezone functions. If you are unable to install version 3.0, we provide a [Singularity.container](Singularity.container) for you to use instead. This is the recommended approach as some older versions of Python do not support generation of the timestamp. See the [installation docs](https://github.com/singularityware/singularity-python/wiki/Installation) for your different options.
88

99
The Singularity-Python code is licensed under the MIT open source license, which is a highly permissive license that places few limits upon reuse. This ensures that the code will be usable by the greatest number of researchers, in both academia and industry. The following examples are provided:
1010

singularity/analysis/classify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_diff(container=None,image_package=None):
7474
'''
7575

7676
# Find the most similar os
77-
most_similar = estimate_os(image_package=image_package,container=container)
77+
most_similar = estimate_os(image_package=image_package,container=container)
7878
similar_package = "%s/docker-os/%s.img.zip" %(get_package_base(),most_similar)
7979

8080
comparison = compare_containers(image_package1=image_package,

singularity/analysis/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def compare_singularity_images(image_paths1,image_paths2=None):
128128
members2 = [x.name for x in tar2]
129129
c = compare_lists(members1,members2)
130130
sim = information_coefficient(c['total1'],c['total2'],c['intersect'])
131-
delete_image_tar(fileobj2)
131+
delete_image_tar(fileobj2, tar2)
132132

133133
dfs.loc[image1,image2] = sim
134134
if repeat:
135135
dfs.loc[image2,image1] = sim
136136
comparisons_done.append(comparison_id)
137-
delete_image_tar(fileobj1)
137+
delete_image_tar(fileobj1, tar1)
138138
return dfs
139139

140140

singularity/analysis/reproduce/hash.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def get_image_hash(image_path,
9999
include_files=include_files)
100100

101101
cli = Singularity()
102-
file_obj,tar = get_image_tar(image_path)
102+
file_obj, tar = get_image_tar(image_path)
103103
hasher = hashlib.md5()
104104

105105
for member in tar:
@@ -117,11 +117,14 @@ def get_image_hash(image_path,
117117

118118
digest = hasher.hexdigest()
119119

120-
if isinstance(file_obj,io.BytesIO):
120+
# Close up / remove files
121+
try:
121122
file_obj.close()
122-
else:
123-
if os.path.exists(file_obj):
124-
os.remove(file_obj)
123+
except:
124+
tar.close()
125+
126+
if os.path.exists(file_obj):
127+
os.remove(file_obj)
125128

126129
return digest
127130

@@ -163,7 +166,7 @@ def get_content_hashes(image_path,
163166
tag_root=tag_root,
164167
include_sizes=include_sizes)
165168

166-
deleted = delete_image_tar(file_obj)
169+
delete_image_tar(file_obj, tar)
167170
return results
168171

169172

singularity/analysis/reproduce/utils.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,17 @@ def get_image_tar(image_path,S=None):
114114
return file_obj, tar
115115

116116

117-
def delete_image_tar(file_obj):
117+
def delete_image_tar(file_obj, tar):
118118
'''delete image tar will close a file object (if extracted into
119119
memory) or delete from the file system (if saved to disk)'''
120-
deleted = False
121-
if isinstance(file_obj,io.BytesIO):
120+
try:
122121
file_obj.close()
122+
except:
123+
tar.close()
124+
if os.path.exists(file_obj):
125+
os.remove(file_obj)
123126
deleted = True
124-
bot.debug('Closed memory tar.')
125-
else:
126-
if os.path.exists(file_obj):
127-
os.remove(file_obj)
128-
deleted = True
129-
bot.debug('Deleted temporary tar.')
127+
bot.debug('Deleted temporary tar.')
130128
return deleted
131129

132130

singularity/analysis/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import requests
3333

3434
import shutil
35-
import simplejson
3635
from singularity.logger import bot
3736
from singularity.utils import get_installdir
3837
import sys

singularity/build/google.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def get_image_path(repo_url, trailing_path):
165165

166166

167167

168-
def run_build(logfile=None):
168+
def run_build(logfile='/tmp/.shub-log'):
169169

170170
'''run_build will generate the Singularity build from a spec_file from a repo_url.
171171
@@ -287,9 +287,10 @@ def run_build(logfile=None):
287287
"metadata": json.dumps(metadata)}
288288

289289
# Did the user specify a specific log file?
290-
logfile = get_build_metadata('logfile')
291-
if logfile is not None:
292-
response['logfile'] = logfile
290+
custom_logfile = get_build_metadata('logfile')
291+
if custom_logfile is not None:
292+
logfile = custom_logfile
293+
response['logfile'] = logfile
293294

294295
# Send final build data to instance
295296
send_build_data(build_dir=build_dir,

singularity/build/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ def run_build(build_dir,params,verbose=True, compress_image=False):
121121
if os.path.exists(params['spec_file']):
122122
bot.info("Found spec file %s in repository" %params['spec_file'])
123123

124+
# If the user has a symbolic link
125+
if os.path.islink(params['spec_file']):
126+
bot.info("%s is a symbolic link." %params['spec_file'])
127+
params['spec_file'] = os.path.realpath(params['spec_file'])
128+
124129
# START TIMING
125130
start_time = datetime.now()
126131
image = build_from_spec(spec_file=params['spec_file'], # default will package the image

0 commit comments

Comments
 (0)