diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a4db1..2fb458b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) + - add more verbosity to instance start/stop (0.0.12) - adding more verbosity to running commands (0.1.11) - log error paths are optional (0.1.1) - instance list doesn't always include container_image (0.1.0) diff --git a/spython/instance/__init__.py b/spython/instance/__init__.py index b7b2d7d..3e67f75 100644 --- a/spython/instance/__init__.py +++ b/spython/instance/__init__.py @@ -10,7 +10,7 @@ class Instance(ImageBase): - def __init__(self, image, start=True, name=None, **kwargs): + def __init__(self, image, start=True, name=None, quiet=True, **kwargs): """An instance is an image running as an instance with services. This class has functions appended under cmd/__init__ and is instantiated when the user calls Client. @@ -30,10 +30,11 @@ def __init__(self, image, start=True, name=None, **kwargs): self._update_metadata(kwargs) self.options = [] self.cmd = [] + self.quiet = quiet # Start the instance if start: - self.start(**kwargs) + self.start(quiet=quiet, **kwargs) # Unique resource identifier diff --git a/spython/instance/cmd/start.py b/spython/instance/cmd/start.py index 77fc94b..096319e 100644 --- a/spython/instance/cmd/start.py +++ b/spython/instance/cmd/start.py @@ -19,6 +19,7 @@ def start( capture=False, singularity_options=None, environ=None, + quiet=True, ): """start an instance. This is done by default when an instance is created. @@ -30,6 +31,7 @@ def start( capture: capture output, default is False. With True likely to hang. args: arguments to provide to the instance (supported Singularity 3.1+) singularity_options: a list of options to provide to the singularity client + quiet: Do not print verbose output. options: a list of tuples, each an option to give to the start command [("--bind", "/tmp"),...] @@ -74,6 +76,10 @@ def start( args = [args] cmd = cmd + args + # Print verbose output + if not (quiet or self.quiet): + bot.info(" ".join(cmd)) + # Save the options and cmd, if the user wants to see them later self.options = options self.args = args diff --git a/spython/instance/cmd/stop.py b/spython/instance/cmd/stop.py index 9638b0f..5bc6091 100644 --- a/spython/instance/cmd/stop.py +++ b/spython/instance/cmd/stop.py @@ -15,6 +15,7 @@ def stop( sudo_options=None, timeout=None, singularity_options=None, + quiet=True, ): """stop an instance. This is done by default when an instance is created. @@ -23,6 +24,7 @@ def stop( name: a name for the instance sudo: if the user wants to run the command with sudo singularity_options: a list of options to provide to the singularity client + quiet: Do not print verbose output. timeout: forcebly kill non-stopped instance after the timeout specified in seconds @@ -49,6 +51,10 @@ def stop( instance_name = name cmd = cmd + [instance_name] + # Print verbose output + if not (quiet or self.quiet): + bot.info(" ".join(cmd)) + output = run_command(cmd, sudo=sudo, sudo_options=sudo_options, quiet=True) if output["return_code"] != 0: diff --git a/spython/version.py b/spython/version.py index c0c3583..892de27 100644 --- a/spython/version.py +++ b/spython/version.py @@ -5,7 +5,7 @@ # with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -__version__ = "0.1.11" +__version__ = "0.1.12" AUTHOR = "Vanessa Sochat" AUTHOR_EMAIL = "vsochat@stanford.edu" NAME = "spython"