Skip to content

chore(bigquery): add dynamic logging banner to nox mypy session - #17492

Merged
chalmerlowe merged 3 commits into
mainfrom
feat/bigquery-mypy-banner
Jun 23, 2026
Merged

chore(bigquery): add dynamic logging banner to nox mypy session#17492
chalmerlowe merged 3 commits into
mainfrom
feat/bigquery-mypy-banner

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/google-cloud-bigquery/noxfile.py Outdated
@chalmerlowe
chalmerlowe force-pushed the feat/bigquery-mypy-banner branch 9 times, most recently from fb9bf56 to 042e991 Compare June 18, 2026 14:44
@chalmerlowe
chalmerlowe marked this pull request as ready for review June 19, 2026 11:29
@chalmerlowe
chalmerlowe requested review from a team as code owners June 19, 2026 11:29
@chalmerlowe
chalmerlowe requested review from GarrettWu and removed request for a team June 19, 2026 11:29

@parthea parthea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@chalmerlowe
chalmerlowe merged commit 8826494 into main Jun 23, 2026
31 checks passed
@chalmerlowe
chalmerlowe deleted the feat/bigquery-mypy-banner branch June 23, 2026 17:37
chalmerlowe added a commit that referenced this pull request Jun 25, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants