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

Silence the sherpa warning about DS9 not being available #18

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

taldcroft
Copy link
Member

Description

When importing sherpa.ui it always checks for the presence of the ds9 app in the path, even if it is irrelevant to the fitting task.

WARNING: imaging routines will not be available,
failed to import sherpa.image.ds9_backend due to
 'RuntimeErr: DS9Win unusable: Could not find ds9 on your PATH'

This shows up in ska_testr outputs and triggers a failure because of the WARNING. This is emitted as a logger.warning not a Python warning.

This PR sets the logging level for the that logger to logging.ERROR so the warning message is not emitted.

Testing

  • Passes unit tests on MacOS
  • Functional testing

Functional testing

Ran pytest find_attitude -v -k test_multiple_solutions -s with and without the patch.

  • With the patch no warning is seen in the output
  • Without the patch the usual warning is seen.

A more direct test is here:

$ ipython
In [1]: import logging
In [2]: logger = logging.getLogger('sherpa.image')
In [3]: logger.setLevel(logging.ERROR)
In [4]: import sherpa.image
In [5]:  # No warning!

$ ipython
In [1]: import sherpa.image
WARNING: imaging routines will not be available, 
failed to import sherpa.image.ds9_backend due to 
'RuntimeErr: DS9Win unusable: Could not find ds9 on your PATH'

@taldcroft taldcroft requested review from javierggt and jeanconn March 16, 2022 19:17
Copy link
Contributor

@jeanconn jeanconn left a comment

Choose a reason for hiding this comment

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

The change and its testing look good to me.

@DougBurke
Copy link

An alternative would be to re-write to avoid the sherpa.ui level, but just create the data objects, models, ... directly. I haven't looked in detail, but I don't think the fit does anything complex so it should be easy. Let me know if you want and I can try a first-pass conversion.

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