-
Notifications
You must be signed in to change notification settings - Fork 45
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
v0.8.0 bug fixes and doc string fixes #327
Conversation
@ssolson is it possible we can change our automated pypi release to be triggered by Github releases instead of commits to master? The current automation prevents us from making minor documentation updates after a release. We typically don't get to this in time and the documentation is built on master which we only see after a release. |
Fortunately I found a work around that allows us to get our documentation updated quickly before OREC. So we don't need these changes pulled in immediately. But long term we should still look at how our development workflows on each repo tie into doc updates. |
@ssolson I identified issues within several python examples and work on getting these fixed ASAP. I reworked this PR to focus on bugs, not just minor documentation items. I'd like to make this a bugfix release as soon as possible. The notebook vs script runs may have inadvertently been an environment issue (3.9 vs 3.11). Checking on that now. |
Update on WPTO_hindcast_example.ipynb: |
Update on qc_example.ipynb: |
The pypi.yml release currently works exactly the way you request it to work here.
|
I have cleared cache and re run multiple times. |
This is not an MHKiT error You just need to pip install folium folium is only used to add context to the example and is not a requirement of MHKiT |
Apologies and Never mind. I see the issue is the basemap was showing up gray. I have now fixed this in akeeste#4 |
I take responsibility for not catching this but I did not realize that the wave module xarray conversion made the functions so slow they are now unusable. E.g. in the Pacwave resource characterization this block now takes greater than 30 minutes... unless you convert Tp back to use pandas which will only take 9 minutes. @akeeste I know the wave module is still in a bit of transition but do you expect the time gains to be significantly reduced when completed? I am questioning our approach to always convert pandas to xarray.
|
@ssolson Thanks for clarifying. I missed that when skimming the pypi.yml workflow |
* fix cdip * D3D TRTS eg fix * fix pylint error * pylint * fix too many branches
@ssolson thanks for addressing the cdip and D3D examples in akeeste#4. I was also able to get the directional_waves example to run when the cached was cleared. Maybe there's an issue using pickle to read data into Python 3.11 when it was cached in 3.9? That's the situation I had locally. Not something we need to address, but something to be aware of. On the note of computational speed-- I implemented a few changes to our type handling to address this, but perhaps there's still an instance that uses |
Apologies my previous message was not clear. Yes there are issues with the computation (not just the conversion) on the converted xarrays. Specifically with the calculation of Tp. This morning I created the following script and found Tp to be the primary bottle neck. I commented out the built in MHKiT Tp and used MHKiT v0.7.0 pandas version inline and found significant speed increases ~60% faster. Time results using built in Tp
Time results using previous pandas TpLook at the results for the Tp calculation vs the others:
|
@ssolson Okay understood. Seems odd as the methodology is essentially the same now, but applied on an xarray dataset (and with type handling). I wonder if the delay is mostly in the type conversion or xarray's How does the expense compare if the spectra is already an xarray Dataset (type handling eliminated) and we calculate Tp with:
|
That is what I found. Finding the argmax is a very expensive operation on the xarray. I spent some time trying to fix this but I realized I was getting outside the scope of this PR pretty quickly. So I wanted to circle back with you and see if time gains from a full implementation of xarray are to be expected or if we should reconsider our approach? |
I don't expect a significant improvement in computational expense in the future just by using xarray. Let's discuss approaches at our next monthly meeting. |
* fix cdip * D3D TRTS eg fix * fix pylint error * pylint * fix too many branches * fix map and Tp * folium fix & Tp using pandas * up to python 3.10 * py version as string * fix variable check for new xarray * undo changes
mhkit/wave/performance.py
Outdated
LM = convert_to_dataset(LM).to_array() | ||
JM = convert_to_dataset(JM).to_array() | ||
frequency = convert_to_dataset(frequency).to_array() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is causing the tests to fail. I'm looking into it but if you are around @akeeste I know you are more familiar with these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akeeste can you tell me the reasoning behind this change? Is it simply a performance thing to go Dataset to array instead just to array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest solution is to skip the conversion if it is already a DataArray. Otherwise we are going to need to pass the name around to fix this.
Do you have a preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssolson I fixed these few lines. To be honest, I can't recall at the moment why I made this change, but I reverted it and the power_performance_workflow tests are passing now.
If I can jump in, a part of this problem might be because yall are using Datasets for single variables rather than DataArrays. This line If you want to keep the DataSets that line gets more complicated, but is still a touch faster: |
@jmcvey3 thank you for jumping in. I have not tried this yet but looks promising. From our meeting yesterday @akeeste is going to address the outstanding issues to pass tests and get these bug fixes through. Because the proposed solution changes the general approach we are going to address this in a follow on PR focused on the larger xarray strategy. |
There's still a couple tests failing. I'm not sure why the mooring test is failing since I only updated the docstring (for better formatting in the built docs). I'll continue looking into this and narrow in on an issue in the metocean example. |
Part of matplotlib, unrelated to this PR, that is called in the mooring animation is depreciated in 3.9+, causing the mooring_test to fail here. I'm guessing that if we re-run tests on dev, it would fail there too. @hivanov-nrel any insight on how we can fix this? |
Hi Adam, it looks like the issue is on line 89 and line 129. The inputs needs to be a sequence so the fix for this is putting brackets around them like so:
Do you mind implementing this on your PR or should I do this fix separately? |
Thanks for taking a quick look @hivanov-nrel. That fixed mooring_test, I'll add it to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adam this looks good to me. If this is ready to merge it would help me bc #330 depends on these changes and I am being forced to run hindcast tests on that PR currently.
This PR addresses several bug and doc string fixes in v0.8.0. I think it's critical that we make these fixes before our workshop next Thursday.
I tested all of our Python examples on a clean install of MHKiT with Python 3.11. There are several examples with errors
mhkit.utils.index_to_datetime
is removed/renamedsignificant_wave_height_0
Incorporates several minor documentation fixes: