-
Notifications
You must be signed in to change notification settings - Fork 15
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
First try at fixing col setup without start stop. Model validator for… #1212
base: main-dev
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
|
@@ -463,6 +463,36 @@ def validate_no_forbidden_keys(self): | |
for key in self.FORBIDDEN_KEYS: | ||
if key in self.model_fields: | ||
raise ValidationError | ||
return self | ||
|
||
@model_validator(mode="after") | ||
# @classmethod | ||
def validate_start_stop_xand(self): | ||
if not (self.start and self.stop): | ||
if self.start or self.stop: | ||
Comment on lines
+472
to
+473
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. are the nested if not (self.start and self.stop) and self.start or self.stop: or if bool(self.start) != bool(self.stop): |
||
raise ValueError("Both start and stop need to be provided or both not provided.") | ||
return self | ||
|
||
# @model_validator(mode="after") | ||
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. Can we not just leave this in? 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. We can. But then we have to remove the |
||
# @classmethod | ||
# def validate_obs_config(cls, v: PyaroConfig): | ||
# if v is not None and cls.obs.config.name != cls.obs_id: | ||
# logger.info( | ||
# f"Data ID in Pyaro config {v.name} does not match obs_id {cls.obs_id}. Setting Pyaro config to None!" | ||
# ) | ||
# v = None | ||
# if v is not None: | ||
# if isinstance(v, dict): | ||
# logger.info("Obs config was given as dict. Will try to convert to PyaroConfig") | ||
# v = PyaroConfig(**v) | ||
# if v.name != cls.obs_id: | ||
# logger.info( | ||
# f"Data ID in Pyaro config {v.name} does not match obs_id {cls.obs_id}. Setting Obs ID to match Pyaro Config!" | ||
# ) | ||
# cls.obs_id = v.name | ||
# if cls.obs_id is None: | ||
# cls.obs_id = v.name | ||
# return v | ||
|
||
@cached_property | ||
def basedir_logfiles(self): | ||
|
@@ -471,27 +501,6 @@ def basedir_logfiles(self): | |
p.mkdir(parents=True, exist_ok=True) | ||
return str(p) | ||
|
||
@model_validator(mode="after") | ||
@classmethod | ||
def validate_obs_config(cls, v: PyaroConfig): | ||
if v is not None and cls.obs.config.name != cls.obs_id: | ||
logger.info( | ||
f"Data ID in Pyaro config {v.name} does not match obs_id {cls.obs_id}. Setting Pyaro config to None!" | ||
) | ||
v = None | ||
if v is not None: | ||
if isinstance(v, dict): | ||
logger.info("Obs config was given as dict. Will try to convert to PyaroConfig") | ||
v = PyaroConfig(**v) | ||
if v.name != cls.obs_id: | ||
logger.info( | ||
f"Data ID in Pyaro config {v.name} does not match obs_id {cls.obs_id}. Setting Obs ID to match Pyaro Config!" | ||
) | ||
cls.obs_id = v.name | ||
if cls.obs_id is None: | ||
cls.obs_id = v.name | ||
return v | ||
|
||
def add_glob_meta(self, **kwargs): | ||
""" | ||
Add global metadata to :attr:`add_meta` | ||
|
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.
why return
self
?