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

Stream instead of buffer JSON in read_json/write_json #96

Merged
merged 4 commits into from
Mar 14, 2024

Conversation

peterallenwebb
Copy link
Contributor

resolves https://dbtlabs.atlassian.net/browse/MNTL-179

Description

There is no reason to keep JSON in memory as an intermediate step during read/write, and it was contributing to max resident set size, so stream it instead.

Checklist

@peterallenwebb peterallenwebb requested a review from a team as a code owner March 14, 2024 20:16
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 55.51%. Comparing base (ae8ffe0) to head (2e8af14).

Files Patch % Lines
dbt_common/clients/system.py 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
- Coverage   55.77%   55.51%   -0.26%     
==========================================
  Files          50       50              
  Lines        3050     3064      +14     
==========================================
  Hits         1701     1701              
- Misses       1349     1363      +14     
Flag Coverage Δ
unit 55.51% <0.00%> (-0.26%) ⬇️

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.

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

Do we need to add some addition test to cover the new changes so we don't accidentally change this behavior? Is it even possible?

Otherwise looks good!

with open(path, "w", encoding="utf-8") as f:
json.dump(data, f, cls=dbt_common.utils.encoding.JSONEncoder)
except Exception as exc:
# See write_file() for an explanation of this error handling.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the helpful comment!

@peterallenwebb peterallenwebb added this pull request to the merge queue Mar 14, 2024
Merged via the queue into main with commit a1a223d Mar 14, 2024
13 checks passed
@peterallenwebb peterallenwebb deleted the paw/stream-json branch March 14, 2024 23:16
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.

3 participants