-
Notifications
You must be signed in to change notification settings - Fork 105
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
Issue227 - Turbine, Panel and CSP Installation Configs from local path #250
Conversation
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.
Some ideas for improvements. What do you think?
NB: We need to be careful if we change how the of get_windturbineconfig
is handled. If we only allow str
values from atlite.resource.windturbines
then that would be a breaking change which we should avoid.
atlite/resource.py
Outdated
if not Path(turbine).exists(): | ||
if not turbine.endswith(".yaml"): | ||
turbine += ".yaml" | ||
|
||
turbine = WINDTURBINE_DIRECTORY / turbine |
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.
Rather than presuming that if the Path does not exist that then it might be a pre-shipped one, we can check if it is a shipped config by checking:
turbine in windturbines
and then instead of manually constructing the path
turbine = windturbines[turbine]
as we have the turbines which are pre-shipped as well as their paths already read in windturbineconfig
.
atlite/resource.py
Outdated
The configuration can be one from local storage, then 'turbine' is | ||
considered part of the file base name '<turbine>.yaml' in config.windturbine_dir. | ||
Alternatively the configuration can be downloaded from the Open Energy Database (OEDB), | ||
Alternatively, the configuration can be downloaded from the Open Energy Database (OEDB), | ||
in which case 'turbine' is a dictionary used for selecting a turbine from the database. | ||
Finally, turbine can also be a path to a local config file. |
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.
We need to do some adjustements here, as config.windturbine_dir
does not exist (very old legacy piece of doc which shouldn't be here).
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.
E.g.
The configuration can be either one of the configurations shipped with atlite, one loaded from a local path or retrieved from the Open Energy Database (OEDB):
If one of the names of the preshipped turbines from atlite.resources.windturbines
is provided, that turbine configuration is loaded and returned.
If a pathlib.Path
object is provided, this local path is read and the turbine configuration from this Path is parsed.
If a string starting with "oedb:" is provided, atlite will try to read the turbine configuration for this from OEDB.
atlite/resource.py
Outdated
if not Path(panel).exists(): | ||
if not panel.endswith(".yaml"): | ||
panel += ".yaml" | ||
panel = SOLARPANEL_DIRECTORY / panel | ||
|
||
else: | ||
panel = Path(panel) |
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.
See above for windturbine configs
atlite/resource.py
Outdated
if not Path(installation).exists(): | ||
|
||
# if isinstance(installation, str): # not sure what this does | ||
if not installation.endswith(".yaml"): | ||
installation += ".yaml" | ||
installation = CSPINSTALLATION_DIRECTORY / installation | ||
|
||
installation = CSPINSTALLATION_DIRECTORY / installation | ||
else: | ||
installation = Path(installation) |
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.
See above for windturbine configs
Hey @LukasFrankenQ, this looks sensible! What is the state here? As far as I see the only thing missing is the doc suggestion of @euronion. I would not enforce a |
Hey @FabianHofmann, hey @euronion, thank you for the suggestions (and the suggestion by @euronion on Discord). I believe that the following strikes a balance between both suggestions made, i.e. retains flexibility wrt being agnostic in
In case of the turbine it would of course first check for being an oedb file. The only problem with this is that if I had |
I would prefer strongly enforcing We don't do it for cutouts partially due to legacy reasons and partially because we have the freedom to do so, as there are no "standard" cutouts which ship with Standard use case in the past for the turbine name (and other configs) was to provide the name of the turbine which was translated into a path. Now we would just enforce this behaviour. We could even think about omitting the |
@euronion you are right. I did not think properly about what the |
Hi @euronion, Hi @FabianHofmann, |
Looking good, thanks for the PR! |
Closes #227.
Change proposed in this Pull Request
Methods
get_windturbineconfig
,get_solarpanelconfig
andget_cspinstallationconfig
load yaml files based on the passedconfiguration name. Now, additionally, the methods recognize if a path to a locally stored config is passed.
The file is then loaded instead of a predefined config.
Description
The methods run
Path([the local path]).exists()
to check if the path exists. If not, the methods assume that the user passedthe name of a config, and proceeds as before the change.
Motivation and Context
This is a small change, proposed a while ago by @fneum. I seems like a sensible addition.
How Has This Been Tested?
I checked all three functions to make sure that both old and new behaviour are behaving as expected.
Type of change
Checklist
pytest
inside the repository and no unexpected problems came up. (one apparently unrelated error)doc/
.environment.yaml
file.doc/release_notes.rst
.pre-commit run --all
to lint/format/check my contribution