+1 vote
1.1k views
Hi,

Recently I have downloaded openLCA 2.0.4 and tried to run these lines with OpenLCA IPC server & olca-ipc in python:

------------------------------------

import olca

import uuid

client = olca.Client(8080)

all_processes = client.get_descriptors(olca.Process)

for thispros in all_processes:

    print(thispros.name)

------------------------------------

I keep getting this kind of error:

ERROR:root:failed to get descriptors of type <class 'olca.schema.XXX'>: -32601: Does not understand: get/descriptors

I have switch from Process to Flow Property, ProductSystem, and keep getting errors like this:

ERROR:root:failed to get descriptors of type <class 'olca.schema.FlowProperty'>: -32601: Does not understand: get/descriptors

ERROR:root:failed to get descriptors of type <class 'olca.schema.Unit'>: -32601: Does not understand: get/descriptors

ERROR:root:failed to get descriptors of type <class 'olca.schema.FlowProperty'>: -32601: Does not understand: get/descriptors

ERROR:root:failed to get descriptors of type <class 'olca.schema.ProductSystem'>: -32601: Does not understand: get/descriptors

------------------------------------

But then when I switch back to openLCA 1.11.0, it worked again without running into those errors.

What has changed since version 1 and what should I change so that my python code will work with OpenLCA 2.X?

Thank you!
in openLCA by (170 points)

1 Answer

+3 votes
by (630 points)
selected by
 
Best answer

For using olca-ipc with openLCA 2.x, you will need to upgrade the version of your olca-ipc package and import it as "olca_ipc".

Moreover, some of the functions have been moved from olca-ipc to the olca-schema library, which you can import via "olca_schema".

In order to print the process names in your example above, the following code works for me:

import olca_ipc as ipc
import olca_schema as o
 
client = ipc.Client(8080)
 
all_processes = client.get_descriptors(o.Process)
for thispros in all_processes:
    print(thispros.name)
As you can see, the object "Process" is accessed via the olca-schema library.
You will probably need to modify your code for it to work with openLCA 2.x.
Kind regards

by (170 points)
I am using Python 3.10.10 but openLCA >= 2 requires Python >= 3.11. I guess that's the reason. Thank you!
...