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

Add output to signal if a test result was cached #13588

Closed
joshua-cannon-techlabs opened this issue Nov 11, 2021 · 13 comments · Fixed by #13889
Closed

Add output to signal if a test result was cached #13588

joshua-cannon-techlabs opened this issue Nov 11, 2021 · 13 comments · Fixed by #13889

Comments

@joshua-cannon-techlabs
Copy link

Is your feature request related to a problem? Please describe.
Coming from Bazelland, it was very nice to see which tests actually ran and which ones didn't due to caching.

Output looks roughly like:

//a/b/c/d:e_test        (cached) PASSED in 29.5s
//a/b:c_test            (cached) PASSED in 1.6s
//a/b/c/d:e2_test                PASSED in 2.8s
//a/b/c:d_test                   PASSED in 16.0s

This raised the confidence in the build tool's ability to cache entire test runs, and in our understanding of the cache invalidation.

Describe the solution you'd like
A similar output for ./pants test (maybe other rules as well, lint/fmt/etc...).

Describe alternatives you've considered
The stats helps, but isn't quite the same.

Additional context
N/A

@joshua-cannon-techlabs
Copy link
Author

Additionally, the feature could use different signaling for "memoized" vs. "cached".

@stuhood
Copy link
Member

stuhood commented Nov 11, 2021

We should definitely do this, yea. In fact, I promised @g-cassie I'd open a ticket about it a while back... oops. Thanks!

@stuhood
Copy link
Member

stuhood commented Nov 11, 2021

#13590 exposes the information needed to do this. In a followup change, the TestResult type (and any others for which this information might be rendered) should begin carrying along ProcessResultMetadata, and the test goal should request the RunId, and consume the metadata to render cache status and runtime.

stuhood added a commit that referenced this issue Nov 12, 2021
To prepare for #13588, exposes the `ProcessResultMetadata` type to `Python`, and adds the `RunId` that a `ProcessResult` was generated in to its metadata.

Collectively, this will allow `@rule` code which is interested in being invalidated for every run (probably only `@goal_rule`s) to render information about whether processes hit the cache, or were memoized.
@stuhood
Copy link
Member

stuhood commented Nov 12, 2021

I'm going to have to focus on other things for a bit. Maybe someone else would be interested in picking up the rendering changes, as described above?

@stuhood stuhood removed their assignment Nov 12, 2021
@riisi
Copy link
Contributor

riisi commented Dec 5, 2021

@stuhood Had a quick play with this, looks straightforward. But not sure how to get the current process run id though in the test goal - per "the test goal should request the RunId".

@stuhood
Copy link
Member

stuhood commented Dec 6, 2021

@stuhood Had a quick play with this, looks straightforward. But not sure how to get the current process run id though in the test goal - per "the test goal should request the RunId".

Ah, yea: sorry that that wasn't clear!

#13590 added an intrinsic that exposes RunId as a singleton. To consume a singleton (or any other type which can be computed using what is already in scope), you put it in the argument list of your @rule. So:

@goal_rule
def run_tests(
    console: Console,
    ..,
    run_id: RunId,  # NEW
) -> TestGoal:
    ..

@yoav-orca
Copy link
Contributor

@riisi do you intend to implement this?

@riisi
Copy link
Contributor

riisi commented Dec 11, 2021 via email

@riisi
Copy link
Contributor

riisi commented Dec 12, 2021

Thoughts on this layout? I'd slightly prefer columns like the Bazel output but this is the least change to get this in, and I don't want to mis-align with the outputs from the other goals - that might require a larger discussion.

image

The possible cache results are ran_locally, memoized, hit_locally, and hit_remote. Suggest these should be translated for console output as

  • <no print output if ran locally>
  • (memoized)
  • (cached locally)
  • (cached remote)

@yoav-orca
Copy link
Contributor

@riisi I would appreciate a sort-by option, where you can get the final output sorted by time

@benjyw
Copy link
Contributor

benjyw commented Dec 12, 2021

BTW you absolutely can add columns (in a followup) if you like. There is no requirement that different goal outputs be consistent, and they aren't really today.

@benjyw
Copy link
Contributor

benjyw commented Dec 12, 2021

I'd say "cached remotely", so it mirrors "cached locally"?

@Eric-Arellano
Copy link
Contributor

BTW you absolutely can add columns (in a followup) if you like.

A concern I'd have is when your terminal isn't wide enough, that wrapping might look even worse. We intentionally use soft wrapping with the output of test so that the shell handles wrapping for us.

That's probably not a show stopper and I think that columns would be a net win. Although, doing it in a dedicated followup probably makes sense.

stuhood pushed a commit that referenced this issue Dec 27, 2021
Fixes #13588.

[ci skip-rust]
[ci skip-build-wheels]
stuhood pushed a commit to stuhood/pants that referenced this issue Dec 27, 2021
stuhood added a commit that referenced this issue Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants