Skip to content

Commit

Permalink
removing checks for versions across all files and 2.x image commands … (
Browse files Browse the repository at this point in the history
#191)

* removing checks for versions across all files and 2.x image commands import, export

the reason being so we can easily support apptainer and singularityce installs,
which both provide an executable singularity but with different versions! Also,
people should not be using the 2.x command groups at this point because there are too
many security issues. We can support this in some small way by not making it easy/possible
to do here, unless they want to install an older version. This will fix #190

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Mar 27, 2022
1 parent d0099dd commit 1daab24
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate black
pyflakes spython/oci spython/image spython/instance spython/main
pyflakes spython/oci spython/image.py spython/instance spython/main
pytest:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
singularity on pypi), and the versions here will coincide with these releases.

## [master](https://github.com/singularityhub/singularity-cli/tree/master)
- version checks removed to support Singularity 3.x and above (0.2.0)
- adding support for SIF (oras pull) (0.1.18)
- updating CI/tests and fixing deprecations (warnings) (0.1.17)
- fixing bug with defining comments earlier (0.1.16)
Expand Down
2 changes: 1 addition & 1 deletion spython/README.md
Expand Up @@ -4,7 +4,7 @@ This will briefly outline the content of the folders here.
## Main Functions

- [main](main) holds the primary client functions to interact with Singularity (e.g., exec, run, pull), and the subfolders within represent command groups (e.g., instance, image) along with the base of the client ([base](main/base)). This folder is where **commands** go!
- [image](image) is a class that represents and holds an image object, in the case that the user wants to initialize a client with an image. This holds the ImageClass, which is only needed to instantiate an image.
- [image](image.py) is a class that represents and holds an image object, in the case that the user wants to initialize a client with an image. This holds the ImageClass, which is only needed to instantiate an image.
- [instance](instance) is a class that represents and holds an instance object. The user can instantiate the class, and then run it's sub functions to interact with it. The higher level "list" command is provided on the level of the client.
- [cli](cli): is the actual entry point that connects the user to the python API client from the command line. The user inputs are parsed, and then passed into functions from main.

Expand Down
2 changes: 1 addition & 1 deletion spython/image/__init__.py → spython/image.py
Expand Up @@ -10,7 +10,7 @@
from spython.utils import split_uri


class ImageBase(object):
class ImageBase:
def __str__(self):
protocol = getattr(self, "protocol", None)
if protocol:
Expand Down
46 changes: 0 additions & 46 deletions spython/image/cmd/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions spython/image/cmd/create.py

This file was deleted.

34 changes: 0 additions & 34 deletions spython/image/cmd/export.py

This file was deleted.

25 changes: 0 additions & 25 deletions spython/image/cmd/importcmd.py

This file was deleted.

31 changes: 0 additions & 31 deletions spython/image/cmd/utils.py

This file was deleted.

7 changes: 1 addition & 6 deletions spython/instance/cmd/start.py
Expand Up @@ -56,12 +56,7 @@ def start(

image = self._image

# Derive subgroup command based on singularity version
subgroup = "instance.start"
if "version 3" in self.version():
subgroup = ["instance", "start"]

cmd = self._init_command(subgroup, singularity_options)
cmd = self._init_command(["instance", "start"], singularity_options)

# Set options and args
args = args or self.args
Expand Down
9 changes: 3 additions & 6 deletions spython/instance/cmd/stop.py
Expand Up @@ -36,12 +36,9 @@ def stop(

check_install()

subgroup = "instance.stop"

if "version 3" in self.version():
subgroup = ["instance", "stop"]
if timeout:
subgroup += ["-t", str(timeout)]
subgroup = ["instance", "stop"]
if timeout:
subgroup += ["-t", str(timeout)]

cmd = self._init_command(subgroup, singularity_options)

Expand Down
2 changes: 1 addition & 1 deletion spython/logger/progress.py
Expand Up @@ -25,7 +25,7 @@
ETA_SMA_WINDOW = 9


class ProgressBar(object):
class ProgressBar:
def __enter__(self):
return self

Expand Down
31 changes: 11 additions & 20 deletions spython/main/__init__.py
Expand Up @@ -16,7 +16,6 @@ def get_client(quiet=False, debug=False):
debug: turn on debugging mode
"""
from spython.utils import get_singularity_version
from .base import Client as client

client.quiet = quiet
Expand All @@ -31,26 +30,20 @@ def get_client(quiet=False, debug=False):
from .instances import list_instances, stopall # global instance commands
from .run import run
from .pull import pull
from .export import export, _export
from .export import export

# Actions
client.apps = apps
client.build = build
client.execute = execute
client.export = export
client._export = _export
client.help = helpcmd
client.inspect = inspect
client.instances = list_instances
client.run = run
client.shell = shell
client.pull = pull

# Command Groups, Images
from spython.image.cmd import generate_image_commands # deprecated

client.image = generate_image_commands()

# Commands Groups, Instances
from spython.instance.cmd import (
generate_instance_commands,
Expand All @@ -61,24 +54,22 @@ def get_client(quiet=False, debug=False):
client.instance.version = client.version

# Commands Groups, OCI (Singularity version 3 and up)
if "version 3" in get_singularity_version():
from spython.oci.cmd import generate_oci_commands
from spython.oci.cmd import generate_oci_commands

client.oci = generate_oci_commands()() # first () runs function, second
# initializes OciImage class
client.oci.debug = client.debug
client.oci.quiet = client.quiet
client.oci.OciImage.quiet = client.quiet
client.oci.OciImage.debug = client.debug
client.oci = generate_oci_commands()() # first () runs function, second
# initializes OciImage class
client.oci.debug = client.debug
client.oci.quiet = client.quiet
client.oci.OciImage.quiet = client.quiet
client.oci.OciImage.debug = client.debug

# Initialize
cli = client()

# Pass on verbosity
for subclient in [cli.image, cli.instance]:
subclient.debug = cli.debug
subclient.quiet = cli.quiet
subclient.version = cli.version
cli.instance.debug = cli.debug
cli.instance.quiet = cli.quiet
cli.instance.version = cli.version

return cli

Expand Down
3 changes: 0 additions & 3 deletions spython/main/build.py
Expand Up @@ -67,9 +67,6 @@ def build(
# If no extra options
options = options or []

if "version 3" in self.version():
ext = "sif"

# Force the build if the image / sandbox exists
if force:
cmd.append("--force")
Expand Down

0 comments on commit 1daab24

Please sign in to comment.