chore(bigquery): add dynamic logging banner to nox mypy session - #17492
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a log_package_context context manager in noxfile.py to log a package context banner upon Nox session completion, applying it to the mypy session. The feedback suggests replacing os.getcwd() with pathlib.Path(file).parent.name to ensure the package name is correctly resolved even when Nox is executed from outside the package directory.
fb9bf56 to
042e991
Compare
There was a problem hiding this comment.
Could we handle this globally in run_conditional_tests.sh?
If we print the banner right after the test script completes, it will output right next to the Nox final exit summary. This gives us instant coverage for all packages and all sessions with a 1-2 lines of bash code.
https://github.com/googleapis/google-cloud-python/compare/main...testing-ci?quick_pull=1
This PR adds a dynamic logging banner `Finished session for <package>` to nox `mypy` sessions in `bigquery` to simplify troubleshooting. Currently when a nox session runs, there may be many lines of text between a reference to which package is being tested and the result summary line. This can make it more difficult to determine which package is affected without a lot of manual scrolling (every time you need to trouble shoot an issue). This is especially true if you use `Ctrl+F` to zoom over to summaries with words like `failed`. ``` change detected in packages/bigframes/ [many lines of text...] 2547 passed, 157 skipped, 9 xfailed, 1 xpassed, 586 warnings in 136.68s (0:02:16) nox > Session unit-3.11(test_extra=True) failed in 3 minutes. ``` The PR adds a banner line right before the nox result summary: ``` change detected in packages/bigframes/ [many lines of text...] 2547 passed, 157 skipped, 9 xfailed, 1 xpassed, 586 warnings in 136.68s (0:02:16) nox > Finished session for bigframes # NEW LINE, right before the summary line nox > Session unit-3.11(test_extra=True) failed in 3 minutes. ``` > [!note] > There is no convenient way to inject a log line into the nox session and have it print **exactly** where you want. Also, because the long term intent is to add this to all nox sessions I included an easy to apply `contextmanager` to ensure the correct placement of the new logging banner. > [!note] > This PR only adds this capability to a single nox session (`mypy`) and a single handwritten package (`bigquery`). I did not want to invest a lot of time unless the team feels it is beneficial. In which case, we can add a task the next sprint to make this a global change.
This PR adds a dynamic logging banner
Finished session for <package>to nox
mypysessions inbigqueryto simplify troubleshooting.Currently when a nox session runs, there may be many lines of text between a reference to which package is being tested and the result summary line. This can make it more difficult to determine which package is affected without a lot of manual scrolling (every time you need to trouble shoot an issue). This is especially true if you use
Ctrl+Fto zoom over to summaries with words likefailed.The PR adds a banner line right before the nox result summary:
Note
There is no convenient way to inject a log line into the nox session and have it print exactly where you want. Also, because the long term intent is to add this to all nox sessions I included an easy to apply
contextmanagerto ensure the correct placement of the new logging banner.Note
This PR only adds this capability to a single nox session (
mypy) and a single handwritten package (bigquery). I did not want to invest a lot of time unless the team feels it is beneficial. In which case, we can add a task the next sprint to make this a global change.