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

Refactor class hierarchy of NB2WProduct #130

Merged
merged 16 commits into from
Jan 14, 2025
Merged

Refactor class hierarchy of NB2WProduct #130

merged 16 commits into from
Jan 14, 2025

Conversation

ferrigno
Copy link
Contributor

This solves issue #129

@ferrigno ferrigno requested a review from dsavchenko January 10, 2025 19:43
@ferrigno ferrigno self-assigned this Jan 10, 2025
@ferrigno ferrigno linked an issue Jan 10, 2025 that may be closed by this pull request
Copy link
Member

@dsavchenko dsavchenko left a comment

Choose a reason for hiding this comment

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

When I wrote this class, it was not intended to be directly initialised, serving as something like an abstract base class.
But if it actually works for the general-purpose NumpyDataProduct, then OK, let's use it like this.

There is some violation of the logic, however. The oda:DataProduct ontology class is a parent for every kind of products, not only NumpyDataProduct-based. So maybe it makes sense to introduce some term like oda:NumpyDataProduct to the ontology and have it as a type_key here. But in this case, python class hierarchy is different from ontology class hierarchy. Reconciling this will require some more involved refactoring.

To summarise, having this as a hotfix for the specific issue is OK for me, but I would let @volodymyrss and @burnout87 comment on this

@dsavchenko
Copy link
Member

As a sidenote: I don't like the name NumpyDataProduct neither in the code nor in the ontology. I would have named it somehow like FITSDataProduct

@ferrigno
Copy link
Contributor Author

I will try to discuss with @burnout87 on Monday. An alternative would be to introduce a derived class for the Fits(Numpy)DataProduct to preserve the logic or to make a check in nb2worflow for the attribute existence

@burnout87
Copy link
Contributor

burnout87 commented Jan 13, 2025

Having a dedicated class for a Numpy-based product makes sense, this would allow us to have the NB2WProduct class to be a proper base class, numpy-agnostic, with the type_key defined in this PR. Then, a derived class specific for Numpy-based data-products could be defined without breaking any logic, assigning its own dedicated ontology term. This can be done in a dedicated PR.

To add: I would avoid renaming the classes, especially those in the oda_api as this could potentially break the logic in many places.

@burnout87 burnout87 self-requested a review January 13, 2025 07:08
@ferrigno
Copy link
Contributor Author

@burnout87 why don't you use this PR to implement such a class without my hack ?

@ferrigno
Copy link
Contributor Author

You can use JEM-X expert test_notebook for spectra to test this (I have set appropriate parameters)

@burnout87 burnout87 self-requested a review January 14, 2025 14:14
@burnout87 burnout87 requested a review from dsavchenko January 14, 2025 14:15
@ferrigno
Copy link
Contributor Author

As soon as Denys approves it, could you merge? It would be nice to have notebooks finally working also for the outputs.
I think that the guide should be updated in the output definition, as to have full functionality, one needs to use proper DataTypes and DataType annotations.

@dsavchenko dsavchenko changed the title Add type_key attribute to class NB2WProduct Refactor class hierarchy of NB2WProduct Jan 14, 2025
@burnout87 burnout87 merged commit 117f904 into master Jan 14, 2025
2 checks passed
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.

oda:DataProduct output has no type_key required for output
3 participants