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

No on_database_metadata_change signal sent when deleting database #223

Open
mrvisscher opened this issue Dec 20, 2024 · 1 comment
Open

Comments

@mrvisscher
Copy link

For some reason the on_database_metadata_change is not sent when you delete a database from the databases metadata. signal=False is hardcode instead of it using the signal parameter that defaults to True. I think the expected behavior would be for the signal to fire on database deletion as well.

def __delitem__(self, name: str, signal: bool = True):
from bw2data import Database
if name not in self:
raise KeyError
try:
Database(name).delete(warn=False, signal=False)
except:
warnings.warn(
"""
Deletion unsuccessful due to database error.
Metadata state is unchanged, but database state is unknown.
"""
)
return
super(Databases, self).__delitem__(name=name, signal=False)
if signal:
on_database_delete.send(name=name)

@mrvisscher
Copy link
Author

Same goes for parameterized exchanges:

ActivityParameter.recalculate_exchanges(group, signal=False)

Exchanges are recalculated, but the signal is hardcoded to False. The signal is not emitted meaning models dependent on that signal will be out of sync.

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

No branches or pull requests

1 participant