Skip to content

Commit dc0bba8

Browse files
committed
fixing bugs for builder
1 parent f334173 commit dc0bba8

File tree

6 files changed

+20
-28
lines changed

6 files changed

+20
-28
lines changed

singularity/analysis/reproduce/hash.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
'''
2828

29-
from singularity.cli import Singularity
29+
from spython.main import Client
3030
from singularity.logger import bot
3131
from singularity.analysis.reproduce.criteria import *
3232
from singularity.analysis.reproduce.levels import *
@@ -46,7 +46,7 @@
4646

4747

4848

49-
def get_image_hashes(image_path,version=None,levels=None):
49+
def get_image_hashes(image_path, version=None, levels=None):
5050
'''get_image_hashes returns the hash for an image across all levels. This is the quickest,
5151
easiest way to define a container's reproducibility on each level.
5252
'''
@@ -98,7 +98,6 @@ def get_image_hash(image_path,
9898
skip_files=skip_files,
9999
include_files=include_files)
100100

101-
cli = Singularity()
102101
file_obj, tar = get_image_tar(image_path)
103102
hasher = hashlib.md5()
104103

@@ -109,7 +108,7 @@ def get_image_hash(image_path,
109108
if member.isdir() or member.issym():
110109
continue
111110
elif assess_content(member,file_filter):
112-
content = extract_content(image_path,member.name,cli)
111+
content = extract_content(image_path,member.name)
113112
hasher.update(content)
114113
elif include_file(member,file_filter):
115114
buf = member.tobuf()

singularity/analysis/reproduce/metrics.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
'''
2828

29-
from singularity.cli import Singularity
29+
from spython.main import Client
3030
from singularity.logger import bot
3131
from .levels import get_levels
3232
from .utils import extract_content
@@ -105,10 +105,9 @@ def assess_differences(image_file1,
105105
# Otherwise we need to check based on byte content
106106
else:
107107
if len(contenders) > 0:
108-
cli = Singularity()
109108
for rogue in contenders:
110-
hashy1 = extract_content(image_file1,rogue,cli,return_hash=True)
111-
hashy2 = extract_content(image_file2,rogue,cli,return_hash=True)
109+
hashy1 = extract_content(image_file1, rogue, return_hash=True)
110+
hashy2 = extract_content(image_file2, rogue, return_hash=True)
112111

113112
# If we can't compare, we use size as a heuristic
114113
if hashy1 is None or hashy2 is None: # if one is symlink, could be None
@@ -140,4 +139,3 @@ def assess_differences(image_file1,
140139

141140
reports['scores'] = scores
142141
return reports
143-

singularity/analysis/reproduce/utils.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
'''
2828

29-
from singularity.cli import Singularity
29+
from spython.main import Client
3030
from .criteria import (
3131
assess_content,
3232
include_file,
@@ -48,7 +48,6 @@ def extract_guts(image_path,tar,file_filter,tag_root=True,include_sizes=True):
4848
read the memory in tar, or from fileystem
4949
'''
5050

51-
cli = Singularity()
5251
results = dict()
5352
digest = dict()
5453

@@ -64,7 +63,7 @@ def extract_guts(image_path,tar,file_filter,tag_root=True,include_sizes=True):
6463
if member.isdir() or member.issym():
6564
continue
6665
elif assess_content(member,file_filter):
67-
digest[member_name] = extract_content(image_path,member.name,cli,return_hash=True)
66+
digest[member_name] = extract_content(image_path, member.name, return_hash=True)
6867
included = True
6968
elif include_file(member,file_filter):
7069
hasher = hashlib.md5()
@@ -91,21 +90,18 @@ def get_memory_tar(image_path):
9190
'''get an in memory tar of an image. Use carefully, not as reliable
9291
as get_image_tar
9392
'''
94-
cli = Singularity()
95-
byte_array = cli.export(image_path)
93+
byte_array = Client.export(image_path)
9694
file_object = io.BytesIO(byte_array)
9795
tar = tarfile.open(mode="r|*", fileobj=file_object)
9896
return (file_object,tar)
9997

10098

101-
def get_image_tar(image_path,S=None):
99+
def get_image_tar(image_path):
102100
'''get an image tar, either written in memory or to
103101
the file system. file_obj will either be the file object,
104102
or the file itself.
105103
'''
106104
bot.debug('Generate file system tar...')
107-
if S is None:
108-
S = Singularity()
109105
file_obj = S.export(image_path=image_path)
110106
if file_obj is None:
111107
bot.error("Error generating tar, exiting.")
@@ -128,17 +124,15 @@ def delete_image_tar(file_obj, tar):
128124
return deleted
129125

130126

131-
def extract_content(image_path,member_name,cli=None,return_hash=False):
127+
def extract_content(image_path, member_name, return_hash=False):
132128
'''extract_content will extract content from an image using cat.
133129
If hash=True, a hash sum is returned instead
134130
'''
135131
if member_name.startswith('./'):
136132
member_name = member_name.replace('.','',1)
137133
if return_hash:
138134
hashy = hashlib.md5()
139-
if cli == None:
140-
cli = Singularity()
141-
content = cli.execute(image_path,'cat %s' %(member_name))
135+
content = Client.execute(image_path,'cat %s' %(member_name))
142136
if not isinstance(content,bytes):
143137
content = content.encode('utf-8')
144138
content = bytes(content)

singularity/build/scripts/singularity-prepare-instance.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sudo apt-get -y install git \
1414
libtool \
1515
squashfs-tools \
1616
autotools-dev \
17+
libarchive-dev \
1718
automake \
1819
autoconf \
1920
debootstrap \
@@ -26,6 +27,7 @@ sudo apt-get -y install git \
2627

2728
# Pip3 installs
2829
sudo pip3 install --upgrade pip &&
30+
sudo pip3 install pyasn1-modules -U &&
2931
sudo pip3 install --upgrade google-api-python-client &&
3032
sudo pip3 install --upgrade google &&
3133
sudo pip3 install oauth2client==3.0.0

singularity/package/clone.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
2626
'''
2727

28+
from spython.main import Client
2829
import tempfile
2930
from singularity.logger import bot
30-
from singularity.cli import Singularity
3131
from singularity.utils import run_command
3232
import platform
3333
import os
3434
import sys
3535

36-
def package_node(root=None,name=None):
36+
def package_node(root=None, name=None):
3737
'''package node aims to package a (present working node) for a user into
3838
a container. This assumes that the node is a single partition.
3939
@@ -81,10 +81,9 @@ def unpack_node(image_path,name=None,output_folder=None,size=None):
8181

8282
bot.debug("Preparing to unpack %s to %s." %(image_name,name))
8383
unpacked_image = "%s/%s" %(output_folder,name)
84-
85-
S = Singularity(sudo=True)
86-
S.create(image_path=unpacked_image,
87-
size=size)
84+
85+
if not os.path.exists(unpacked_image):
86+
os.mkdir(unpacked_image)
8887

8988
cmd = ["gunzip","-dc",image_path,"|","sudo","singularity","import", unpacked_image]
9089
output = run_command(cmd)

singularity/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
LICENSE = "LICENSE"
3333

3434
INSTALL_REQUIRES = (
35-
('spython', {'min_version': '0.0.31'}),
35+
('spython', {'min_version': '0.0.32'}),
3636
('requests', {'min_version': '2.18.4'}),
3737
('retrying', {'min_version': '1.3.3'}),
3838
('pygments', {'min_version': '2.1.3'}),

0 commit comments

Comments
 (0)