LCA-ActivityBrowser / activity-browser

GUI for brightway2
GNU Lesser General Public License v3.0
152 stars 58 forks source link

Issue switching from one project to another #373

Closed romainsacchi closed 4 years ago

romainsacchi commented 4 years ago

I am experiencing issues switching from one project to another, on the welcome page. The error thrown is the following:

image

The app does not totally crash, but the content of the project is not shown.

dgdekoning commented 4 years ago

I think I've come across something like this before, is it possible that at some point you imported data through brightway and used create_new_biosphere method? I think that is the only method that quietly creates a 'file' database instead of defaulting to sqlite.

The easiest 'fix' on your end would be to remove the database through brightway. Probably not something you want to do.

Brightway2 code says we can iterate through a singlefile database, so some slight changes to the AB should fix the issue.

dgdekoning commented 4 years ago

Together with the databases table there are 4 instances of len being called on bw.Database.

romainsacchi commented 4 years ago

That could indeed be the issue. Thanks for the answer. I'll see in the meanwhile if I can do without the additional biosphere db.

romainsacchi commented 4 years ago

Yes, I can reproduce the error in brighway2. This would throw an error: len(bw.Database("additional_biosphere"))

dgdekoning commented 4 years ago

A short solution would be to use sum(1 for _ in bw.Database("additional_biosphere")) where it counts all the activities.

Going through the code I've noticed a few other possible issues (bw.Database is being pumped directly into a pandas DataFrame in the MetaDataStore class) but I'm unsure if these require changes or if the __iter__ implementation in the SingleFileDatabase allows all of that to work correctly.

dgdekoning commented 4 years ago

Building a development version with the fix included now. Thanks for reporting this @romainsacchi and please don't hesitate to bring up any other issues you come across!