Skip to content

Refactor/Move qt_plotting to pyvista_qt#719

Merged
akaszynski merged 9 commits intomasterfrom
feat/split_qt
May 24, 2020
Merged

Refactor/Move qt_plotting to pyvista_qt#719
akaszynski merged 9 commits intomasterfrom
feat/split_qt

Conversation

@akaszynski
Copy link
Copy Markdown
Member

@akaszynski akaszynski commented May 14, 2020

Move qt_plotting to pyvista_qt

This PR moves qt_plotting.py out of pyvista.plotting and into pyvistaqt. Reasoning for this:

Licensing

GPL scares me a little, and I want to make certain that we've removed all traces of pyqt from our module over the concern of licensing.

Agile Development

Testing is really bogging down agile development. It's difficult to get core tests/doc building/ and qt tests to consistently run each time. It's usually a flaky test in Mac or some similar timeout in Windows due to server load.

With split modules, we can add a ton of features like better icons, pyqt5 version control, feature tree, etc. all within the setup.py.

Better testing control

Changes to BackgroundPlotter do not affect any upstream core functionality and as such we should not need to test the core functionality again with each minor change. The opposite doesn't hold true, (i.e. changes to the pyvista core can affect pyvistaqt) so we simply pull from master and check if we're valid.

Pyside

We can support pyside in the same manner; by providing a submodule that builds upon BasePlotter. Including pyside support within pyvista will further bloat the module and we need to move the opposite direction.

Summary

This is a significant but necessary change to make pyvista easier to develop in an agile manner. It will also lead to improvements in BackgroundPlotter as changes there will be easier to test and develop.

@imsodin
Copy link
Copy Markdown
Contributor

imsodin commented May 14, 2020

In terms of licensing this does not help: Just as currently importing pyqt5 means the whole of pyvista needs to conform with gpl, so does importing pyvista_qt, which in turn imports pyqt5. This problem can only be solved by not importing pyqt5 at all in the codebase.

@akaszynski
Copy link
Copy Markdown
Member Author

In terms of licensing this does not help: Just as currently importing pyqt5 means the whole of pyvista needs to conform with gpl, so does importing pyvista_qt, which in turn imports pyqt5. This problem can only be solved by not importing pyqt5 at all in the codebase.

It's a reasonable point. Do you propose we move out the entire import? As it stands it's a conditional import that only runs if you have pyvista_qt installed.

@imsodin
Copy link
Copy Markdown
Contributor

imsodin commented May 14, 2020

I am not the right person to ask this, I am neither an expert on licensing nor affected by the licensing choice of pyvista. From what I read my (!) conclusion is that importing a python module is considered linking, and linking GPL code makes the whole thing subject to GPL terms. So the question here is: Is conditional importing still importing? I'd guess yes. However I'd expect not even experts could be entirely sure, because these cases usually only become clear after litigation. Legal advice will probably stay on the save side usually. The actual judgement would have to be done by downstreams in violation of GPL (e.g. any closed-source downstreams distributing the code), i.e. whether to use pyvista or not and accept any risk, or pyqt5, i.e. whether or not to litigate. Pyvista itself as far as I understand is not in violation of GPL (unless stating the license to be MIT is already considered a violation - it's probably not correct, but by making the pyvista source open it still complies with GPL as far as I understand). So my personal opinion is: Do not import pyqt5 in any way if you want to license pyvista as MIT. However my opinion is not what counts. I seem to remember that closed-source downstreams have been mentioned at some point. If that's correct whoever knows them should ask them, because their opinion matters.

@akaszynski
Copy link
Copy Markdown
Member Author

Removing the BackgroundPlotter all together makes sense to me as it completely removes any doubt that pyqt is or isn't being imported. Plus, from a development standpoint I don't have to test an additional dependency.

@codecov
Copy link
Copy Markdown

codecov bot commented May 15, 2020

Codecov Report

Merging #719 into master will decrease coverage by 1.25%.
The diff coverage is 61.53%.

@@            Coverage Diff             @@
##           master     #719      +/-   ##
==========================================
- Coverage   84.73%   83.48%   -1.26%     
==========================================
  Files          35       34       -1     
  Lines        9266     8841     -425     
==========================================
- Hits         7852     7381     -471     
- Misses       1414     1460      +46     

@banesullivan
Copy link
Copy Markdown
Member

banesullivan commented May 15, 2020

I vote for taking all traces of PyQt out of pyvista (this repo) and into a separate repo with a compatible license. We need to focus on the core feature dev and testing to really move the software forward. Also, having things more modular will streamline dev all around and make it easier for new developers to jump on board with PyVsita core.

I've majorly ranted about GPL on many other issues and how we can't even import GPL software without violating the license - so in brief, let's get PyQt out of here and stop worrying about it. Also, having it here is just getting messy.


In practice, we'll need to keep an empty BackgroundPlotter and QtInteractor<whatever_its_called> class around that throw big ol' warnings. I have a feeling this might be a challenge/(pain in the 🍑) for downstream projects like MNE-Python and the now several commercial software packages using the PyQt interface, so we'll definitely want to have all of them (@GuillaumeFavelier / @larsoner and @math-artist are the first to come to mind) fully in the loop before we even think about merging this.

@akaszynski
Copy link
Copy Markdown
Member Author

In practice, we'll need to keep an empty BackgroundPlotter and QtInteractor<whatever_its_called> class around that throw big ol' warnings.

Were you thinking of a depreciation warning? We can do that for a minor release, but I'd honestly prefer just forcing people off rather than taking the bandaid off slowly. I've got a closed source project that uses pyvista.BackgroundPlotter and something would generally break between versions anyway, so I had to fix the version until I was ready for a true upgrade. It will be less to maintain as well.

I'd say throwing a depreciation error would be best, but I'll settle with a warning if @GuillaumeFavelier and @larsoner think it's best.

@akaszynski akaszynski added the review-critical For changes that might have serious implications - always good to get a second set of careful eyes. label May 15, 2020
@akaszynski
Copy link
Copy Markdown
Member Author

@banesullivan, I'm going to need you to go into add qtdocs.pyvista.org to pyvista_qt-docs. GitHub pages is already enabled, but I need you to setup the domain (or give me access to it).

@GuillaumeFavelier
Copy link
Copy Markdown
Contributor

This is a big change, this plotter is here since I learned about pyvista. I think it's enough for a minor release, what do you think @pyvista/developers ?

I thought the plan was to move towards pyvista-gui though. Is it for even more modularity?

Also, I understand it's called pyvista-qt with a - right? That's what I saw on PyPi. Is there a reason why we should keep the spelling pyvista_qt (with a _) around? Sorry for the naive question, I just think it should be consistent everywhere.

I'd say throwing a depreciation error would be best

I'm in favour of the deprecation error. If it's not there anymore, people should not expect it to work. And we can inform the users about the move. Then this can be removed at the next big release cycle. But if we go for a warning, we should redirect to Plotter as an alternative.

I have a feeling this might be a challenge/(pain in the peach) for downstream projects like MNE-Python and the now several commercial software packages using the PyQt interface

Regarding mne-python, the plan is to pin the latest version of pyvista with the BackgroundPlotter around and work the transition when everything is settled on the new pyvista-qt side. I remain optimistic, hopefully everything will go smoothly 👍

You might be interested @larsoner, @agramfort :)

