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

Create a new serialize_report fn #554

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Mar 4, 2025

This merges the previous to_database and to_archive methods into one, which serializes a Report to the report_json and chunks pairs, and can optionally return a totals dict as well.

@Swatinem Swatinem self-assigned this Mar 4, 2025
@Swatinem Swatinem force-pushed the swatinem/report-serde branch 2 times, most recently from dd3148d to 6ebee5a Compare March 4, 2025 14:55
Copy link

codspeed-hq bot commented Mar 4, 2025

CodSpeed Performance Report

Merging #554 will degrade performances by 21.68%

Comparing swatinem/report-serde (1478aa9) with main (079d368)

Summary

❌ 1 regressions
✅ 16 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_report_serialize 4.8 ms 6.1 ms -21.68%

@Swatinem Swatinem force-pushed the swatinem/report-serde branch from 6ebee5a to 996e82b Compare March 4, 2025 15:21
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 84.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 88.71%. Comparing base (338a920) to head (1478aa9).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
shared/reports/serde.py 80.95% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #554      +/-   ##
==========================================
- Coverage   88.73%   88.71%   -0.02%     
==========================================
  Files         461      461              
  Lines       13144    13159      +15     
  Branches     1510     1512       +2     
==========================================
+ Hits        11663    11674      +11     
- Misses       1164     1166       +2     
- Partials      317      319       +2     
Flag Coverage Δ
shared-docker-uploader 88.71% <84.00%> (-0.02%) ⬇️

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.

@codecov-notifications
Copy link

codecov-notifications bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 84.00000% with 8 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
shared/reports/serde.py 80.95% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from swatinem/mv-reportfile to main March 5, 2025 13:51
This merges the previous `to_database` and `to_archive` methods into one, which serializes a Report to the `report_json` and `chunks` pairs, and can optionally return a `totals` dict as well.
@Swatinem Swatinem force-pushed the swatinem/report-serde branch from 02c0986 to 968f544 Compare March 5, 2025 13:57
@Swatinem Swatinem marked this pull request as ready for review March 5, 2025 13:57
@Swatinem Swatinem requested a review from a team March 5, 2025 13:57
Copy link
Contributor

@giovanni-guidini giovanni-guidini left a comment

Choose a reason for hiding this comment

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

some nit comments.
but LGTM. Nice to consolidate many functions into a simpler interface.

@@ -26,6 +26,8 @@
from shared.utils.sessions import Session, SessionType
from shared.utils.totals import agg_totals

from .serde import _encode_chunk, serialize_report
Copy link
Contributor

Choose a reason for hiding this comment

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

haha serde. Rust background bubbling up
Or is that used in other contexts? I know it's from SerializeDeserialize, so it makes sense.

Don't love the relative import tho

@@ -481,7 +483,9 @@ def __bool__(self):
@sentry_sdk.trace
def to_archive(self, with_header=True):
# TODO: confirm removing encoding here is fine
chunks = END_OF_CHUNK.join(_encode_chunk(chunk) for chunk in self._chunks)
chunks = END_OF_CHUNK.join(
_encode_chunk(chunk).decode() for chunk in self._chunks
Copy link
Contributor

Choose a reason for hiding this comment

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

Why make this function start with _?
That's typically a "private function" in Python, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

hum just to keep the same name as it was, I see I see

@@ -506,6 +510,9 @@ def to_database(self):
).decode(),
)

def serialize(self, with_totals=True) -> tuple[bytes, bytes, ReportTotals | None]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd make it always return the totals, and you can just ignore them if not using...
Would that be a big performance impact? If that's the case I'd understand making it optional, but would make it more explicit

"only use totals if needed cause the function is considerably slower" or something

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