-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dynamic python code #65
Comments
Notes 6/21/23: These notes have been incorporated into the body of this issue, and in a separate issue #67 |
This allows you to test manually at the command line. More illuminating is the code in the body of the issue.
Sample code to put into a model
|
@rburghol Couple notes when running the test above:
|
Hey @jdkleiner -- sorry, the test code does suffer from the lack you describe :) -- |
|
Tested on:
|
Goal: have a set of functions defined by local code that are executable in
@njit
. see respec#113state
on deq1PL3_5250_0001
'/home/rob/working/modeling/hsp2/river_wd/PL3_5250_0001.py'
PL3_5250_0001.py
file in that directory, it'll load the file and the functioned defined withinPL3_5250_0001.py
is the functionom_test_fn()
fixjup
(develop with install fix for bad jupyter line) takes 7 seconds (:15 on first compile)spects
loads 20-30 OM components and takes 12 seconds (:22 on 1st compile)state
loads 0 OM, and takes 17 seconds each time (no diff w/1st compile), even if there is no dynamic code loaded, or empty dynamic code function.statex
used to disable, then sequentially enable things (run from 1984-2001):hydr()
, and does settingstate_ix[o1_ix' ...
each timestep, but no computationsmain
, and all state loading stuff in HYDR, but no njoi module loading, nor any code in hydr executed.state_info
to_hydr_()
state_paths
_hydr_()
_hydr_
main.py
load_dynamics()
(need to move this from main.py since the dynamic code must be loaded in the same module that it is called in, however, maybe we can also pass it in as part of a standard python dictionary, but then split it out as an individual function when passing thsp2_local_py = dynamic_module_import(fbase, local_path + "/" + fbase + ".py", "hsp2_local_py")
hsp2_local_py
modulehsp2_local_py.state_step_hydr(model_exec_list, op_tokens, state_ix, dict_ix, ts_ix, hydr_ix, step)
Loading and Executing
@njit
code,Since all functions called by njit code must be njit also, the dynamic functions must be defined before the first call of the larger routine, such as
_hydr_()
.Example Withdrawal
PL3_5250_0001.h5
PL3_5250_0001.py
:PL3_5250_0001.py
and set the withdrawa (O1)l to 0.0The text was updated successfully, but these errors were encountered: