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

Fix bug background workunits were printed in UI #7997

Merged

Conversation

Projects
None yet
6 participants
@cattibrie
Copy link
Contributor

commented Jul 2, 2019

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.

@@ -246,6 +246,18 @@ def root(self):
ret = ret.parent
return ret

def is_background(self, background_root_workunit):

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Jul 2, 2019

Contributor

I recommend using a keyword only arg here, so that callers must use a kwarg.

Suggested change
def is_background(self, background_root_workunit):
def is_background(self, *, background_root_workunit):

This comment has been minimized.

Copy link
@stuhood

stuhood Jul 2, 2019

Member

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.

This comment has been minimized.

Copy link
@cosmicexplorer

cosmicexplorer Jul 2, 2019

Contributor

@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).

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Jul 2, 2019

Contributor

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.

This comment has been minimized.

Copy link
@stuhood

stuhood Jul 2, 2019

Member

@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.

@stuhood

stuhood approved these changes Jul 2, 2019

Copy link
Member

left a comment

Thanks!

@@ -246,6 +246,18 @@ def root(self):
ret = ret.parent
return ret

def is_background(self, background_root_workunit):

This comment has been minimized.

Copy link
@stuhood

stuhood Jul 2, 2019

Member

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.

"""
:API: public
"""
ret = self

This comment has been minimized.

Copy link
@wisechengyi

wisechengyi Jul 2, 2019

Contributor

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.

@cattibrie cattibrie force-pushed the cattibrie:etyurina/background_workunits_in_ui branch from af0a10b to 4c2f332 Jul 3, 2019

@illicitonion illicitonion merged commit 1d5b343 into pantsbuild:master Jul 4, 2019

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

cosmicexplorer added a commit to cosmicexplorer/pants that referenced this pull request Jul 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.