Skip to content

Commit e6f2768

Browse files
committed
updating examples
1 parent e811f9f commit e6f2768

File tree

11 files changed

+58
-334
lines changed

11 files changed

+58
-334
lines changed

examples/classify/classify_image/count_files.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,20 @@
33
# This is an example of counting files using an image diff
44

55
from singularity.analysis.classify import (
6-
get_diff,
76
file_counts,
87
extension_counts
98
)
109

11-
image_package = "python:3.6.0.img.zip"
12-
13-
# The diff is a dict of folders --> files that differ between
14-
# image and it's closest OS
15-
diff = get_diff(image_package=image_package)
10+
container = "ubuntu.simg"
1611

1712
# Now we might be interested in counting different things
18-
readme_count = file_counts(diff=diff)
19-
copyright_count = file_counts(diff=diff,patterns=['copyright'])
20-
authors_count = file_counts(diff=diff,patterns=['authors','thanks','credit'])
21-
todo_count = file_counts(diff=diff,patterns=['todo'])
13+
readme_count = file_counts(container)
14+
copyright_count = file_counts(container, patterns=['copyright'])
15+
authors_count = file_counts(container, patterns=['authors','thanks','credit'])
16+
todo_count = file_counts(container, patterns=['todo'])
2217

2318
# Or getting a complete dict of extensions
24-
extensions = extension_counts(diff=diff)
19+
extensions = extension_counts(container)
2520

2621
# Return files instead of counts
27-
extensions = extension_counts(diff=diff,return_counts=False)
22+
extensions = extension_counts(container, return_counts=False)

examples/classify/classify_image/derive_tags.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,19 @@
55
import os
66
os.environ['MESSAGELEVEL'] = 'CRITICAL'
77

8-
from singularity.analysis.classify import (
9-
get_tags,
10-
get_diff
11-
)
12-
13-
image_package = "python:3.6.0.img.zip"
8+
from singularity.analysis.classify import get_tags
9+
from singularity.package import get_container_contents
1410

1511
# The algorithm works as follows:
16-
# 1) first compare package to set of base OS (provided with shub)
17-
# 2) subtract the most similar os from image, leaving "custom" files
18-
# 3) organize custom files into dict based on folder name
19-
# 4) return search_folders as tags
12+
# 1) organize custom files into dict based on folder name
13+
# 2) return search_folders as tags
2014

2115
# Default tags will be returned as software in "bin"
22-
tags = get_tags(image_package=image_package)
16+
tags = get_tags(container)
2317

24-
# We can also get the raw "diff" between the image and it's base
25-
# which is usable in other functions (and we don't have to calc
26-
# it again)
27-
diff = get_diff(image_package=image_package)
18+
# We can also get the raw list of flies
19+
file_list = get_container_contents(container)['all']
2820

2921
# We can specify other folders of interest
3022
folders = ['init','init.d','bin','systemd']
31-
tags = get_tags(search_folders=folders,diff=diff)
32-
# Most similar OS found to be %s debian:7.11
23+
tags = get_tags(container, search_folders=folders)

examples/classify/classify_image/estimate_os.py

Lines changed: 0 additions & 17 deletions
This file was deleted.
-134 KB
Binary file not shown.

examples/create/make_runscript/make_runscript.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

examples/create/package_image/package_image.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/create/package_image/package_images.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

examples/reproducibility/assess_replication.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
11
from glob import glob
22

3-
from singularity.analysis.reproduce import (
4-
assess_replication,
5-
assess_differences
6-
)
3+
from singularity.analysis.reproduce import assess_differences
74

85
image_files=glob('*.img')
96

10-
# ASSESS REPLICATION #######################################
11-
# returns booleans for if the hashes for levels are the same
12-
13-
assess_replication(image_files[0],image_files[1])
14-
15-
{'BASE': False,
16-
'ENVIRONMENT': False,
17-
'IDENTICAL': False,
18-
'LABELS': True,
19-
'RECIPE': False,
20-
'REPLICATE': False,
21-
'RUNSCRIPT': False}
22-
23-
assess_replication(image_files[0],image_files[0])
24-
25-
{'BASE': True,
26-
'ENVIRONMENT': True,
27-
'IDENTICAL': True,
28-
'LABELS': True,
29-
'RECIPE': True,
30-
'REPLICATE': True,
31-
'RUNSCRIPT': True}
32-
337
# ASSESS DIFFERENCES #######################################
348
# returns dictionary with
359

examples/reproducibility/generate_image_hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# We might want to get a dictionary of content hashes for all files
4545
# of one container at one level!
4646
digest = get_content_hashes(image_path)
47-
digest['./usr/bin/pinky']
47+
digest['hashes']['/usr/bin/chfn']
4848
# 'ee2b438c278011bdac1a3a927e2d37519a8ed9c7'
4949

5050
# We can also get a hash of the entire image file, this is done on the

0 commit comments

Comments
 (0)