Skip to content

Add statistics information for individual checks (especially time of execution) #1144

Closed

Description

@potiuk

I would love to have an option to add some statistics to be displayed for each check. This could be very useful for running pre-commit in CI. I had a case recently of a check that run accidentally a bit longer than expected (it was building unnecessary docker image) and I have not realised that it is taking longer - because we had other checks after and I could only see the total execution time.

Also some other useful information that we might see is how many parallel processes were run and how many files were passed as parameters. This might be really useful especially for people who do not understand that pre-commit runs in parallel by default - this can have some undesireable side effects if you forget to set "require_serial" to True when you need. And seeing that in the output of CI might immediately show that something is wrong. For now the output is a bit of "black-box".

An option to see some additional information (--add-statistics) might be super-useful.

Example output I imagine (maybe a bit better aligned):

Check if image build is needed...........................................Passed [23.5s, 1 process, no-files]  
Add licence for all JINJA template files.................................Passed [2.25s, 8 processes, 48 files]
Check Shell scripts syntax correctness...................................Passed [6.00s, 8 processes, 10 files]
Lint dockerfile..........................................................Passed [2.20s, 3 processes, 3 files]
Run mypy.................................................................Passed [12.00s, 8 processes, 1456 files]
Run pylint for main sources.............................................Skipped 
Run pylint for tests....................................................Skipped
Run flake8...............................................................Passed [24.05s, 8 processes, 1456 files]

Activity

  1. potiuk commented on Sep 22, 2019

    @potiuk
    Author

    Happy to contribute it if there is an agreement to add it :)

  2. asottile commented on Sep 22, 2019

    @asottile
    Member

    the output is intentionally quiet and I don't want to change that, your proposal also makes things no longer line up

    maybe just add this to verbose if at all ?

  3. potiuk commented on Sep 22, 2019

    @potiuk
    Author

    verbose is .... far too verbose. It's great to see only "passed" but then having some stats, would make it also actionable for cases that are "valid properties" of the check rather than just passed/failed status. Most of the UnitTest frameworks have such feature to display for example the timing.

    And it is perfectly ok to have a separate switch for that and do not have it in the output by default. I think it might be really useful for the CI case I described.

  4. asottile commented on Sep 22, 2019

    @asottile
    Member

    I don't want a combinatoric explosion of options, especially ones I'm not going to use

  5. asottile commented on Sep 22, 2019

    @asottile
    Member

    if it's only for CI who cares how verbose it is?

  6. potiuk commented on Sep 22, 2019

    @potiuk
    Author

    I think it might be useful for local pre-commits as well, but the main usage scenario for this flag I foresee for CI case. We are currently using it with --all-files --show-diff-on-failure and it works great (minimum output + we see exact diffs when diff-failure happens).

    In this case I only found out that we have a problem because the build steps were running for a really long time and failed (but I would immediately see the problem if I had the stats).
    In my particular case we have the "build needed check" (see the #1143 ) and when it does not need to rebuild the image it will be "passed" in ms. But if (happened in my case) due to bug in build need detection it took maybe 2-3 minutes. - I would immediately see this with statistics but in case of our build the only thing i could see is "passed" without knowing how much time this particular check took.

    BTW. I have found that having CI build for pre-commit is great promotor of pre-commit in general - because when something fails, installing pre-commit and running that failed check is simplest way to do (and pre-commit nicely suggests that action). But CI is also good to observe if other build properties are met.

  7. asottile commented on Sep 23, 2019

    @asottile
    Member

    I don't want another option, let's add it to verbose output

  8. blueyed commented on Nov 22, 2019

    @blueyed
  9. asottile commented on Nov 22, 2019

    @asottile
    Member

    please read the discussion -- I've already said no to that

  10. blueyed commented on Nov 22, 2019

    @blueyed
  11. deleted a comment from blueyed on Nov 22, 2019
  12. asottile commented on Nov 22, 2019

    @asottile
    Member

    please stay on topic, thanks

  13. blueyed commented on Nov 22, 2019

    @blueyed
  14. 34 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions