activity-browser
activity-browser copied to clipboard
Duplicating activities does not add the original database to 'Depends' column.
When an activity is duplicated to another database. The Depends column does not update to reflect the new dependency. Changing the project or closing/opening AB does not fix this.
Problem is worse, AB also doesn't update Depends column when exchanges from other databases are added.
Additional info:
The sync of DatabasesModel reads the dependencies from Brightway. The issue is in AB apparently failing to update this dependency in BW.
By checking bw.databases[name].get("depends", []) I found that it is not a UI problem but that the actual bw dependency is not updated.
Updating is failing to happen in 5 instances:
- Adding an exchange from database
Ato database!A(dependency should be added toA) - Removing an exchange from database
Afrom an activity in database!A(dependency fromAshould be removed) - Duplicating an activity which has dependencies from database
!Ato databaseA(should add dependency toA) - Deleting an activity in database
A, which has dependencies from!A(dependencies to!Ashould be removed) - Deleting an activity in database
Awith downstream consumers in database!A(dependencies of!Ashould be updated) - potentially related: #1012
All these updates should happen in activity.py, specifically in relevant function of ActivityController and ExchangeController.
Additionally, an update signal should probably be added in __init__ of the table model for signals.database_changed.connect(self.sync)
When re-linking a database, the depends column gets updated properly (here).
I haven't found yet what the reason is for this failing update or why it is updating on relink.
Perhaps we need bw.Database(db).find_dependents() though from testing this seems to not always be the full solution (only works when adding, not removing?). However, this call is also not included for relinking*, so I'm not sure why it does work there. A slight warning about bw.Database(db).find_dependents() though: This will check the entire database db, this can take a very long time for large databases.
* well, it is, but before we make changes during relinking, so it seems similar to a check like bw.databases[name].get("depends", [])?