-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(ts-gen): add timeseries generation #2112
Conversation
39e9095
to
027978e
Compare
027978e
to
89e9d30
Compare
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.
Suggestion to use more numpy/pandas for performance reason + question on backup mechanism + a few minor comments.
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Outdated
Show resolved
Hide resolved
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Show resolved
Hide resolved
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Show resolved
Hide resolved
modulation_matrix = study_data.tree.get( | ||
["input", "thermal", "prepro", area_id, thermal.id.lower(), "modulation"] | ||
)["data"] | ||
modulation_capacity = np.array([row[2] for row in modulation_matrix]) |
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 use an enum or constants for the various column numbers
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 used constants
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Outdated
Show resolved
Hide resolved
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Outdated
Show resolved
Hide resolved
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Outdated
Show resolved
Hide resolved
# 8- Generates the UUID for the `get_inner_matrices` method | ||
uuid = study_data.tree.context.matrix.create(generated_matrix) | ||
self._INNER_MATRICES.append(uuid) | ||
# 9- Write the matrix inside the input folder. |
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.
It's a shame that we need to:
- write the matrix twice, in the matrix store AND as a file here
- duplicate here the code that writes a matrix to a file: it's only 1 line but we need to ensure consistency between here and other places where we write matrice, it's error-prone for future evolutions
For 2, we should probably have a small utility method shared at least beween matrix.py
and here.
For 1, I have not easy solution, we probaby need to postpone this ... Note that this kind of direct write will be an issue the day we want to store input matrices with a different format.
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.
Now that we don't have inner_matrices anymore, the 1. is no longer relevant.
Also for 2. I created a function dump_dataframe inside matrix.py that I reused here
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Show resolved
Hide resolved
antarest/study/storage/variantstudy/model/command/generate_thermal_cluster_timeseries.py
Outdated
Show resolved
Hide resolved
Uses antares-timeseries-generation to perform thermal clusters timeseries generation. The generation is performed as a background task on file studies, since it can take several seconds or more. Note that generated matrices are not "inner matrices" of the command since they are generated on each command execution. Generated matrices that will be stored later in the matrix store will be saved from garbage collection as all other snaphot matrices.
Here's an exemple of generation duration time with this PR performed after the commit
add little tests
.It's clear to see why we need to use
tasks
.We'll probably encounter some timeouts during variants safe generation. To avoid that, we'll have to increase this limit which is hard-coded at 60 seconds inside the code