-
Notifications
You must be signed in to change notification settings - Fork 171
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
Support relative paths in YAML configuration files #739
Support relative paths in YAML configuration files #739
Conversation
@rafmudaf it seems that the examples CI is attempting to convert .py files again. I'm not sure why this would be the case, especially since I synced my develop and main branches prior to starting this work. UPDATE: I've removed the |
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 looks good to me. One small catch is that many, but not all, examples can be run from outside of the examples/ directory. I like that a lot of the examples can now be run from an arbitrary location, but some examples have hardcoded relative paths within the scripts, which means the user needs to run those particular examples from within examples/.
For example, examples 07, 08, 12 (both? are there meant to be two example 12s without an a, b, c modifier?) 13, and 29 directly call inputs/wind_rose.csv, so fail when run from outside of the examples/ directory.
That's a good catch @misi9170. I've made this note in #642 (comment), and we should address this when we finally get around to creating more cohesive set of training material. |
Enable Relative File Paths in YAML Configurations
This PR enables users to successfully define relative paths in 3 locations:
FlorisInterface
configuration file. The configuration file will now attempt to be located as-is and as a path relative to the file being run, so users can runpython examples/30_multi_dimensional_cp_ct.py
orcd examples && python 30_multi_dimensional_cp_ct.py
with the same resultsFarm.turbine_library_path
takes a similar route, but will attempt three locations:TurbineMultiDimensional
now has an input for a turbine library path so that thepower_thrust_data_file
can attempted to be found at either the location or originally provided or a path relative to where FLORIS is being run.This PR also addresses some docstring ambiguity as it relates to the above implementation.
Related issue
From #604, a better solution is needed for handling user's configurations where they are, and this is often as relative paths, including in our examples, which is what this PR is solving.
This PR should close #737 as it resolves the relative path definition of the multidimensional Cp-Ct curve, and completes one of the remaining tasks in #733.
Impacted areas of the software
floris.type_dec.convert_to_path
: A three-pronged search for the path is performed, and the adds a validation step, so nonexistent file paths are found earlier.floris.simulation.farm.Farm
:internal_turbine_library_path
is added to provide a namespace for the module's__default_library_path
turbine_library_path
: is now either matching the internal or mapped to 1 of 2 file path locations (see above).floris.tools.FlorisInterface
: enables relative file paths to in the configuration definition, and updates the internal mapping, if that is the case.floris/simulation.turbine_multi_dim.TurbineMultiDimensional
:turbine_library_path
has been added as an argument, which is passed from theFarm
class on initialization, to indicate where thepower_thrust_data_file
will be located.power_thrust_data_file
should no longer point directly to where it is located, but should be in relation to the FLORIS turbine library, or in a user-provided turbine library. This change will promote adherence to consistent data library usage.Additional supporting information
How to effectively manage relative file definitions in YAML has been a lingering issue since the introduction of the turbine library, and this enhancement should work towards a more rigorous Turbine Library by providing some necessary patches to unconsidered use cases.
Test results, if applicable
All tests pass, and all CI tests pass as a result, demonstrating that this successfully addresses #737, while leaving room to build a more robust turbine library per #604.