-
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
use antares-study-version
package to handle versions
#79
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
from dataclasses import dataclass, field | ||
from enum import IntEnum | ||
from pathlib import Path | ||
|
||
from antares.study.version import StudyVersion | ||
|
||
class Modes(IntEnum): | ||
antares = 1 | ||
|
@@ -43,7 +43,7 @@ class StudyDTO: | |
# Simulation stage data | ||
time_limit: t.Optional[int] = None | ||
n_cpu: int = 1 | ||
antares_version: int = 0 | ||
antares_version: StudyVersion = StudyVersion.parse(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the parsing from tiny db will work ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Writing: Reading: @classmethod
def from_dict(cls, doc: t.Mapping[str, t.Any]) -> "StudyDTO":
"""
Create a Study DTO from a mapping.
"""
attrs = dict(**doc)
attrs.pop("name", None) # calculated
attrs["antares_version"] = StudyVersion.parse(attrs["antares_version"])
return cls(**attrs) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I still added a smalle unit test to test this. |
||
xpansion_mode: str = "" # "", "r", "cpp" | ||
run_mode: Modes = Modes.antares | ||
post_processing: bool = False | ||
|
@@ -59,4 +59,5 @@ def from_dict(cls, doc: t.Mapping[str, t.Any]) -> "StudyDTO": | |
""" | ||
attrs = dict(**doc) | ||
attrs.pop("name", None) # calculated | ||
attrs["antares_version"] = StudyVersion.parse(attrs["antares_version"]) | ||
return cls(**attrs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
antares-study-version~=1.0.7 | ||
bcrypt~=3.2.2 | ||
cffi~=1.15.1 | ||
cryptography~=39.0.1 | ||
|
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 not very safe to do this because we change the study object:
if it's used after this method call, antares_version is a string and not a StudyVersion anymore.
It would be more safe to copy the dict for example
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.
Ah okay I see, modifying
vars(study)
alters thestudy
object. I didn't think about that. I'll do a deepcopy of the dict.