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

vega_templates: Handle content as dict instead of string. #124

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Mar 16, 2023

Prevent unnecessary dumps/loads calls.

Closes #23

  • Before:

Captura de pantalla 2023-03-16 a las 12 17 12

  • After:

Captura de pantalla 2023-03-16 a las 12 16 21

@daavoo daavoo requested a review from skshetry March 16, 2023 11:23
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
@daavoo daavoo self-assigned this Mar 16, 2023
@daavoo daavoo added the A: vega Area: Vega plots label Mar 16, 2023
@daavoo daavoo force-pushed the revisit-json-dumps branch from 31002b2 to 85ad4de Compare March 16, 2023 11:35
Prevent unnecessary `dumps`/`loads` calls.

Closes #23
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 88.15% and project coverage change: -2.09 ⚠️

Comparison is base (14f91b2) 96.55% compared to head (73a1961) 94.47%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   96.55%   94.47%   -2.09%     
==========================================
  Files          19       19              
  Lines         697      724      +27     
  Branches      100      112      +12     
==========================================
+ Hits          673      684      +11     
- Misses         20       27       +7     
- Partials        4       13       +9     
Impacted Files Coverage Δ
src/dvc_render/vega.py 85.13% <66.66%> (-12.27%) ⬇️
src/dvc_render/vega_templates.py 93.87% <88.46%> (-4.40%) ⬇️
tests/test_templates.py 100.00% <100.00%> (ø)
tests/test_vega.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


if skip_anchors is None:
skip_anchors = []

content = deepcopy(self.template.content)
Copy link
Member

@skshetry skshetry Mar 16, 2023

Choose a reason for hiding this comment

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

Without deep-copying, we may accidentally modify the same contents.

Copy link
Contributor Author

@daavoo daavoo Mar 16, 2023

Choose a reason for hiding this comment

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

Without deep-copying, we may accidentally modify the same contents.

I added reset() method to bypass the need of deepcopy (which was also taking time)

Copy link
Member

Choose a reason for hiding this comment

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

That’s only protected because replace_value copies the whole collection, right?

@daavoo daavoo merged commit ba87a2e into main Mar 16, 2023
@daavoo daavoo deleted the revisit-json-dumps branch March 16, 2023 13:47
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
daavoo added a commit to iterative/dvc that referenced this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: vega Area: Vega plots
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

plots: require templates to be JSON and treat them as such
3 participants