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: add capability for writing to bigquery #993

Merged
merged 3 commits into from
Jan 9, 2025
Merged

Conversation

joseph-sentry
Copy link
Contributor

this PR:

  • creates the lower level glue between our code and BQ in the form of the BigQueryService
  • creates an abstraction for persisting testruns and implements it for both BQ and PG

@joseph-sentry joseph-sentry marked this pull request as ready for review January 7, 2025 21:59
@joseph-sentry joseph-sentry requested a review from a team January 7, 2025 21:59
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 71.47436% with 89 lines in your changes missing coverage. Please review.

Project coverage is 97.74%. Comparing base (e1d597d) to head (0efb81c).
Report is 5 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
services/bigquery.py 25.80% 46 Missing ⚠️
services/tests/test_bigquery.py 40.54% 22 Missing ⚠️
ta_storage/pg.py 88.54% 11 Missing ⚠️
generated_proto/testrun/ta_testrun_pb2.py 72.22% 5 Missing ⚠️
ta_storage/bq.py 90.24% 4 Missing ⚠️
ta_storage/base.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #993      +/-   ##
==========================================
- Coverage   97.96%   97.74%   -0.22%     
==========================================
  Files         446      454       +8     
  Lines       36045    36368     +323     
==========================================
+ Hits        35311    35548     +237     
- Misses        734      820      +86     
Flag Coverage Δ
integration 42.01% <38.46%> (-0.02%) ⬇️
unit 90.46% <71.47%> (-0.18%) ⬇️

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

@codecov-staging
Copy link

codecov-staging bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 71.47436% with 89 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
services/bigquery.py 25.80% 46 Missing ⚠️
services/tests/test_bigquery.py 40.54% 22 Missing ⚠️
ta_storage/pg.py 88.54% 11 Missing ⚠️
generated_proto/testrun/ta_testrun_pb2.py 72.22% 5 Missing ⚠️
ta_storage/bq.py 90.24% 4 Missing ⚠️
ta_storage/base.py 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jan 7, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1 1 0 0
View the top 1 failed tests by shortest run time
ta_storage/tests/test_pg.py::ta_storage.tests.test_pg
Stack Traces | 0s run time
ImportError while importing test module '.../ta_storage/tests/test_pg.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.../local/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ta_storage/tests/test_pg.py:3: in <module>
    from ta_storage.pg import PGDriver
ta_storage/pg.py:4: in <module>
    from msgpack import unpackb
E   ModuleNotFoundError: No module named 'msgpack'

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1 1 0 0
View the top 1 failed tests by shortest run time
ta_storage/tests/test_pg.py::::ta_storage.tests.test_pg
Stack Traces | 0s run time
No failure message available

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

github-actions bot commented Jan 7, 2025

✅ All tests successful. No failed tests were found.

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

this is an abstraction to help us use bigquery for test analytics data

this abstraction allows us to write data to bigquery using the Storage
Write API and query it using SQL statements as strings, it also handles
creating the connection to bigquery for us

the use protocol buffers is a consequence of using the Storage Write API

feat: create TADriver abstraction

this commit creates the TADriver abstraction which (for now) exposes a
write_testruns method, which will take care of persisting a list of
testruns to some specific storage

this commit implements this interface for Postgres and for Bigquery

the idea is that we will start by persisting testruns to both, then
eventually we add a method to the interface for retrieving the
aggregates at which point it will be safe for our cloud offering to
switch over to only bigquery for storage of TA testruns.
protobuf/sample.proto Outdated Show resolved Hide resolved
protobuf/ta_testrun.proto Outdated Show resolved Hide resolved
requirements.in Outdated Show resolved Hide resolved
ta_storage/base.py Outdated Show resolved Hide resolved
ta_storage/pg.py Outdated Show resolved Hide resolved
ta_storage/bq.py Outdated Show resolved Hide resolved
ta_storage/pg.py Outdated Show resolved Hide resolved
batch_commit_write_streams_request.parent = parent
batch_commit_write_streams_request.write_streams = [write_stream.name]

self.write_client.batch_commit_write_streams(batch_commit_write_streams_request)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the complexity specific for batch_commit_write_streams? I mean wholy sh…, this API is convoluted and overly complex.

Can you point to the docs related to inserting / batch-writing to bigquery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

services/tests/test_bigquery.py Outdated Show resolved Hide resolved
services/tests/test_bigquery.py Outdated Show resolved Hide resolved
@joseph-sentry joseph-sentry added this pull request to the merge queue Jan 9, 2025
Merged via the queue into main with commit 78ce991 Jan 9, 2025
14 of 27 checks passed
@joseph-sentry joseph-sentry deleted the joseph/bq branch January 9, 2025 17:06
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