Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running olca_schema.calculate using a stand-alone server #61

Open
pedroripper opened this issue Jun 12, 2024 · 6 comments
Open

Comments

@pedroripper
Copy link

Greetings,

You have already helped me with stalling olca-modules, but now I am having trouble when running olca_schema.calculate.

I managed to launch a stand-alone server and add some processes to the database. Now I would like to run a calculation but I keep getting this error in the terminal

13:00:09.636 [pool-1-thread-1] DEBUG com.zaxxer.hikari.pool.ProxyConnection -- HikariPool-1 - Executed rollback on connection org.apache.derby.impl.jdbc.EmbedConnection@1413730361 (XID = 2672766), (SESSIONID = 1), (DATABASE = C:/Users/pedroripper/openLCA-data-1.4/databases/ecoinvent_v3_10_Consequential_Unit_Processes_2024_01_22_rodolpho), (DRDAID = null)  due to dirty commit state on close().

Am I doing something wrong?

I have already tested this code using the server launched from OpenLCA interface and it worked.

Thanks in advance 🙂

@msrocka
Copy link
Member

msrocka commented Jun 14, 2024

Mmh, this is just a debug log message, not an error message and not a message regarding the calculation. Without more details (server setup, native libraries loaded or not, database, what does not work) it is hard to say something.

@pedroripper
Copy link
Author

Hi @msrocka. Thank you for your response and sorry for the delay.

I am starting the server running the following line in my terminal

.\ipc-server.cmd ecoinvent_v3_10_Consequential_Unit_Processes_2024_01_22_rodolpho

After that, I run something similar the example below (which runs into the same problem).

It never prints the "Finished" string, so it is probably something wrong in the calculation part.

import olca_ipc
import olca_schema

client = olca_ipc.Client(8080)

group = olca_schema.new_unit_group('Mass units', 'kg')
mass = olca_schema.new_flow_property('Mass', group)
client.put_all(group, mass)

concrete = client.get(olca_schema.Flow, 'ef5d9b7f-0d4a-49b9-a2eb-eef36ded1c38')
steel = client.get(olca_schema.Flow, '0c826417-e870-4c43-95c4-b38ff2ff47d2')

output_product = olca_schema.new_product("MyProduct", mass)
client.put(output_product)

process = olca_schema.new_process("MyProcess")

exchange = olca_schema.new_input(process, concrete, 10)
exchange.is_quantitative_reference = True

exchange = olca_schema.new_input(process, steel, 5)
exchange.is_quantitative_reference = True

exchange = olca_schema.new_output(process, output_product, 1)
exchange.is_quantitative_reference = True

created_process = client.put(process)

product_system = client.create_product_system(created_process)

method = client.get_descriptors(olca_schema.ImpactMethod)[0]

calculationSetup = olca_schema.CalculationSetup(
    target = product_system,
    impact_method = method,
)
print("Start calculation")
result = client.calculate(calculationSetup)
result.wait_until_ready()
print("Finished!")
impacts = result.get_total_impacts()

@pedroripper
Copy link
Author

Hi @msrocka !

I was wondering if you had time to look at my example.

Thanks!

@msrocka
Copy link
Member

msrocka commented Jun 26, 2024

The script works for me (but it should not create mass and a unit group but should instead get it from the database like it is done for the linked products). What is missing currently in the server startup script is the loading of the calculation libraries, the calculation then takes quite some time. The -native parameter needs to be set to a location where the calculation libraries can be found (it is described in the ipc-doc). If the script is started from a current MKL version it should point to the installation folder; something like

%java% -Xmx3584M -cp * org.openlca.ipc.Server -timeout 30 -native %script_dir%\.. -db %1

@pedroripper
Copy link
Author

Hi @msrocka ! Thank you so much for your response.

I understand that I have to point the calculation libraries folder. But I am having trouble to find it.

Shouldn't it be inside the database? I am getting confused because when I open the database with OpenLCA, there is a folder (that seems to be inside the database) with the methods. However, when I double click on the database, this is what I see

image

@pedroripper
Copy link
Author

Also, if it is not too much trouble, could you send me a command example (with all the necessary parameters) that I should run in order for my code to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants