Closed dt-woods closed 1 month ago
Which openLCA and olca-ipc version and which database do you use? I tested it with LCA Commons /electricity baseline and this process:
import olca_ipc as ipc
import olca_schema as o
def main():
client = ipc.Client(8080)
process_ref = client.get_descriptor(
o.Process, "0082cc36-0aa6-3ff2-acf5-a2765411b57a"
)
sys_ref = client.create_product_system(
process_ref, o.LinkingConfig(
provider_linking=o.ProviderLinking.ONLY_DEFAULTS
)
)
system = client.get(o.ProductSystem, sys_ref.id)
print(f"created system {system.id}")
print(f" with {len(system.processes)} processes")
print(f" and {len(system.process_links)} process links")
if __name__ == "__main__":
main()
It works as expected:
created system eced4bde-0d77-42d0-8a68-abf88deb3c23
with 174 processes
and 342 process links
I'll double check version numbers and get back to you.
I think the errors creep in when you try to edit something existing. What
happens when you modify the product system you created and try to update it
(e.g., using the put
command)?
On Wed, Feb 28, 2024, 06:51 Michael Srocka @.***> wrote:
Which openLCA and olca-ipc version and which database do you use? I tested it with LCA Commons /electricity baseline https://www.lcacommons.gov/lca-collaboration/search/page=1&repositoryId=Federal_LCA_Commons%2FUS_electricity_baseline and this process https://www.lcacommons.gov/lca-collaboration/Federal_LCA_Commons/US_electricity_baseline/dataset/PROCESS/0082cc36-0aa6-3ff2-acf5-a2765411b57a :
import olca_ipc as ipcimport olca_schema as o
def main(): client = ipc.Client(8080) process_ref = client.get_descriptor( o.Process, "0082cc36-0aa6-3ff2-acf5-a2765411b57a" ) sys_ref = client.create_product_system( process_ref, o.LinkingConfig( provider_linking=o.ProviderLinking.ONLY_DEFAULTS ) ) system = client.get(o.ProductSystem, sys_ref.id) print(f"created system {system.id}") print(f" with {len(system.processes)} processes") print(f" and {len(system.process_links)} process links")
if name == "main": main()
It works as expected:
created system eced4bde-0d77-42d0-8a68-abf88deb3c23 with 174 processes and 342 process links
— Reply to this email directly, view it on GitHub https://github.com/GreenDelta/olca-ipc.py/issues/31#issuecomment-1968819567, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHCFB5I6BDIGAIN44JE2LYLYV4K5RAVCNFSM6AAAAABCLGH4EGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYHAYTSNJWG4 . You are receiving this because you authored the thread.Message ID: @.***>
I'm running:
I'm not reading from a database; rather, I'm trying to build one.
openLCA 2.1.0 ; olca-ipc 2.0.2
It should work then. The requirements are that the processes need to be all in the database before calling create_product_system
and for the linking option ONLY_DEFAULTS
they must have the default providers set in the processes. When this is the case, I cannot reproduce this.
When you are building the database via IPC, you may need to check the default providers in the processes; they are only linked when they are already present in the database, so the import order is important then.
Thanks. My order of operations matches yours: first build all the processes with default providers, then build the product systems.
Are there any common data errors you've encountered that prevent product systems from being created?
I found the error in my code and I got product systems working again. Thanks for your assistance!
I am attempting to generate Product systems using the IPC server and Python. The command,
client.create_product_system
takes two arguments: reference object to process and the linking configuration. I set the linking configuration settings and run the IPC command, which generates a reference object to the new product system, which is also generated in openLCA's database. I query the product system and look at the processes list and processLinks list and find only the reference process listed for processes and an empty list for the processLinks.I don't see where the link configuration is doing anything. If I stop the IPC service and open the product system, the model graph is plain (see below).
If I right-click on the input flow, I get a context menu with the option to "Build flow supply chain" with two options: Complete and Build next tier. The options under "Complete" look quite similar to the options I set in the LinkConfiguration.
If I click the option I set in the IPC, the processes and process_links lists are updated. Of course, I have to click "Save" in openLCA first. I'm not sure what is running when I do this.
Why this doesn't work in IPC?
Is there something I need to do to force this completion, a method I missed, or must I write my own methods to build these lists?
Thanks for your time and assistance.