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
Fix bug background workunits were printed in UI #7997
Fix bug background workunits were printed in UI #7997
Conversation
@@ -246,6 +246,18 @@ def root(self): | |||
ret = ret.parent | |||
return ret | |||
|
|||
def is_background(self, background_root_workunit): |
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.
I recommend using a keyword only arg here, so that callers must use a kwarg.
def is_background(self, background_root_workunit): | |
def is_background(self, *, background_root_workunit): |
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.
This is a required parameter of a particular type, rather than a boolean or optional parameter. So I'm not sure I agree in this case.
But @cattibrie : it would be good to add a docstring for this method.
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.
@Eric-Arellano Is it likely to ever accept more than one argument? I think that if not (it seems not), then a positional param seems ok (with a docstring, as above).
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.
Eh after typing up the below example, I agree that yes it's fine to not use kwarg only here:
lint_workunit.is_background(compile_workunit)
lint_workunit.is_background(background_root_workunit=compile_workunit)
--
However, in general, want to respond to this:
This is a required parameter of a particular type, rather than a boolean or optional parameter.
True, but there is often (not always) value in enforcing kwarg only for required parameters too. For example, from strutil.py
:
def strip_prefix(string: str, prefix: str) -> str: ...
strip_prefix("hello world", "hello")
strip_prefix("hello world", prefix="hello")
You can of course figure it out with the first version, but the second has no ambiguity and I would argue is worth the extra few characters.
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.
@Eric-Arellano : If the arguments had different types, explicitly naming them would be slightly less valuable though: that's what I was referring to here.
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.
Thanks!
@@ -246,6 +246,18 @@ def root(self): | |||
ret = ret.parent | |||
return ret | |||
|
|||
def is_background(self, background_root_workunit): |
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.
This is a required parameter of a particular type, rather than a boolean or optional parameter. So I'm not sure I agree in this case.
But @cattibrie : it would be good to add a docstring for this method.
src/python/pants/base/workunit.py
Outdated
""" | ||
:API: public | ||
""" | ||
ret = self |
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.
Thanks @cattibrie !
nit: let's rename ret
(to curr_workunit
?), since it no longer carries the meaning of the possible return value, unlike the methods above.
af0a10b
to
4c2f332
Compare
)" This reverts commit 1d5b343.
Problem
Background workunits were present in UI output. The reason is that background root workunit start to have a parent - main thread root.
Solution
Print workunit label in UI only if it is not under the background root workunit.