Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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)
- 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)
Expand Down
5 changes: 3 additions & 2 deletions spython/instance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions spython/instance/cmd/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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"),...]

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spython/instance/cmd/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion spython/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down