0 votes
30 views

Dear all,

hopping from one mine to the next one... After solving things regarding units (thanks Francois!) next one is the input/output of a process. In principle the code is as follows:

import olca_schema as schema
import olca_ipc as ipc
 
client=ipc.Client(8080)
argon_mass=150.21
#   Einheiten im Modell
mass_flow_property=client.get(schema.FlowProperty, name="Mass") # unit Mass
 
argon_gas=client.get(schema.Flow, "a94ce0ad-46f5-407c-b445-671e353875f0") # Flow Argon fluessig
mypart_flow=schema.new_flow('Bauteil',schema.FlowType.PRODUCT_FLOW,mass_flow_property)
#  Prozess
myprocess=schema.new_process(name='myprocess')
ArgonIn=schema.new_input(myprocess, argon_gas, argon_mass)
ArgonIn.default_provider=client.get(schema.Process,"aa6e701a-3728-4375-90b2-0e63eda7a627")
mypart=schema.new_output(myprocess,mypart_flow,0.5)
mypart.is_quantitative_reference=True
client.put_all(ArgonIn,mypart,myprocess)
 
#   Productsystem
myProzess_ref=client.get(schema.Process, name='myPsystem')
config=schema.LinkingConfig(prefer_unit_processes=True, provider_linking=schema.ProviderLinking.PREFER_DEFAULTS)
myPSystem=client.create_product_system(myProzess_ref,config)
print(f"created product system {myPSystem.name}, id={myPSystem.id}")
# Ansteuern des IPC Servers
setup = schema.CalculationSetup(
        target=schema.Ref(ref_type=schema.RefType.ProductSystem, name='WAMPSystem'),
        impact_method=schema.Ref(id="c45bb4f6-8b50-425f-a4f6-c69668d7ac96"),
        amount=10,
    )
result = client.calculate(setup)
assert result
result.wait_until_ready()
print(result)
# Extraktion der Ergebnisse
impacts = result.get_total_impacts()
# End of code

I receive following error message... 

ERROR:root:failed to insert model: -32602: Invalid parameters: no valid @type attribute present in request

UPDATE: I found out that the error message might come from the client.put_all command since the printout of "ArgonIn" is

Exchange(amount=150.21, amount_formula=None, base_uncertainty=None, cost_formula=None, cost_value=None, currency=None, default_provider=None, description=None, dq_entry=None, flow=Ref(id='a94ce0ad-46f5-407c-b445-671e353875f0', category='C:Manufacturing/20:Manufacture of chemicals and chemical products/201:Manufacture of basic chemicals, fertilizers and nitrogen compounds, plastics/2011:Manufacture of basic chemicals', description=None, flow_type=None, location=None, name='argon, liquid', process_type=None, ref_unit=None, ref_type=<RefType.Flow: 'Flow'>), flow_property=None, internal_id=1, is_avoided_product=None, is_input=True, is_quantitative_reference=None, location=None, uncertainty=None, unit=None)

What caught my eye is "ref_unit=None"... What is wrong with the client.put_all line

Kind regards,

Dieter

ago in openLCA by (610 points)
edited ago by

1 Answer

0 votes
ago by (6.5k points)
selected ago by
 
Best answer

Hi Dieter,

You do not have to put ArgonIn and mypart in the database.

You should probably use a Python editor (like PyCharm), that way you could see code linting that warns about such error. For example, PyCharm warns:

Expected type 'Actor | Currency | DQSystem | Epd | Flow | FlowMap | FlowProperty | ImpactCategory | ImpactMethod | Location | Parameter | Process | ProductSystem | Project | Result | SocialIndicator | Source | UnitGroup', got 'Exchange' instead

Regards,
François

ago by (610 points)
Thanks Francois!!

You helped me a lot and started a new approach! Maybe there is a new post in the pipeline ;)

Kind regards, Dieter
...