-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature: run prototype with command line tool #36
Conversation
Signed-off-by: Sylvain Leclerc <sylvain.leclerc@rte-france.com>
to test see tests/unittests/data/components_for_thermal_cluster.yml
allows to take data with several scenarios
src/andromede/main/main.py
Outdated
return resolve_components_and_cnx(parse_yaml_components(comp), model) | ||
|
||
|
||
if __name__ == "__main__": |
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.
For clarity, I suggest to put all that is bellow here in a "main" function:
if __name__ == "__main__": | |
if __name__ == "__main__": | |
main() |
enable the possibility to use the command with only the parameter --study fix the fact that the preloaded_libraries parameter in the resolve_library method didn't keep the preloaded models in the returned library
src/andromede/main/main.py
Outdated
database = None | ||
|
||
if args.study: | ||
if args.models or args.component or args.timeseries: |
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.
I think there's a way in ParseArgs to create exclusive groups, i.e., sets of arguments that can't be passed together so you would automatically check for this, but maybe it won't be enough for your needs 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.
there is but you can't make an argument excludes with other arguments which are not mutually exclusive
the importing order is an depth-first travelsal of the tree going from every library to the root or an already imported library the algo : - checks if there is cycles and raise error if so - can import models form 2 separated tree - doesnt check if ports are defined twice no test available the code isnt commented
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.
A few suggestions:
- adding a "console script" entry point
- moving some new methods to more appropriate places in inner modules
src/andromede/model/parsing.py
Outdated
@@ -93,6 +93,7 @@ class Config: | |||
|
|||
class InputLibrary(BaseModel): | |||
id: str | |||
dependence: Optional[str] = None |
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 should allow a list here to import multiple libraries --> "dependencies"
src/andromede/main/main.py
Outdated
if import_stack[-1].dependence in did: | ||
lib = resolve_library(import_stack[-1], [output_lib]) | ||
|
||
output_lib.models.update(lib.models) |
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 can add a check here that there is no name conflict between models
src/andromede/main/main.py
Outdated
lib = resolve_library(import_stack[-1], [output_lib]) | ||
|
||
output_lib.models.update(lib.models) | ||
output_lib.port_types.update(lib.port_types) |
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 can add a check here that there is no name conflict between port types
src/andromede/main/main.py
Outdated
yaml_libraries[yaml_lib.id] = yaml_lib | ||
|
||
todo = list(yaml_libraries.values()) | ||
did = list() |
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.
Note that it's better to use a set
for this kind of use: a search in a set is more efficient than in a list (to be honest here it does not really matter in practice because it will always be small).
src/andromede/main/main.py
Outdated
parser.error( | ||
"--study flag can't be use with --models, --component and --timeseries" | ||
) | ||
components_path = args.study / "input" / "components" / "components.yml" |
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.
Let's move this logic (of parsing all data from one directory) to andromede.study.parsing
src/andromede/main/main.py
Outdated
print("scenario ", scenario) | ||
print("status : ", status) | ||
|
||
print("avarage final cost : ", problem.solver.Objective().Value()) |
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.
typo "average"
src/andromede/main/main.py
Outdated
def main() -> None: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--study", type=Path, help="path to the root dirertory of the study" |
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.
typo directory
src/andromede/main/main.py
Outdated
"--component", type=Path, help="path to the component file, *.yml" | ||
) | ||
parser.add_argument( | ||
"--timeseries", type=Path, help="path to the timeseries dirertory" |
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.
typo directory
fix old test, changing input library to list of input libraries
No description provided.