HARPgroup / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
1 stars 0 forks source link

First specl function def PR #33

Closed rburghol closed 1 year ago

rburghol commented 1 year ago

Work with @jdkleiner to get a PR on respec with the bare bones specl inclusion:

jdkleiner commented 1 year ago

@rburghol Sounds good, I'm working on getting a clean "pull request ready" version of the specl branch now

jdkleiner commented 1 year ago

@rburghol I think I've got it ready for a RESPEC pull request, take a look (See specl branch) https://github.com/HARPgroup/HSPsquared/tree/specl

Only 2 files are modified compared to the master branch of HSPsquared

Other files with specl stuff (I did not include these file updates in this push):

Note: specl is the "pull-request ready" branch, I've stashed all of our additional specl progress in specl_10.18.22

rburghol commented 1 year ago

Awesome, I'll take a quick look at it compared to the develop branch that we have locally and let you know, but it sounds great.

rburghol commented 1 year ago

By the way I really like how you set all of the additional changes into a separate branch so that we can just make the poll requests from our specl branch. I think that'll help organize it really nicely.

rburghol commented 1 year ago

Thanks again -- Here are my suggestions/questions:

jdkleiner commented 1 year ago

@rburghol After a little bit of sleuthing I agree. Because we're calling specl() from within the njit-decorated _hydr_(), we probably don't need the second level _specl_() so long as all of the processes within specl() are "Numba compile-able".

Excerpt from RESPEC HSPsquared documentation _"The reason for the two functions levels is that Numba does not compile all Python language constructs, any Pandas functions, and some Numpy library functions. So the top level function, snow() for example, can be arbitrary Python, Pandas and Numpy code which prepares data to be used by the second level code like _snow_( ). The second level code and all routines called by it must be compatible with Numba so that the code can be compiled. Any violation of Numba constraints will prohibit the compilation and force the code to run a Python speed."_

I'll work on revising specl accordingly.

Perhaps the function becomes this simple, is @njit needed if its called within a @njit-wrapped function? :

def specl(ui, ts, step, specactions):
    print("specl()")

    # example for modifying ts element
    ts['OUTDGT2'][step] = 99
rburghol commented 1 year ago

Awesome:

rburghol commented 1 year ago

I have onemore thing:

Also I noticed something interesting.

jdkleiner commented 1 year ago

@rburghol

See updated branch here (also removed print): https://github.com/HARPgroup/HSPsquared/blob/specl/HSP2/SPECL.py

jdkleiner commented 1 year ago

Also to your merging question. Looks like we've already pushed an earlier version of SPECL to the respec develop branch?https://github.com/respec/HSPsquared/blob/develop/HSP2/SPECL.py

rburghol commented 1 year ago

Ahhhhh. Maybe that's why the merge is funky. OK - so that's weird. I honestly don't know how that happened. My PRs have only been with the branch psa, but looks like I pulled specl into that? That was not a thoughtful thing for me to do :). At least the code is not filled with testing stuff.

So:

Sorry this is getting complicated.

jdkleiner commented 1 year ago

Yeah somehow the psa branch has all of the other specl development stuff in there (multiple additional files modified with specl stuff beyond the simple example of HYDR.py just loading and calling specl() and SPECL.py defining specl()).

So perhaps place your latest psa work into the specl branch, then do a pull request to respec master? or is the develop branch the place to do all pull requests?

rburghol commented 1 year ago

Oh sheesh -- thanks for sleuthing that out.

jdkleiner commented 1 year ago
rburghol commented 1 year ago
jdkleiner commented 1 year ago

Ok gotcha, I'll do just that and report back

jdkleiner commented 1 year ago

Alright I believe I've got it, see the updated specl branch: https://github.com/HARPgroup/HSPsquared/tree/specl/HSP2

Though still unable to merge with respec/develop?

jdkleiner commented 1 year ago

Pull request made: https://github.com/respec/HSPsquared/pull/104