-
Notifications
You must be signed in to change notification settings - Fork 96
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
AttributeError: 'Pandas' object has no attribute 'chkpar' #488
Comments
Did you rerun the PstFrom pest-interface construction with the new version of pyemu? |
I have not, but Moussa had a similar issue and he rebuilt everything from scratch w/ the latest versions of packages and is now having an issue running his model. |
I'm going to try to use pyemu version 1.2.0 and older pandas |
tried running with pyemu 1.2.0 and pandas 2.0.2 and still same error. this is all with python 3.11. It did run for a colleague that is still using python 3.9, so wondering if its a compatibility issue with newer python? |
So just to be clear, you reran the python functions that build the pest interface with PstFrom (essentially rebuilt the control file, template file, instruction files, etc)? And this was done using the same version of pyemu/pandas that you are using at runtime that calls apply_genericlist_pars()? We have several CI tests that cover this use case with PstFrom and they seem to be ok and I know that |
yes, i rebuilt the entire pest framework (PstFrom) from scratch, including observations. All of the rebuilding worked fine. The problem occurs when we try to do a forward run with pestpp using the forward_run.py I, and a couple other colleagues get the same error as follows: Traceback (most recent call last): |
Ok thats a new error from before and I think its related to the version of pandas (maybe). What version of pandas are you using? |
im using: |
hmm. That should be ok. Can you zip up your model+pest files and post them somewhere so that I can check them out? |
can i email them to you? |
Ok I think I see the issue (@briochh would know better) - it looks like you are broadcasting grid-type multiplier parameters for the wel package across multiple stress periods, which isn't a problem in and of itself except that you have differing numbers of well package entries across the stress periods. I think this is what is tripping things up because the number and location of individual well entry (ie grid-type) jumps from 420 in the first stress period to 1042 in the second stress period, which looks like is confusing pandas about how to apply the 420 grid-based wel multipliers. To fix this, either don't broadcast the grid-type pars across multiple stress periods or fill the well entries across the stress periods with zero-flux (dummy) entries so that all stress periods have the same well entries. @briochh does this jive? For some reason I thought we were trapping for this use case when add_pars() is called... |
@jtwhite79, yeah that sounds like something that could cause some dramas. We do have a check in the If this is what is causing the issue, I feel like we could handle this are forward run time, as the multipliers are aligned according to the values of index_cols so the number of entries or even the order shouldn't matter. I think we should put together a quick test that reproduces this issue and see if this casting is feasible. One challenge might come if the values in @jptraylor, in the mean time your best/easiest work around would be, as @jtwhite79 suggests, to pad those input files so that the same well locs are represented in all the files that you are passing to that |
@jptraylor, are you still seeing that |
@jtwhite79 @briochh I'm not understanding the issue with applying the grid-scale pumping multipliers for each stress period's wel package. Each mult file located in the mult directory, with suffix grid.csv is unique for each stress period and has the same number of rows or mults as there are number of wells in the associated wel file, so those match up. I guess i dont understand where the mismatch is occurring. |
Yes, i got that error when i initially ran the model (which was originally built on older versions of pyemu and pandas) with the recent pyemu and pandas versions. Then, per Jermey's suggestion, i rebuilt the pest framework with the recent pyemu/pandas versions and got that xx.get() error |
Ok, that xx.get() error is really just an indication that something is failing on the multiprocess -- the tracebacks from there can be a little long winded. The true error looks to be related to |
Yes, sharing that model with you is fine |
@jtwhite79 One big difference i found between the original version of the model (created with older version of pyemu/pandas) and this new one (created with newer versions of pyemu/pandas) is that the grid mult files for the wells look different. For example, we have multipliers by datasource, of which there are three pumping datasources (datasource is specified as a boundname in each wel file), so the original version has a mult grid file for wel_datasource that has three entries whereas the new one has a bunch of entries per datasource, although its difficult to tell how the number of entries per datasource in the new file lines up with the number of actual wells. So, the new pyemu/pandas is constructing these grid mults in a different way, it appears. |
Thats an interesting observation. @briochh I dont think we have changed the way the PstFrom sets up parameters for a given set of arguments but i could be wrong. @jptraylor do you have the original model+pest files (if so can you email them to me?)? |
yes i have them, will send them. |
Ok after looking at those files, the number of well parameters is the same and the mult2model_info.csv is the same. The tpl files for the well multipliers are different - the new tpl file for the "datasource" tag only has two entries compared to the original. I found this is the call where wel parameters are added and tagged with "datasource"
but when I run |
Well it would help if i sent you the correct model, been testing things on my end, got a few versions going. Basically the one i sent was the the forward run i tried to rerun with the newer pyemu/pandas and it bombed, so it didnt write any of the org/wel*.dat files to the external/wel*.dat. I'm sending you the correct original now. |
Ok Ive dug in some more. i can confirm that the new style tpl file has many more lines than the one produced by v1.2, however they both still have only 3 unique parameters, corresponding to the 3 datasource types. It looks like the new tpl file has the maximum number of entries found in any wel list file - I seem to remember going to this style broadcasting multiplier file for a reason, but it escapes me now (@briochh will probably remember). Anyhow, for me, if I roll back to v1.2 (py 3.10 and pandas 2.1), I get the same tpl as before, which ought to be what you are after... |
I'm using py 3.11 right now, are you suggesting i get a 3.10 version setup with pyeemu v1.2? |
@jtwhite79 what is the significance of the mwe.zip? Maybe i'm missing something, but thye look to be the same as the original wel files i sent |
I just add those as files for @briochh in case he wanted to check it out. The tpl files look to be the same as the original if I use the version listed above... |
@jptraylor, looking into this now. If I am reading it right you are trying to set up a parameter for each "type" or well and broadcast it across all well files. Is this correct? |
@jptraylor, you could try an approach like this:
|
@jtwhite79 I was able to get everything running with python 3.10, pyemu 2.1 and pandas 1.5.3 (pandas 2.1 threw a deprecation error from the pyemu/helpers.py about a change in kwarg name line_terminator to lineterminator). |
@jptraylor, can you check those version number again? pyemu is currently only at 1.3.3. Would be good to note down here the approach that you are using for this type of use case. We added that chkpar business to try and make sure that we would error at run time if the number of model pars connected to a multiplier parameter weren't to as expected (rather than silently continue). With the earlier version of pyemu, it may not throw an error, but it may not be doing what you expect! |
@briochh ah i see! Everything ran with python 3.10, pyemu 1.2, and pandas 1.5.3 |
ok, definitely things changed between pandas 1.5.3 and 2.1. We pinned pyemu 1.3.3 to pandas < 2.1, so the incompatibility there is not too surprising. That being said, it might be worth double checking that the multiplier changes that you think are occurring are being propagated through to the resultant model input pars. You could try pyemu 1.3.3 with pandas < 2.1, as we added a bit more robust error check at apply time in 1.3.3. You could set up a quick and dirty test with the example that you passed where you modify |
I am trying to do a forward noptmax=0 run of a model. and I got the error message:
AttributeError: 'Pandas' object has no attribute 'chkpar'
which occurs immediately upon execution of the forward.py script. Here is the screenshot of errors:
starting list mlt 2024-03-19 11:59:12.021732
number of chunks to process: 9
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
^^^^^^^^^^^^^^^^^^^
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 2048, in _process_chunk_list_files
raise e
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 2045, in _process_chunk_list_files
_process_list_file(model_file, df)
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 2177, in _process_list_file
assert len(common_idx) == mlt.chkpar, (
^^^^^^^^^^
AttributeError: 'Pandas' object has no attribute 'chkpar'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\projects\D_GV6800\analysis\model\cache_cal_testing\cache500eastcr_forward\forward_run.py", line 12, in
main()
File "D:\projects\D_GV6800\analysis\model\cache_cal_testing\cache500eastcr_forward\forward_run.py", line 8, in main
pyemu.helpers.apply_list_and_array_pars(arr_par_file='mult2model_info.csv',chunk_len=50)
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 1599, in apply_list_and_array_pars
apply_genericlist_pars(list_pars, chunk_len=chunk_len)
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 2036, in apply_genericlist_pars
[xx.get() for xx in x]
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\site-packages\pyemu\utils\helpers.py", line 2036, in
[xx.get() for xx in x]
^^^^^^^^
File "C:\Users\jtraylor\AppData\Local\miniforge3\envs\gis\Lib\multiprocessing\pool.py", line 774, in get
raise self._value
AttributeError: 'Pandas' object has no attribute 'chkpar'
My pyemu version is 1.3.3+6.g3322178a. My pandas version is 2.1.1.
This model was made on an older version of pyemu and pandas.
Is this a versioning issue? I'm wondering if its a new versioning issue between pyemu and pandas?
The text was updated successfully, but these errors were encountered: