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

feat: improve ta_storage.bigquery #1017

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

joseph-sentry
Copy link
Contributor

  • generalize the way bigquery accepts query parameters
  • change type of params arg in bigquery_service to sequence
  • feat: add upload_id field to ta_testrun protobuf
  • add flags_hash field to ta_testrun protobuf
  • create new testid generation function
  • add test_id to ta_testrun proto
  • add flaky_failure to testrun protobuf
  • handle flaky failures in ta_storage.bq
  • create sql queries for reading from bq
  • write tests for ta_storage.bq aggregate queries

- generalize the way bigquery accepts query parameters
- change type of params arg in bigquery_service to sequence
- feat: add upload_id field to ta_testrun protobuf
- add flags_hash field to ta_testrun protobuf
- create new testid generation function
- add test_id to ta_testrun proto
- add flaky_failure to testrun protobuf
- handle flaky failures in ta_storage.bq
- create sql queries for reading from bq
- write tests for ta_storage.bq aggregate queries
@codecov-notifications
Copy link

Codecov Report

Attention: Patch coverage is 41.21212% with 97 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
ta_storage/tests/test_bq.py 18.07% 68 Missing ⚠️
ta_storage/bq.py 65.85% 14 Missing ⚠️
services/tests/test_bigquery.py 40.00% 6 Missing ⚠️
generated_proto/testrun/ta_testrun_pb2.py 28.57% 5 Missing ⚠️
ta_storage/utils.py 84.21% 3 Missing ⚠️
services/bigquery.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 41.21212% with 97 lines in your changes missing coverage. Please review.

Project coverage is 97.54%. Comparing base (a03a9b9) to head (7e31388).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
ta_storage/tests/test_bq.py 18.07% 68 Missing ⚠️
ta_storage/bq.py 65.85% 14 Missing ⚠️
services/tests/test_bigquery.py 40.00% 6 Missing ⚠️
generated_proto/testrun/ta_testrun_pb2.py 28.57% 5 Missing ⚠️
ta_storage/utils.py 84.21% 3 Missing ⚠️
services/bigquery.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1017      +/-   ##
==========================================
- Coverage   97.78%   97.54%   -0.24%     
==========================================
  Files         451      452       +1     
  Lines       36913    37064     +151     
==========================================
+ Hits        36095    36155      +60     
- Misses        818      909      +91     
Flag Coverage Δ
integration 42.42% <40.60%> (-0.03%) ⬇️
unit 90.07% <41.21%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

⚠️ Impact Analysis from Codecov is deprecated and will be sunset on Jan 31 2025. See more

Copy link

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@joseph-sentry joseph-sentry requested a review from a team January 21, 2025 18:00
@@ -27,4 +28,8 @@ message TestRun {

optional string filename = 14;
optional string framework = 15;

optional int64 upload_id = 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a specific reason why all the fields ar optional, is this for forward compatiblity reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

protobuf generally prefers fields to be optional, if a field is marked as required then it's required forever: context



def calc_flags_hash(flags: list[str]) -> bytes | None:
flags_str = " ".join(flags) # we know that flags cannot contain spaces
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
flags_str = " ".join(flags) # we know that flags cannot contain spaces
flags_str = " ".join(sorted(flags)) # we know that flags cannot contain spaces

just to make sure sort order is consistent. not sure if that might already be guaranteed from the caller?

# we only need the first one
flags_hash, _ = mmh3.hash64(flags_str)
try:
flags_hash_bytes = flags_hash.to_bytes(8, byteorder)
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use a fixed byteorder instead of using the system one.

try:
flags_hash_bytes = flags_hash.to_bytes(8, byteorder)
return flags_hash_bytes
except OverflowError as e: # this should never happen because hash64 should always return 2 64 bit ints
Copy link
Contributor

Choose a reason for hiding this comment

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

I think OverflowError is the wrong exception (according to docs https://docs.python.org/3/library/exceptions.html#OverflowError) in case of destructuring assignments.

As the comment says, if this ever fails, its a bug in the underlying package, so I’m okay with just not catching this.

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