Skip to content

Commit 130366c

Browse files
authored
adding more verbosity for instance start/stop commands (#175)
Signed-off-by: vsoch <[email protected]> Co-authored-by: vsoch <[email protected]>
1 parent d17ed1e commit 130366c

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
1717
singularity on pypi), and the versions here will coincide with these releases.
1818

1919
## [master](https://github.com/singularityhub/singularity-cli/tree/master)
20+
- add more verbosity to instance start/stop (0.0.12)
2021
- adding more verbosity to running commands (0.1.11)
2122
- log error paths are optional (0.1.1)
2223
- instance list doesn't always include container_image (0.1.0)

spython/instance/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Instance(ImageBase):
13-
def __init__(self, image, start=True, name=None, **kwargs):
13+
def __init__(self, image, start=True, name=None, quiet=True, **kwargs):
1414
"""An instance is an image running as an instance with services.
1515
This class has functions appended under cmd/__init__ and is
1616
instantiated when the user calls Client.
@@ -30,10 +30,11 @@ def __init__(self, image, start=True, name=None, **kwargs):
3030
self._update_metadata(kwargs)
3131
self.options = []
3232
self.cmd = []
33+
self.quiet = quiet
3334

3435
# Start the instance
3536
if start:
36-
self.start(**kwargs)
37+
self.start(quiet=quiet, **kwargs)
3738

3839
# Unique resource identifier
3940

spython/instance/cmd/start.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def start(
1919
capture=False,
2020
singularity_options=None,
2121
environ=None,
22+
quiet=True,
2223
):
2324
"""start an instance. This is done by default when an instance is created.
2425
@@ -30,6 +31,7 @@ def start(
3031
capture: capture output, default is False. With True likely to hang.
3132
args: arguments to provide to the instance (supported Singularity 3.1+)
3233
singularity_options: a list of options to provide to the singularity client
34+
quiet: Do not print verbose output.
3335
options: a list of tuples, each an option to give to the start command
3436
[("--bind", "/tmp"),...]
3537
@@ -74,6 +76,10 @@ def start(
7476
args = [args]
7577
cmd = cmd + args
7678

79+
# Print verbose output
80+
if not (quiet or self.quiet):
81+
bot.info(" ".join(cmd))
82+
7783
# Save the options and cmd, if the user wants to see them later
7884
self.options = options
7985
self.args = args

spython/instance/cmd/stop.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def stop(
1515
sudo_options=None,
1616
timeout=None,
1717
singularity_options=None,
18+
quiet=True,
1819
):
1920
"""stop an instance. This is done by default when an instance is created.
2021
@@ -23,6 +24,7 @@ def stop(
2324
name: a name for the instance
2425
sudo: if the user wants to run the command with sudo
2526
singularity_options: a list of options to provide to the singularity client
27+
quiet: Do not print verbose output.
2628
timeout: forcebly kill non-stopped instance after the
2729
timeout specified in seconds
2830
@@ -49,6 +51,10 @@ def stop(
4951
instance_name = name
5052
cmd = cmd + [instance_name]
5153

54+
# Print verbose output
55+
if not (quiet or self.quiet):
56+
bot.info(" ".join(cmd))
57+
5258
output = run_command(cmd, sudo=sudo, sudo_options=sudo_options, quiet=True)
5359

5460
if output["return_code"] != 0:

spython/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77

8-
__version__ = "0.1.11"
8+
__version__ = "0.1.12"
99
AUTHOR = "Vanessa Sochat"
1010
AUTHOR_EMAIL = "[email protected]"
1111
NAME = "spython"

0 commit comments

Comments
 (0)