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

Sonify plugin updates #3269

Merged
merged 72 commits into from
Dec 19, 2024
Merged

Conversation

javerbukh
Copy link
Contributor

@javerbukh javerbukh commented Nov 6, 2024

Description

This pull request takes the work from james-trayford#3 and moves it into a PR for Jdaviz. There is now a plugin called "Sonify Data" which contains configuration options for sonifying a data cube. There are also options for which speaker the sound will come from, volume, and to start/stop the stream so the spectrum-at-spaxel tool can work as usual after sonifying the cube.

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.
  • Add Sonify Data plugin which uses the Strauss package to turn a data cube into sound. [Sonify plugin updates #3269]

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

javerbukh and others added 25 commits July 31, 2024 17:27
- Fix sigcube alignment with other cubes [get rid of transpose]
- Add percentile cut option that enables some rough feature isolation without full continuum subtraction
- Protect against cubes w/NaNs
@github-actions github-actions bot added cubeviz plugin Label for plugins common to multiple configurations labels Nov 6, 2024
@javerbukh javerbukh added this to the 4.1 milestone Nov 6, 2024
@javerbukh javerbukh force-pushed the sonify-plugin-updates branch from 57ee976 to cc51183 Compare November 7, 2024 15:08
James Trayford and others added 2 commits December 12, 2024 17:24
@pllim
Copy link
Contributor

pllim commented Dec 12, 2024

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:16:1: F841 local variable 'e' is assigned to but never used
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:21:28: E231 missing whitespace after ','
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:65:101: E501 line too long (101 > 100 characters)

@javerbukh
Copy link
Contributor Author

The tests pass and run locally but fail on CI because there is no sound device with output. Is there a way we can skip the test in CI? @pllim

@pllim
Copy link
Contributor

pllim commented Dec 12, 2024

fail on CI because there is no sound device with output

Can we be sure that every user's machine has a sound device with output? Is it not possible to disable the plugin if such a situation happens (rather than have it fail CI)?

Is there a way we can skip the test in CI?

If you must, yes, you can skip it by checking to see if "CI" env var is set. See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables

super().__init__(*args, **kwargs)
self._plugin_description = 'Sonify a data cube'
self.docs_description = 'Sonify a data cube using the Strauss package.'
if not self.has_strauss or sd.default.device[1] < 0:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pllim This line here will cause the plugin do be disabled if there is not a valid sound output device.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then why is CI failing? Something is running when it is not supposed to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I added a check in vue_sonify_cube() to prevent that from being called.

ci_cron_tests_stable_strauss:
name: Python 3.12 with stable versions of dependencies and Strauss
runs-on: ubuntu-latest
if: (CI == false && (github.repository == 'spacetelescope/jdaviz' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Extra CI'))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that I see this if here, it does not quite make sense to add a GitHub Actions job and then tell it to never run. Options:

  1. If you still want other tests to run and just to make sure non-strauss stuff does not break when strauss is installed, only skip the failing tests when CI is true. Do not skip the whole job.
  2. If (1) means nothing to you, just remove this whole job from this YAML. It is dead code at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I put that skip in the actual test file test_sonify_plugin.py or in this file?

Copy link
Member

Choose a reason for hiding this comment

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

that effectively makes the test useless though, right (unless we occasionally remember to run locally). Is it possible to test that the plugin is disabled because of no sound devices but then still call the internals to generate the sonified cube and assert its contents without ever playing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar thoughts as Kyle (but less clear) at #3269 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would require a non-trivial amount of code moving that should be covered by #3330.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vue_sonify_cube() calls flux_viewer.get_sonified_cube() which requires a device ID because that method creates an instance of CubeListenerData called audified_cube, which does not need a device ID. However, later in the method the sounddevice.OutputStream is created which does need the device ID. I could separate that stream creation from the get_sonified_cube method but that work may be overwritten by #3330 . So is that work worth it to do in this PR if we may do something different down the road? If the answer is yes then I can do that but I wanted to be clear with why I think that effort is covered by #3330.

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the rush, probably okay to defer unless you think that refactoring is critical here for AAS.

@javerbukh
Copy link
Contributor Author

@pllim Looks like the test marked to be skipped if run inside github actions is still being run in the CI. Any suggestions?

@pllim
Copy link
Contributor

pllim commented Dec 13, 2024

Pushed a commit to copy over astropy syntax that I know works. 🤞

@james-trayford
Copy link

james-trayford commented Dec 16, 2024

IIUC - listener related stuff now compatabile with CI?
Screenshot 2024-12-16 at 12 41 50
So is it just any code formatting, logging, etc now?

@pllim
Copy link
Contributor

pllim commented Dec 16, 2024

Still need to insert change log. You can ignore the standalone build.

Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

I left a few questions and suggestions. One overarching question: is there a meaningful difference between audification/audified and sonification/sonified? Both are used throughout this code, and if they're being used to mean the same thing we should probably standardize to using only one term.

jdaviz/configs/cubeviz/plugins/viewers.py Outdated Show resolved Hide resolved
jdaviz/configs/cubeviz/plugins/tools.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, I think this looks good to me now. Re-approving.

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

One small comment that you can take or leave - otherwise looks good to me to merge for now and we can continue to iterate in the follow-up tickets created.

self.docs_description = 'Sonify a data cube using the Strauss package.'
if not self.has_strauss or sd.default.device[1] < 0:
self.disabled_msg = ('To use Sonify Data, install strauss and restart Jdaviz. You '
'can do this by running `pip install ".[strauss]"` in the command'
Copy link
Member

Choose a reason for hiding this comment

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

should this be updated to pip install strauss now? Back ticks also won't render as code this way... maybe better without them entirely?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Related, I realized that my comment here was never addressed. Right now the instructions are confusing because they don't say that this command has to be run in the Jdaviz root directory, and also aren't applicable if the user is not on a dev install.

Copy link
Contributor

Choose a reason for hiding this comment

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

The correct syntax is pip install jdaviz[strauss] for end-users.

ref: https://github.com/astropy/astropy/wiki/v7.0.0-RC-testing

Copy link
Member

Choose a reason for hiding this comment

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

Now that strauss is released, can we just suggest pip install strauss or do we want to maintain the ability to pin specific version by suggesting [strauss]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change it in both places to pip install strauss.

@javerbukh javerbukh merged commit 18a740d into spacetelescope:main Dec 19, 2024
17 of 21 checks passed
@james-trayford
Copy link

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build standalone Additional pylons cubeviz Extra CI Run cron jobs in PR plugin Label for plugins common to multiple configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants