-
Notifications
You must be signed in to change notification settings - Fork 286
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
Watch mode (--interval) #41
Conversation
This is a rebased and squashed commit from dron's `loop` branch. Related PR: #30
gpustat/core.py
Outdated
@@ -379,6 +379,8 @@ def print_formatted(self, fp=sys.stdout, force_color=False, no_color=False, | |||
show_cmd=False, show_user=False, show_pid=False, | |||
show_power=None, gpuname_width=16, | |||
show_header=True, | |||
eol_char='\n', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this eol character portable for OS other than POSIX? I think windows use '\n\r' or '\r\n'. However, it doesn't matter if we target on only POSIX systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.linesep
can be a better choice of default parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was previously just '\n'. I would say POSIX systems are just targetted, but totally fine with using os.linesep
.
gpustat/__main__.py
Outdated
@@ -66,7 +71,27 @@ def main(*argv): | |||
version=('gpustat %s' % __version__)) | |||
args = parser.parse_args(argv[1:]) | |||
|
|||
print_gpustat(**vars(args)) | |||
if args.interval > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be better to have a minimal interval of 0.1 sec like watch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
The doc needs an update too. |
LGTM, but the README needs an update to show-off new option. |
Watch mode (--interval) support Conflicts: gpustat/__main__.py
Merged into master. |
Adds
-i
/--interval
to support built-in watch feature.Based on @drons 's PR #30.