GreenDelta / olca-ipc.py

Mozilla Public License 2.0
29 stars 17 forks source link

adding parameter with formula #24

Closed pwierzgala closed 1 year ago

pwierzgala commented 1 year ago

Hi,

I am having troubles adding a parameter with a formula. The parameter is added but with value 0 and no formula. I tried the code below and after running it in the OpenLCA -> Database -> Content -> Parameters the parameter Y has value 0 and no formula. Then I tried to add it manually and it was added as expected with value (computed) 40 and formula X*10.

import olca
from olca_schema import new_parameter

x = new_parameter('X', 4.0)
y = new_parameter('Y', 'X*10')

with olca.Client() as client:
  client.insert(x)
  client.insert(y)

It should be the same but I also tried:

import olca
from olca_schema import Parameter, ParameterScope

x = Parameter()
x.name = 'X'
x.value = 4.0
x.parameter_scope = ParameterScope.GLOBAL_SCOPE

y = Parameter()
y.name = 'Y'
y.formula = 'X*10'
y.parameter_scope = ParameterScope.GLOBAL_SCOPE

with olca.Client() as client:
  client.insert(x)
  client.insert(y)

Versions: OpenLCA: 2.0.0.beta1 olca-ipc: git+https://github.com/GreenDelta/olca-ipc.py.git/@v2 open-schema: 0.0.7

I also tried olca-ipc git+https://github.com/GreenDelta/olca-ipc.py.git/@master and the one from pypi.org but none of them worked. The code I used for with them was little different. It didn't require to install olca-schema separately and instead of new_parameter there was function parameter_of. Please note that I've managed to correctly add parameters using olca-ipc /@master and OpenLCA 1.11.0.

[1] Do you have any ideas why it doesn't work? [2] Are there any examples or documentation to v2 available online? [3] It is reasonable to use OpenLCA 2.0.0.beta1 and olca-ipc /@v2 or it's too early and it's expected that many features won't work as expected? If it's too early could you tell what's the roadmap for v2 and when a version suitable for use is expected?

msrocka commented 1 year ago

Thank you for testing the v2 branch! This issue should be fixed now with the v0.0.8 of the olca-schema module (see this test: https://github.com/GreenDelta/olca-ipc.py/blob/v2/tests/test_param.py). It is indeed a bit early to use the IPC module with version 2 and we need to update the doc and the examples. However, this was a very helpful bug-report, so thanks a lot!

pwierzgala commented 1 year ago

This issue is no longer present in the olca-ipc==2.0.0.