Skip to content

Commit 1021e0f

Browse files
authored
Merge pull request #63 from vsoch/development
Development
2 parents d442325 + 3174a9b commit 1021e0f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/shub/run_client.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Download a Singularity Hub Container
2+
3+
# This is a simple script to use the singularity command line tool to
4+
# obtain a manifest and download an image
5+
6+
from singularity.hub.client import Client
7+
8+
shub = Client() # Singularity Hub Client
9+
10+
11+
#############################################
12+
# Task 1: Download a container
13+
#############################################
14+
15+
16+
container_name = 'vsoch/singularity-hello-world'
17+
collection = shub.get_collection(container_name)
18+
container_ids = collection['container_set']
19+
20+
# Here is one we are interested in
21+
container_id = container_ids.pop()
22+
23+
# The container manifest has all information about container
24+
manifest = shub.get_container(container_id)
25+
26+
# Default will download to present working directory,
27+
# but we can also set download_folder to something:
28+
image = shub.pull_container(manifest)
29+
30+
# You can also set the download_folder or name, eg:
31+
image = shub.pull_container(manifest,
32+
download_folder='/tmp',
33+
name='container.img.gz')

0 commit comments

Comments
 (0)