cyrillefrancois / openlca2bw

Other
9 stars 5 forks source link

Does "update_openLCA_IPC()" implement version control? #13

Open qtu-UBC opened 6 months ago

qtu-UBC commented 6 months ago

Hi, I wonder if there is a version control mechanism implemented for "update_openLCA_IPC()" or every time I execute the function (even if I only modified one process), the entire existing database will be reimported again (seems to be the case by looking at the code)? Thank you.

cyrillefrancois commented 6 months ago

Hello, Yes, in the current version, when you update a database the function "update_openLCA_IPC()" or "update_openLCA_json()" will delete and recreate the associated database. A solution to avoid that will be to use the "last_change" field or OpenLCA version field. But it needs new fields in BW2 also. Otherwise, it needs a function able to compare bw2 activities with openlca processes, but I believe that this kind of function will be long to execute. I keep this issue open if contributors have ideas to share to improve activities/processes version control.

qtu-UBC commented 6 months ago

Thanks for the insight. Alternatively, is it possible to only update the "foreground data" while keeping the background data (e.g., ecoinvent) unchanged? I think in bw2, once you've written a db to a project (e.g., ecoinvent 3.8 cutoff), it's always there, you just need to update the linkage between your foreground model (i.e., where certain activities from ei 3.8 are involved) and the background db.

cyrillefrancois commented 6 months ago

Yes, the "update_openLCA_IPC()" is made for that. The argument "update_databases={}" is made for that. If your OpenLCA database is structure with folders (e.g. "A:Agriculture, forestry and fishing", "B:..." and "My_project_folders") and in bw2 you have 3 databases for biosphere, ecoinvent and your_project, you have to put update_databases={"your_project":"My_project_folders"}. Then the function will only read the folder "My_project_folders" and replace the database "your_project" in bw2.

qtu-UBC commented 6 months ago

Ah, thanks for the explanation. Do you mean {"your_database":"My_project_folders"} where "your_database" is part of the existing bw project that I'm trying to update? As there is already an argument "project_name" in update_openLCA_IPC().

Yes, the "update_openLCA_IPC()" is made for that. The argument "update_databases={}" is made for that. If your OpenLCA database is structure with folders (e.g. "A:Agriculture, forestry and fishing", "B:..." and "My_project_folders") and in bw2 you have 3 databases for biosphere, ecoinvent and your_project, you have to put update_databases={"your_project":"My_project_folders"}. Then the function will only read the folder "My_project_folders" and replace the database "your_project" in bw2.

cyrillefrancois commented 6 months ago

Yes, exactly. "project_name" is the BW2 project name