activity-browser icon indicating copy to clipboard operation
activity-browser copied to clipboard

Database tree view

Open marc-vdm opened this issue 4 years ago • 4 comments

As discussed a few times, a tree view for databases would be nice to have, this could be based on some classification system already present in databases like ecoinvent.

For whoever picks this up: Through other work, I found that the classifications are stored in the Metadatastore:

from activity_browser.bwutils import AB_metadata

db = AB_metadata.get_database_metadata(database_name)

This db object is a Pandas Dataframe, with a column classifications. Each entry is a list in which the classifications are stored as tuples: (name of classification, class)

Hope that saves some work for whoever picks this up.

TODO

  • [x] Put classifications CSV file in static folder
  • [x] Generate tree from file
  • [x] Link processes to tree whenever database is opened with ISIC classifications --> time how long this will take to create
  • [x] Write UI treeview --> how to deal with search between the tree/list?
  • [ ] re-add functionality of drag/drop
  • [ ] context menus --> include expand/collapse options
  • [ ] Optional Add to each tree level the amount of children leaf nodes?
  • [ ] Move things to superclass for shared method/activity class where possible
  • [ ] Link widget signals to update search settings for following signals (#785):
    • signals.new_activity.connect()
    • signals.duplicate_activity.connect()
    • signals.duplicate_activities.connect()
    • signals.duplicate_activity_to_db.connect()
    • signals.delete_activity.connect()
    • signals.delete_activities.connect()

marc-vdm avatar Aug 03 '21 15:08 marc-vdm

See related discussion here https://github.com/LCA-ActivityBrowser/activity-browser/issues/596#issuecomment-1325671704

marc-vdm avatar Nov 23 '22 21:11 marc-vdm

https://unstats.un.org/unsd/classifications/Econ/Download/In%20Text/ISIC_Rev_4_english_structure.Txt This tree view should be incorporated in the static files, and then read by AB to build a tree view of the different categories. On the branch https://github.com/marc-vdm/activity-browser/tree/including_classifications there are already some of these classifications loaded for most of the ecoinvent activities. The activities should be grouped under their respective tree view when showing it.

The tree should be built up similar to Impact Categories, and the filtering should be made to work similar to it. When not in the tree view, the categories should not necessarily be shown, although that might be discussed still.

Furthermore, dragging and dropping activities should still be possible: dragging a parent tree level should drag and drop all child levels.

Finally, it might be useful to make the tree view code work more general, i.e. to reuse the same class when building the tree view of different things.

Databases that do not have these classifications loaded, should disable the tree view. Databases always load in list view by default.

Joeytje50 avatar Dec 16 '22 15:12 Joeytje50

One more thing: ~~It may be good to check out whether it's smart to move the storage of the data up to the ActivityBiosphereWidget instead of having two dataframes, one for the tree and one for the list, but perhaps that's not a problem at all since we already use the MetaDataStore. Happy to think along on this you want.~~ Ok, so we get the data from df_from_metadata(self, db_name: str) -> pd.DataFrame:, you can probably do something similar in the treeview to get the data, probably all you need is df = AB_metadata.get_database_metadata(db_name), though you may need to transform the data from a pd.DataFrame to a dict or something.

marc-vdm avatar Dec 16 '22 16:12 marc-vdm

On the branch https://github.com/marc-vdm/activity-browser/tree/including_classifications there are already some of these classifications loaded for most of the ecoinvent activities.

The classifications are now available in master, so no need to base the branch of my fork, just from master is fine 👍

marc-vdm avatar Dec 19 '22 11:12 marc-vdm

Resolved in #1047

marc-vdm avatar Jun 25 '24 09:06 marc-vdm

[!NOTE] This issue has been implemented in the new release of Activity Browser 🚀 (version 2.10.0), you can get the new version by updating Activity Browser.

Do you want to be notified of new releases of Activity Browser? Subscribe to our updates mailing list ✉.

🤖 beep boop! I'm a bot and this message was an automated action. If updating does not make sense for this issue, just ignore this.

github-actions[bot] avatar Jun 28 '24 08:06 github-actions[bot]