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
datastack module and optional requirements #22
Comments
On a possibly-related note, in tests I've been doing to set up some sphinx documentation, I've had problems with the |
@olaurino - from your original comment, do you know what "act accordingly" means, or does this need to be worked out? I assume that if a backend is missing then either: a) there's a warning message saying something like "datastack support is not available" and the module is not loaded b) the module will load, but will do nothing when a backend is missing. I guess option a fits in better with the current approach of Sherpa (but I haven't looked at the tests/code to see which might make more sense functionally). |
option a) is what happens now. The module fails to load and the user cannot use it. Some of the module's features do not have anything to do with plotting, and they should be available even if plotting backends are not installed. So, I believe we should make the module work like in option b), with some of the functionality always available, and some other functionality available only if a plotting backend is installed. Also, we should refactor the parts of the code that directly probe for the installed backend. First, we should define common interfaces that can be factored out so that the main code gets the implementation from a factory. Then we should evaluate whether we want to fold this new abstraction layer of the datastack module into the main sherpa backend implementations themselves, but at that point this should just be a matter of moving things around. We should also make sure we track the issue you were having with DS9 and sphinx, and in general this could be part of the larger review of the backends design. To summarize, here is what I believe we should do:
|
This commit - "abstracts" the plotting code - creates versions of this abstraction of matplotlib, chips, and no backend The primary driver for this change is given in the comment to #22: #22 (comment) Notes on this change - the test suite does not seem to exercise the plotting code as it did not find several issues during development (requiring manual testing); this commit does not change any test code - the original version included a set of matplotlib-specific code; this has been made available to ChIPS users too (e.g. plot_savefig/plot_xlim) but some discussion is probably warranted on if this is wanted, and if it is what the interface should be - (related to previous point) the _print_window function seems there for ChIPS users (there's a savefig for matplotlib users); I am not happy with the name
@olaurino is @08d3d4d what you were thinking of? |
Indeed. Eventually it would be good if the backend was returned by some kind of factory, but that's something we need to improve in the main sherpa code as well. As for testing, I hope I can commit an example unit test. The unit tests should exercise the expected behavior of the datastack code by mocking the backends and just ensuring that the right backend calls are properly made. The integration of the actual backend is more complex, and depends on the backend. Since the addition of the datastack code is recent and it is a reasonably isolated module, I would try and use it as an example of how we should do proper testing and use this example in other parts of the codebase. |
I don't plan on turning the |
This commit - "abstracts" the plotting code - creates versions of this abstraction of matplotlib, chips, and no backend The primary driver for this change is given in the comment to #22: #22 (comment) Notes on this change - the test suite does not seem to exercise the plotting code as it did not find several issues during development (requiring manual testing); this commit does not change any test code - the original version included a set of matplotlib-specific code; this has been made available to ChIPS users too (e.g. plot_savefig/plot_xlim) but some discussion is probably warranted on if this is wanted, and if it is what the interface should be - (related to previous point) the _print_window function seems there for ChIPS users (there's a savefig for matplotlib users); I am not happy with the name
@olaurino what needs to be done to fix or close this ? |
I have a branch ready to be turned into a PR: What's holding me is that it relies on OTS packages that are not in CIAO, so a PR would break CIAOD (unless we label it pr:hold, which we can do). I am about to send requests for the inclusion of this packages (mock and pytest). Also I am using this as a prototype to explore more robust ways of isolating unit tests, to employ modular, reusable fixtures, to parametrize tests, and so on. So I am trying to document these patterns both inside and outside the code. I put it on the back burner this week to start reviewing and merging open PRs, but I'll get back to it soon. |
ta. I thought that with the recent build/integration PRs that have gone in, this looked a good candidate for inclusion. |
As mentioned in the 4.7 release notes, the new
datastack
module fails to load whenmatplotlib
is not installed.This is a side effect of the decision to have the IO and plotting backends as soft dependencies, while in CIAO there is always a back-end installed.
Moreover, if
matplotlib
is installed, butpyfits
is not, thedatastack
module will indeed be loaded, but the tests will fail becausepyfits
is not available.The
datastack
should check for the presence of the backends and act accordingly.Installing
matplotlib
andpyfits
works around the issue.The text was updated successfully, but these errors were encountered: