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

Watch mode (--interval) #41

Merged
merged 5 commits into from
Aug 18, 2018
Merged

Watch mode (--interval) #41

merged 5 commits into from
Aug 18, 2018

Conversation

wookayin
Copy link
Owner

@wookayin wookayin commented Jun 14, 2018

Adds -i / --interval to support built-in watch feature.

Based on @drons 's PR #30.

drons and others added 3 commits June 13, 2018 20:42
This is a rebased and squashed commit from dron's `loop` branch.
Related PR: #30
Previous implementation of watch mode by @drons (#30) had a blinking
problem because of clearing the screen. Instead, we use clear_eol
and clear_eos to paint over the existing text in the screen and
clear only as necessary, the blinking problem will be gone.
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',
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Owner Author

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.

@@ -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:
Copy link
Collaborator

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.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good idea.

@Stonesjtu
Copy link
Collaborator

The doc needs an update too.

@Stonesjtu
Copy link
Collaborator

LGTM, but the README needs an update to show-off new option.

@wookayin wookayin merged commit 5106181 into master Aug 18, 2018
wookayin added a commit that referenced this pull request Aug 18, 2018
Watch mode (--interval) support

Conflicts:
	gpustat/__main__.py
@wookayin
Copy link
Owner Author

Merged into master.

@wookayin wookayin deleted the drons-loop branch September 10, 2018 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants