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

Plots 2.0 #4904

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft

Plots 2.0 #4904

wants to merge 25 commits into from

Conversation

BeastyBlacksmith
Copy link
Member

@BeastyBlacksmith BeastyBlacksmith commented Mar 12, 2024

This is the development branch for Plots 2.0.

What changed

  • No default backend in PlotsBase, Plots becomes a wrapper for PlotsBase + GR (per [RFC] Plots 2.0 #4565 (comment)), making it non-breaking;
  • Backends are purely extensions with no @require;
  • The internals are more organized into modules and moved around;
  • Backend init and backend code is only found in its extensions, this should help with backend interference and annoyances about initialization and precompilation of plots. This should make backends modular and implemented much easier and without hacks into Plots.jl codebase;
  • Restored Preferences chosen backend;
  • ...

Example:

import UnicodePlots
using Plots 
unicodeplots()
plot(1:10)

What works

  • PlotsBase and Plots tests;
  • Preferences based backend selection.

What does not work

  • Precompilation statements for Plots when using an alternate backend: cannot @eval Main import UnicodePlots => most of the precompile statements are cached in PlotsBase now.

Help needed:

  • write backend agnostic precompile statements for PlotsBase
  • backport changes from v1 since last rebase
  • report breakages
  • move documentation back into this repo
  • start updating the docs
  • update the news.md

Decisions to be made

  • deprecate inspectDR ?
  • move to column major order ?
  • change the defaults

Issues needing attention please add more or checkoff resolved:
#4565 (comment)
Copy of that:
Labeled issues:

Labeled PRs:


Closes #4326

* remove deprecated backends

* move GR to extension

* make plot3d work

* make heatmap work

* factor components into modules

* finish Surface module

* export is_horizontal from Fonts

* start refactoring Plot, Subplot, etc. components

* change version

* continue module shuffling

* continued refactoring

* remove orientation

* minimal usable state

* format

* remove makekw

* anything up to Segments

* move series stuff from utils

* use Arrows

* create Colorbars module

* move axes stuff (precompiling state)

* let's relax deps and add them back later if needed (macOS issue)

* only 2 tests fail now

* restructure extension logic

* remove unicode for now

* GR extension

* update deps

* init step of gr

* proper init of GR

* for now manually activate the backend

* road to fixing gr

* revert some changes

* fix import exports

* fix measures

* clarify name space

* might need to be reverted, shape->Shape (too confusing_

* return lost wrap

* types and modules

* fix more things

* add gr function

* remove stale and fix naming

* added unicode backend

* unicodeplots works

* update runtests

* only use explicitly imported names in backends

* rename wrap to protect

* remove pre post imports, move to alignment jl

* alignment jl

* remove comments

* fix typo

* finally fix InputWrapper, misc changes

* import overloaded, namespace fix

* fixing per backend exceptions

* alost all tests are passing

* fix exports

* trying to fix project toml

* try to resolve deps

* move other backends to the extensions

* start pgfplotsx

* add backends to weakdeps

* recover

* already defined

* fix GR plot area method overload

* plotarea methods are overloaded in layouts.jl

* more fixes

* fix test

* namespace fixes

* fix namespaces

* revert later

* rm pyplot

* remove requires

* add PGFPlotsX imports

* bump julia compat

* create runtime functions for all backends

* improve error handling

* pgfplotsx loading

* get tests running

* fix names, skip StatsPlots examples

* test on 1.10

* remove pyplot remainings

* don't test julia < 1.9

* run julia formatter

* add pythonplotbackend

* fix init python plot

* gaston working

* reorganize plotly backends

* update kaleido compat

* format

* remove PlotlyBase compat

* make default backend functional

* make plotly functional

* naming and PlotlyJS

* get gaston running

* run more tests

* move dev in ci

* dev both at the same time

* fix syntax

* don't dev twice

* only load Gtk if not on CI

* add missing using statement for PlotlyJS

* more imports

* move merge_with_base_supported to Commons

* make Plotly module

* skip non-working tests

* fix filtering

* format

* invert filter

* fix pgfplotsx warning

* don't test Gaston

* fix cgrad missing

* format

---------

Co-authored-by: Simon Christ <simonchrist@gmx.de>
Co-authored-by: Simon Christ <christ@cell.uni-hannover.de>
Co-authored-by: = <=>
@t-bltg t-bltg changed the title Plots 2.0 Redesign backend loading Mar 31, 2024
@t-bltg t-bltg added DO NOT MERGE and removed 2.0 labels Mar 31, 2024
* rework extensions

* need to fix `test_backends`

* test `Plots` pass

* fix test

* restore tests

* format

* update
@BeastyBlacksmith
Copy link
Member Author

@t-bltg do you intend to release this as a 1.x release?

@t-bltg
Copy link
Member

t-bltg commented Apr 2, 2024

If we can make it non breaking, it would make things easier and end endless discussions.

@BeastyBlacksmith
Copy link
Member Author

Well, there would be a few changes that we'd need to roll back for this, like removal of pgfplots and I removed some functions also.

But I also don't quite see how to make switching of backends non-beraking since, what was

using Plots
pythonplot()

is now

using Plots
import PythonPlot
pythonplot()

@isentropic
Copy link
Member

I still don't get why can't 2.0 be breaking and why having a helpful error message isn't enough as a solution as per my comment in the issue #4565. Having GR as the default backend feels bad to me. I understand that nobody changes the backend but this way backend malfunctioning could be diagnosed easier.

Then if the backend doesn't work people can learn about other backends. I really don't buy the keep gr argument by searching GitHub code. Plots 2.0 isn't just for the users but also for debugging and long term stability.

Keeping gr as the default is not good imo. Flux got rid of it's CUDA for this reason and it works fine, new users can adapt we just need to leave good info/warn messages

@isentropic
Copy link
Member

I'm sorry that I'm late into the discussion and if some undoing needs to be done but we should prioritise long term good with 2.0. GR being the default is also what defers people from using plots, if users can learn about the flexibility that's great too. Pyplot imo works more stably with various fonts and scalings.

The purpose of package extensions is exactly this. Splitting into plotsbase and just plots to keep the standard interface means that we never need to go to 2.0 then.

2.0 by definition is breaking and that's ok. Plots is not a low level package and hardly any packages take dep on Plots. Interactive usage is easier to adapt to 2.0 anyways in case the help messages are well stated.

We also need to think about column major order to make Plots play nicely with others and streamline the column major way. These two changes are by far the most important, both being breaking and that's ok cause it's 2.0.

@isentropic
Copy link
Member

I get why people might object with needing to import GR explicitly, but you know adding such import help long term in that people would realize that there are more backends than just GR, and that the errors are coming because of 'import GR' not 'using Plots'. Im not kidding half of our issues are because GR didn't build or something like that. In the current scenario users try to import Plots it errors and then there's frustration. With gr free plots GR will throw it's warnings right awa and we can throw warnings and stuff like your GR loading failed, try these other backends.

@t-bltg t-bltg added the 2.0 label Apr 6, 2024
@t-bltg
Copy link
Member

t-bltg commented Apr 6, 2024

But I also don't quite see how to make switching of backends non-beraking since, what was

I've omitted this, so I've restored the 2.0 label.

We also need to think about column major order to make Plots play nicely with others and streamline the column major way.

I get this, but if no one implements it, this shouldn't block a release.

Having GR as the default backend feels bad to me.

I would be in favor of dropping GR as the default backend. But on the other end, adding PlotsBase without any backend dependency seems a good compromise.

In #4914, I've finalized the way modules and extensions should be written with a lot of cleanups, and restoration of the precompile statements, but unfortunately, it broke the reference tests in subtle ways. What a mess !

I like the new splitting of PlotsBase into smaller modules initiated in this branch, but it needs more work and cleanup, without breaking the tests.

@t-bltg t-bltg changed the title Redesign backend loading Plots 2.0 Apr 6, 2024
@t-bltg
Copy link
Member

t-bltg commented Apr 7, 2024

I've made progress and fixed the tests in #4914, everything is passing locally, and partially in CI.

Currently, there is no solution to generate precompile statements for a different backend than GR in Plots since we cannot @eval Main import UnicodePlots for example.

So we need at least to generate backend independent precompile statement for PlotsBase.
==> EDIT: done in #4914.

* rework extension `__init__` mechanism

* checkpoint plotly

* fix `pythonplot`

* format

* more `pythonplot` fixes

* checkpoint replace

* syntax

* fix `plotlyjs`

* restructure modules

* stable `GR`

* checkpoint broken `references` gr

* broken viewport

* fix `dev`

* update

* no project

* remove `--project`

* update

* fix `plotarea`

* fixes

* stable `PlotsBase`

* cleanup

* format

* restrcit gaston to `linux`

* restrcit `PlolyJS` test

* update format

* update action

* update `Aqua`

* cleanup - fix `Plots` tests

* move preferences back to `PlotsBase`

* simplifications

* format

* change versions

* rework ci

* format

* test downstream

* update ci

* move ci scripts

* fix

* fix

* update

* debug ci

* fix

* update versions

* update

* update

* update

* update

* update

* update

* update

* update

* restore CI

* update workflow

* add `PlotsBase` precompile statements

* update tests

* update preference - simplifications

* update test

* update
@t-bltg
Copy link
Member

t-bltg commented Apr 7, 2024

@BeastyBlacksmith, how can we move forward now ?

Embedded modules need more cleanup, but at least the port to extensions is now complete, with 100% previous tests passing.

@t-bltg
Copy link
Member

t-bltg commented Apr 9, 2024

I'd say we merge this now in master, create a v1 branch for backports and move on.

We can probably ask users to try an alpha version of Plots 2.

EDIT: we can also rename the master branch to main.

@BeastyBlacksmith
Copy link
Member Author

BeastyBlacksmith commented Apr 15, 2024

@BeastyBlacksmith, how can we move forward now ?

Embedded modules need more cleanup, but at least the port to extensions is now complete, with 100% previous tests passing.

Thanks a lot! Next steps would involve porting all the 2.0 labeled PRs and merge them into this branch. I won't merge this branch into master prior to the meeting at JuliaCon and even after that, there is no need to rush this. We should make sure we get all the breaking changes in that have accumulated over the years.

There will be a good amount of time before we get that oppurrtunity again.

@t-bltg
Copy link
Member

t-bltg commented Apr 15, 2024

Thanks, please keep in mind that I probably won't work on this anymore since my time is very limited, so make sure to backport the changes made in master into this branch, so that it doesn't go out of sync and stalls.

CI is currently a bit hacked for GraphRecipes and StatsPlots which will need to adapt to these changes (likely trivial changes).

Also, please make sure the test suite remains green, this took quite some time ...

@t-bltg
Copy link
Member

t-bltg commented Apr 16, 2024

Don't you think that making v2 the current master/main would force developers to work towards the next version (and thus force backporting to v1) ?

I mean we can always merge PRs into a v1 branch and tag backports releases.

Else I'm afraid, given the amount of active contributors, that this would be a nightmare to maintain in sync between branches ...

@BeastyBlacksmith
Copy link
Member Author

BeastyBlacksmith commented Apr 16, 2024

What I probably will do is sync them and then make v2 the new default branch, possibly renaming master to v1. I don't think we need to merge these at all.
We could also make it a policy, to only merge stuff to v1 if it has a v2 port.

@t-bltg
Copy link
Member

t-bltg commented Apr 18, 2024

nightly and 1.11.0-beta1 are passing 🎉, it has been a while ...

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

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

Project coverage is 87.06%. Comparing base (fa65e7d) to head (0ab074b).
Report is 16 commits behind head on master.

Current head 0ab074b differs from pull request most recent head f32247a

Please upload reports for the commit f32247a to get more accurate results.

Files Patch % Lines
PlotsBase/src/Commons/attrs.jl 75.28% 86 Missing ⚠️
PlotsBase/src/utils.jl 92.44% 37 Missing ⚠️
PlotsBase/src/Annotations.jl 75.86% 28 Missing ⚠️
PlotsBase/src/backends.jl 86.25% 18 Missing ⚠️
PlotsBase/src/axes_utils.jl 91.80% 15 Missing ⚠️
PlotsBase/src/plotly.jl 82.50% 14 Missing ⚠️
PlotsBase/src/Axes.jl 93.95% 13 Missing ⚠️
PlotsBase/src/Plots.jl 89.60% 13 Missing ⚠️
PlotsBase/src/recipes.jl 87.62% 12 Missing ⚠️
PlotsBase/src/Commons/Commons.jl 92.36% 10 Missing ⚠️
... and 20 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4904      +/-   ##
==========================================
- Coverage   89.77%   87.06%   -2.71%     
==========================================
  Files          40       51      +11     
  Lines        8780     5993    -2787     
==========================================
- Hits         7882     5218    -2664     
+ Misses        898      775     -123     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ajdunlap and others added 5 commits May 13, 2024 14:59
Bumps [julia-actions/cache](https://github.com/julia-actions/cache) from 1 to 2.
- [Release notes](https://github.com/julia-actions/cache/releases)
- [Commits](julia-actions/cache@v1...v2)

---
updated-dependencies:
- dependency-name: julia-actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](peter-evans/create-pull-request@v5...v6)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* add recipe

* add import

* handle errorbars, add tests

* improve test

* simplify test

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants