sandialabs / OWENS.jl

GNU Lesser General Public License v3.0
8 stars 4 forks source link

Running OWENS in a python wrapper #16

Open kevmoor opened 6 months ago

kevmoor commented 6 months ago

Desire is to run Julia functions directly in Python WEIS, see https://discourse.julialang.org/t/calling-julia-functions-from-python/6885/2

Would possibly still start with file dump, system run, and then read file

Need others to be able to run this easily.

kevmoor commented 6 months ago

This works, assuming you have julia and OWENS running. It took just a few minutes to implement.

# juliaup update
# pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install juliacall
from juliacall import Main as jl
from juliacall import Pkg as jlPkg

jlPkg.activate("../../../")  # relative path to the folder where `MyPack/Project.toml` should be used here 

jl.seval("using OWENS")

testdata = jl.OWENS.runOWENS(jl.OWENS.MasterInput("./sampleOWENS.yml"),"./").to_numpy()
kevmoor commented 6 months ago

So, the next step is aligning the inputs and outputs with potential design optimization needs, which is being defined in #18

Need to review with NREL folks and then this should be completed.

dzalkind commented 5 months ago

Hi Kevin,

I may need some on-line support with running this tomorrow. Here are a few things I've tried:

Running as-is give me:

ERROR: LoadError: ArgumentError: Package GyricFEA [3cd7cb04-a333-4aed-a1f1-c87982f3ae73] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

So, I added a jlPkg.instantiate() to the script.

Then, I get a

juliacall.JuliaError: expected package `PreComp [19f83dec]` to be registered
Stacktrace:

I tried several other things we can go over, but never get further than the PreComp registration notice.

Any ideas?

kevmoor commented 5 months ago

Hi Daniel,

The dependency tree needs to be satisfied. Until the repos can be open sourced and registered with the package manager, they need to be installed manually, in the order specified.

If you have already done that, and are using visual studio, sometimes visual studio activates the current directory’s project.toml environment, instead of the overall julia 1.10 etc environment. If this is the case, you can simply click on the current environment in the bottom ribbon and select the desired environment. Running directly from the terminal would also remove any issues caused by the ide.

Kevin R. Moore – R&D S&E, Mechanical Engineering ORG 8921 – Wind Energy Computational Sciences @.**@.> | CELL: 208-749-0340 [SNL_Horizontal_Black]

From: dzalkind @.> Reply-To: "SNL-WaterPower/OWENS.jl" @.> Date: Thursday, March 14, 2024 at 5:37 PM To: "SNL-WaterPower/OWENS.jl" @.> Cc: "Moore, Kevin Ray" @.>, Assign @.***> Subject: [EXTERNAL] Re: [SNL-WaterPower/OWENS.jl] Running OWENS in a python wrapper (Issue #16)

Hi Kevin,

I may need some on-line support with running this tomorrow. Here are a few things I've tried:

Running as-is give me: `ERROR: LoadError: ArgumentError: Package GyricFEA [3cd7cb04-a333-4aed-a1f1-c87982f3ae73] is required but does not seem to be installed:

So, I added a jlPkg.instantiate() to the script.

Then, I get a

juliacall.JuliaError: expected package PreComp [19f83dec] to be registered Stacktrace:

I tried several other things we can go over, but never get further than the PreComp registration notice.

Any ideas?

— Reply to this email directly, view it on GitHubhttps://github.com/SNL-WaterPower/OWENS.jl/issues/16#issuecomment-1998650512, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APO3LIDYGM4SDSVJLKORARLYYIYDTAVCNFSM6AAAAABDXEDOGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJYGY2TANJRGI. You are receiving this because you were assigned.Message ID: @.***>

dzalkind commented 5 months ago

Okay, I made some progress on this:

Within the python script, I had to jlPkg.activate('/Users/dzalkind/.julia/environments/v1.9/Project.toml')

In chatting with @yqliaohk, I learned that she had installed several dependencies in developer mode. Perhaps that's also another source of our differences in set up?

kevmoor commented 5 months ago

Great! Maybe, mine are in developer mode as well, so that could be it.

Also, I just pushed a patch to the dev branch of OWENS.jl that fixes the post processing errors. If you have a developer install of owens (cloned locally, cd path2directory/OWENS.jl, julia, ] dev .) then you can just pull and check out the branch and then it will use the branch.