Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power options cleanup #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ For older versions (python 2.7, <3.4), you can continue using gpustat v0.x.
[gh-issue-66]: https://github.com/wookayin/gpustat/issues/66


Tests
-----

To run the test suite, execute `PYTEST_ADDOPTS="-s" python setup.py test`
Stonesjtu marked this conversation as resolved.
Show resolved Hide resolved


Changelog
---------

Expand Down
8 changes: 4 additions & 4 deletions gpustat/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def main(*argv):
parser.add_argument(
'-e', '--show-codec', nargs='?', const='enc,dec', default='',
choices=['', 'enc', 'dec', 'enc,dec'],
help='Show encoder/decoder utilization'
help='Show encoder and/or decoder utilization'
)
parser.add_argument(
'-P', '--show-power', nargs='?', const='draw,limit',
choices=['', 'draw', 'limit', 'draw,limit', 'limit,draw'],
help='Show GPU power usage or draw (and/or limit)'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was never and/or limit. If limit is included, then draw is also always included.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean passing limit and draw, limit gives the same output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (limit,draw as well, but I removed that in this PR)

'-P', '--show-power', nargs='?', const='draw,limit', default='',
choices=['', 'draw', 'limit', 'draw,limit'],
help='Show GPU power usage or draw (and limit)'
)
parser.add_argument('--json', action='store_true', default=False,
help='Print all the information in JSON format')
Expand Down
6 changes: 3 additions & 3 deletions gpustat/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def print_to(self, fp,
show_pid=False,
show_fan_speed=None,
show_codec="",
show_power=None,
show_power="",
gpuname_width=16,
term=None,
):
Expand Down Expand Up @@ -264,7 +264,7 @@ def _repr(v, none_value='??'):

if show_power:
reps += ", %(CPowU)s{entry[power.draw]:>3}%(C0)s "
if show_power is True or 'limit' in show_power:
if 'limit' in show_power:
reps += "/ %(CPowL)s{entry[enforced.power.limit]:>3}%(C0)s "
reps += "%(CPowL)sW%(C0)s"
else:
Expand Down Expand Up @@ -539,7 +539,7 @@ def __repr__(self):
def print_formatted(self, fp=sys.stdout, force_color=False, no_color=False,
show_cmd=False, show_full_cmd=False, show_user=False,
show_pid=False, show_fan_speed=None,
show_codec="", show_power=None,
show_codec="", show_power="",
gpuname_width=16, show_header=True,
eol_char=os.linesep,
):
Expand Down
4 changes: 2 additions & 2 deletions gpustat/test_gpustat.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_new_query_mocked(self, scenario_basic):
gpustats.print_formatted(
fp=fp, no_color=False, show_user=True,
show_cmd=True, show_full_cmd=True, show_pid=True,
show_fan_speed=True, show_codec="enc,dec", show_power=True,
show_fan_speed=True, show_codec="enc,dec", show_power="limit",
)

result = fp.getvalue()
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_args_commandline_showoptions(self, scenario_basic):
TEST_OPTS = []
TEST_OPTS += ['-a', '-c', '-u', '-p', '-e', '-P', '-f']
TEST_OPTS += [('-e', ''), ('-P', '')]
TEST_OPTS += [('-e', 'enc,dec'), '-Plimit,draw']
TEST_OPTS += [('-e', 'enc,dec'), '-Pdraw,limit']
TEST_OPTS += ['-cup', '-cpu', '-cufP'] # 'cpuePf'

for opt in TEST_OPTS:
Expand Down