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

Warn if user checks is_stored for plugin not always saved #796

Merged
merged 8 commits into from
Apr 3, 2024

Conversation

cfuselli
Copy link
Member

What is the problem / what does the code in this PR do

This PR addresses the issue of users potentially being unaware when querying for stored data of a plugin in strax that is configured with save_when < ALWAYS (3). In such cases, even if the is_stored function returns False, it might not reflect a lack of data due to processing or storage issues but rather due to the plugin's configuration. This update aims to improve user awareness by providing a warning in such scenarios.

Tested quickly with some single-output and multi-output plugins and seems to work.

@coveralls
Copy link

coveralls commented Jan 26, 2024

Coverage Status

coverage: 91.504% (+0.002%) from 91.502%
when pulling a7840eb on warning-is-stored-never
into 1ce8401 on master.

strax/context.py Outdated
save_when = save_when[target]

if save_when < 3: # 3 is SaveWhen.ALWAYS
warnings.warn(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hej @cfuselli you could add within this if-statement something like:

try:
    components = st.get_components('058518', target)
    targets_plugin_made_from = components.loaders.keys()
    # Warn user:
    print('Can be made from: ', targets_plugin_made_from)
except strax.DataNotAvailable:
    # Warn that data cannot be made
    print('cannot be made')

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice but I think it goes way beyond the scope of is_stored, no?
The warning is just intended to inform user of the existence of plugins that are not stored, so that they won't use these plugins to check if something is stored.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @WenzDaniel. Shal I still mark this as an unsolved thread?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For me it is fine to move ahead. I take what I can get.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just realized that strax.Context.stored_dependencies is the best function for the task @WenzDaniel mentioned.

Let's keep that in mind and update is_stored later if necessary.

strax/context.py Outdated Show resolved Hide resolved
@dachengx dachengx requested a review from yuema137 March 8, 2024 09:35
yuema137
yuema137 previously approved these changes Mar 12, 2024
Copy link
Collaborator

@yuema137 yuema137 left a comment

Choose a reason for hiding this comment

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

I also tested with a few plugins and it looks fine to me. Regarding Daniel's comment, I'm thinking that we could probably add a is_makable function to tell the users the nearest stored parents that the plugin could be made of.

@yuema137
Copy link
Collaborator

yuema137 commented Apr 2, 2024

@dachengx should we merge this PR soon? I think it's a good warning message for the users.

@dachengx dachengx merged commit 094fa7f into master Apr 3, 2024
9 checks passed
@dachengx dachengx deleted the warning-is-stored-never branch April 3, 2024 23:03
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.

5 participants