@imsodin
Copy link
Copy Markdown
Contributor

imsodin commented May 15, 2020

I'd definitely consider this a minor bump, it's not just a bugfix. Also this seems like a good time to introduce RCs, given there seems to be quite a few affected downstreams that would benefit from early testing.

The underscore vs hyphen thing is a typical problem: Module names must not use hyphens but underscores (if at all), package names should avoid underscores. I.e. the package would usually be pyvista-qt, the module pyvista_qt. Or just make both pyvistaqt to remove any possible confusion: https://www.python.org/dev/peps/pep-0008/#package-and-module-names

@larsoner
Copy link
Copy Markdown
Contributor

I remain optimistic, hopefully everything will go smoothly

Indeed I don't foresee any big issues for MNE, we'll just need to implement some try/except import patterns at our end to accommodate older and newer styles I think

@akaszynski
Copy link
Copy Markdown
Member Author

Or just make both pyvistaqt to remove any possible confusion:

I think that sounds like the best solution. It's not the nicest looking name, but it will lead to the least confusion between - and _. I've personally always had issues (especially when downloading from pypi`

Sorry for the naive question, I just think it should be consistent everywhere.

That's my fault. Provided no one has an objection with the name pyvistaqt, I'll change it shortly.

@akaszynski
Copy link
Copy Markdown
Member Author

I thought the plan was to move towards pyvista-gui though. Is it for even more modularity?

I think we can slowly add features from pyvista-gui into pyvistaqt. We can start with a solid base and then build up from there.

@akaszynski akaszynski changed the title 🚧 Refactor/Move qt_plotting to pyvista_qt Refactor/Move qt_plotting to pyvista_qt May 22, 2020
@akaszynski akaszynski requested a review from banesullivan May 23, 2020 17:57
Copy link
Copy Markdown
Member

@banesullivan banesullivan left a comment

Choose a reason for hiding this comment

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

A few minor suggestions I would like to resolve. Otherwise, LGTM!! 🎉

These changes warrant a MINOR version bump and details should be the top point in the release notes.

This is really exciting - I think will significantly improve PyVista's code quality, decrease barriers to entry for new devs, and streamline testing 🚀

@akaszynski akaszynski added this to the Release 0.25.0 milestone May 24, 2020
@akaszynski akaszynski linked an issue May 24, 2020 that may be closed by this pull request
@akaszynski
Copy link
Copy Markdown
Member Author

These changes warrant a MINOR version bump and details should be the top point in the release notes.

Agreed. I've added it to the milestone. We've been due for a minor release anyway.

@akaszynski akaszynski merged commit 8ed12dd into master May 24, 2020
@akaszynski akaszynski mentioned this pull request Jun 2, 2020
@akaszynski akaszynski deleted the feat/split_qt branch June 4, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-critical For changes that might have serious implications - always good to get a second set of careful eyes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Qt Functionality out of pyvista

5 participants