Skip to content

Commit 0d42bdb

Browse files
committed
modified: README.md
modified: singularity/cli/main/__init__.py
1 parent 067169d commit 0d42bdb

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ Please see our [complete docs](https://github.com/singularityware/singularity-py
1010

1111
## Help and Contribution
1212
Please contribute to the package, or post feedback and questions as <a href="https://github.com/singularityware/singularity-python" target="_blank">issues</a>. For points that require discussion of the larger group, please use the <a href="https://groups.google.com/a/lbl.gov/forum/#!forum/singularity" target="_blank">Singularity List</a>
13-

singularity/cli/main/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def get_parser():
6868

6969
# Compare
7070
compare = subparsers.add_parser("compare",
71-
help = "views and functions to compare two containers")
71+
help = "views and functions to compare two containers. Default calculates score.")
72+
73+
compare.add_argument("--outfolder", dest='outfolder',
74+
help="full path to folder for output, stays in tmp (or pwd) if not specified",
75+
type=str, default=None)
7276

7377
compare.add_argument("--images", dest='images',
7478
help="images, separated by commas",
@@ -82,10 +86,6 @@ def get_parser():
8286
help="subtract one container image from the second to make a difference tree (use --images first,subtract)",
8387
default=False, action='store_true')
8488

85-
compare.add_argument('--simcalc', dest='simcalc',
86-
help="calculate similarity (number) between images based on file contents.",
87-
default=False, action='store_true')
88-
8989

9090

9191
# Analysis
@@ -100,6 +100,13 @@ def get_parser():
100100
help="calculate similarity score for your container vs. docker library OS.",
101101
default=False, action='store_true')
102102

103+
analysis.add_argument("--outfolder", dest='outfolder',
104+
help="full path to folder for output, stays in tmp (or pwd) if not specified",
105+
type=str, default=None)
106+
107+
analysis.add_argument("--image", dest='image',
108+
help="full path to singularity image",
109+
type=str, default=None)
103110

104111
analysis.add_argument('--osplot', dest="osplot",
105112
help="plot similarity scores for your container vs. docker library OS.",

singularity/cli/main/analysis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ def main(args,parser,subparser):
4444

4545

4646
# If we are given an image, ensure full path
47-
if args.image is not None:
47+
image = args.image
48+
if image is not None:
4849

49-
if not os.path.exists(args.image):
50+
existed = True
51+
if not os.path.exists(image):
5052
cli = Singularity(debug=args.debug)
51-
image = cli.pull(args.image)
53+
image = cli.pull(image)
54+
existed = False
5255

5356
if image is None:
5457
bot.error("Cannot find image. Exiting.")

singularity/cli/main/compare.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
from singularity.utils import check_install
2626
from singularity.logger import bot
27+
from singularity.cli import Singularity
28+
from singularity.cli.utils import clean_up
2729
import sys
2830
import os
2931

@@ -47,16 +49,17 @@ def main(args,parser,subparser):
4749
bot.debug("Image1: %s" %image1)
4850
bot.debug("Image2: %s" %image2)
4951

50-
images = []
52+
images = dict()
5153
cli = Singularity(debug=args.debug)
5254
for image in [image1,image2]:
55+
existed = True
5356
if not os.path.exists(image):
5457
image = cli.pull(image)
55-
images.append(image)
58+
existed = False
59+
images[image] = existed
5660

5761
# Just for clarity
58-
image1 = images[0]
59-
image2 = images[1]
62+
image1,image2 = list(images.keys())
6063

6164
# the user wants to make a similarity tree
6265
if args.simtree is True:
@@ -68,14 +71,14 @@ def main(args,parser,subparser):
6871
from singularity.cli.app import make_diff_tree
6972
make_diff_tree(image1,image2)
7073

71-
elif args.simcalc is True:
74+
else: # If none specified, just print score
7275
from singularity.analysis.compare import calculate_similarity
7376
score = calculate_similarity(image1,image2,by="files.txt")
7477
print(score["files.txt"])
7578

76-
clean_up(image1,existed1)
77-
clean_up(image2,existed2)
78-
79+
for image,existed in images.items():
80+
clean_up(image,existed)
81+
7982
else:
8083
print("Please specify images to compare with --images")
8184
subparser.print_help()

singularity/logger/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ def get_logging_level():
305305
(5) is assumed (all messages).
306306
'''
307307
try:
308-
level = int(os.environ.get("MESSAGELEVEL", DEBUG))
308+
level = int(os.environ.get("MESSAGELEVEL", INFO))
309309

310310
except ValueError:
311311

312-
level = os.environ.get("MESSAGELEVEL", DEBUG)
312+
level = os.environ.get("MESSAGELEVEL", INFO)
313313
if level == "CRITICAL":
314314
return CRITICAL
315315
elif level == "ABORT":

0 commit comments

Comments
 (0)