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

Do not add producer that has been added by saver #901

Merged
merged 3 commits into from
Oct 13, 2024

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented Oct 13, 2024

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

This is to solve the error when processor = "single_thread" in #903.

In the example of #903, after st.make(nt_test_run_id, "peaklets", processor="single_thread"), the pulse_counts is saved. So the loader will load this plugin because peaklets need records and pulse_counts are produced along with records. So pulse_counts is in components.loaders.

But before this PR, since records is also in components.plugins,

self.post_office.register_producer(
will register pulse_counts in the producer so this caused the bug.

Can you briefly describe how it works?

This PR prevents the producer registration if a data_type is already in components.loaders.

Can you give a minimal working example (or illustrate with a figure)?

Please check #903.

Please make sure that all automated tests have passed before asking for a review (you can save the PR as a draft otherwise).

@coveralls
Copy link

coveralls commented Oct 13, 2024

Coverage Status

coverage: 90.254% (-0.01%) from 90.267%
when pulling 8f06793 on do_not_duplicate_producer
into dca3545 on master.

@dachengx dachengx marked this pull request as ready for review October 13, 2024 17:51
@@ -1006,7 +1006,7 @@ def _get_end_targets(plugins: dict) -> ty.Tuple[str]:
"""Get the datatype that is provided by a plugin but not depended on by any other plugin."""
provides = [prov for p in plugins.values() for prov in strax.to_str_tuple(p.provides)]
depends_on = [dep for p in plugins.values() for dep in strax.to_str_tuple(p.depends_on)]
uniques = list(set(provides) ^ set(depends_on))
uniques = list(set(provides) - set(depends_on))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Get rid of dependencies, do not keep used dependencies.

self.post_office.register_producer(
p.iter(iters={dep: self.post_office.get_iter(dep, d) for dep in p.depends_on}),
topic=strax.to_str_tuple(p.provides),
registered=tuple(components.loaders),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the core of this PR: do not register loaders.

@dachengx dachengx merged commit 8843247 into master Oct 13, 2024
7 of 8 checks passed
@dachengx dachengx deleted the do_not_duplicate_producer branch October 13, 2024 20:44
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.

2 participants