Skip to content
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

Merged
merged 10 commits into from
Nov 28, 2023

Conversation

RHammond2
Copy link
Collaborator

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 run python examples/30_multi_dimensional_cp_ct.py or cd examples && python 30_multi_dimensional_cp_ct.py with the same results
  • Farm.turbine_library_path takes a similar route, but will attempt three locations:
    • The file path as-is
    • The file path relative to the location where the FLORIS script is located
    • The file path relative to the system location that is attempting to run FLORIS (this applies primarily to testing or internal applications)
  • TurbineMultiDimensional now has an input for a turbine library path so that the power_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:
    • arguments have been added to the docstring.
    • 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:
    • Arguments have been added to the docstring to provide clarity
    • turbine_library_path has been added as an argument, which is passed from the Farm class on initialization, to indicate where the power_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.

@RHammond2 RHammond2 added bug Something isn't working enhancement An improvement of an existing feature floris.tools documentation floris.simulation labels Nov 21, 2023
@RHammond2
Copy link
Collaborator Author

RHammond2 commented Nov 21, 2023

@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 jupyter nbconvert section as there are no notebooks in the examples directory. I've also updated example 18, which relied on its relative position to floris/ from examples/ to load the turbines.

@rafmudaf rafmudaf requested a review from misi9170 November 28, 2023 19:14
@rafmudaf rafmudaf changed the title Enhancement: Relative paths in YAML configuration files Support relative paths in YAML configuration files Nov 28, 2023
@rafmudaf rafmudaf added this to the v3.6 milestone Nov 28, 2023
Copy link
Collaborator

@misi9170 misi9170 left a 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.

@rafmudaf
Copy link
Collaborator

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.

@rafmudaf rafmudaf merged commit 34a7e0c into NREL:develop Nov 28, 2023
@RHammond2 RHammond2 deleted the enhancement/yaml-relative-file branch November 29, 2023 16:00
@misi9170 misi9170 mentioned this pull request Apr 5, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation enhancement An improvement of an existing feature floris.simulation floris.tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants