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

Remove vega v5 wrappers #2829

Merged
merged 32 commits into from
Jan 25, 2023
Merged

Remove vega v5 wrappers #2829

merged 32 commits into from
Jan 25, 2023

Conversation

mattijn
Copy link
Contributor

@mattijn mattijn commented Jan 13, 2023

Same as #2822, but renamed the brach, which closed the previous PR.

As mentioned in #2822:

This PR removes the Vega V5 wrappers from the Altair repository.

It removes them from the generate_schema_wrapper, magics, mimebundle, tests and docs.

Not everything related to vega is removed since the saving utilities requires vega bundles to be included.

Thanks for the review @joelostblom, I will update soon. Will it be better to raise deprecation warnings when vega options are called, instead of all the deletions as is proposed currently?

@joelostblom
Copy link
Contributor

Thanks for the review @joelostblom, I will update soon. Will it be better to raise deprecation warnings when vega options are called, instead of all the deletions as is proposed currently?

I was considering that too, and I am OK either way. I don't think we need it since this is a major release and there is an easy other way to get the same functionality via ipython.display, and we would then have this code lying around and need to delete it at a later point. But if you think it is sounder/safer to have it lying around and marked as deprecatedfor a few release, then I'm OK with that too.

@mattijn
Copy link
Contributor Author

mattijn commented Jan 15, 2023

I changed it a bit. Now it is allowed to define vega as format in the mimebundle, so you can export a Vega-lite specification as Vega. But I deprecate the rendering of Vega specifications (defined by mode) as we removed the Vega wrappers.

Now I get a C901 error on flake8 that the save() function is too complex. Not sure how to pass that one, any suggestions?

Copy link
Contributor

@binste binste left a comment

Choose a reason for hiding this comment

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

Thanks @mattijn! Suggested some changes.

altair/utils/mimebundle.py Outdated Show resolved Hide resolved
altair/utils/mimebundle.py Outdated Show resolved Hide resolved
altair/utils/mimebundle.py Outdated Show resolved Hide resolved
altair/utils/mimebundle.py Outdated Show resolved Hide resolved
altair/utils/save.py Outdated Show resolved Hide resolved

if mode != "vega-lite":
if mode == "vega":
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark here about the deprecation warning

@@ -45,7 +88,7 @@ def save(
the format to write: one of ['json', 'html', 'png', 'svg', 'pdf'].
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
the format to write: one of ['json', 'html', 'png', 'svg', 'pdf'].
the format to write: one of ['json', 'html', 'png', 'svg', 'pdf', 'vega', 'vega-lite'].

Only add the vega-lite suggestion if it is also supported in the rest of save

altair/utils/save.py Show resolved Hide resolved
@@ -128,7 +148,7 @@ def save(
**kwargs,
)
write_file_or_filename(fp, mimebundle["text/html"], mode="w")
elif format in ["png", "svg", "pdf"]:
elif format in ["png", "svg", "pdf", "vega"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't comment on the correct line but vega does not work here. It will try to access the mimebundle with key image/svg+xml on line 169.

Could also add support for "vega-lite" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vega-lite cannot be supported as format. That would be json. format functions a bit like export to, or save as in other programs. If it is defined as vega it should compile the vega-lite specification into vega json.
Apparently that never has functioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, you're right, that would be json!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I just noticed the following variations in the code:
https://github.com/altair-viz/altair/blob/1ed3f6f2fd3647bcf1f2e5e81dd328a0f9cf623d/altair/utils/mimebundle.py#L72-L77

It seems there is different type of json, namely, application/json and application/vnd.vegalite.v5+json (for altair 5). So I'll include vega-lite also as format, it probably would be better if it was renamed to something as vl-json.

altair/utils/save.py Show resolved Hide resolved
First round of improving the requested changes.

Co-authored-by: Stefan Binder <[email protected]>
@mattijn
Copy link
Contributor Author

mattijn commented Jan 25, 2023

Thanks for the continuous review @binste!

I've reverted the introduction of warnings and also the enhancements to get an improved support for vega/vega-lite as output save format.
These potential enhancements are registered as feature requests in #2852. Now this PR is only on removing the Vega 5 wrappers/rendering options.

This PR is even with main & all tests are passing. So I'm merging.

@mattijn mattijn merged commit 1f6d1c9 into master Jan 25, 2023
@binste
Copy link
Contributor

binste commented Jan 25, 2023

Awesome, great to see that we can already close #2817 One step closer towards a release candidate!

@mattijn mattijn deleted the remove-vega-v5-wrappers branch August 25, 2023 20:30
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Sep 25, 2023
https://build.opensuse.org/request/show/1113173
by user bnavigator + anag+factory
- Disable altair entrypoint tests: altair 5 removed the vega
  wrappers
  * gh#vega/altair#2829
  * gh#vega/ipyvega#509
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