-
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 all 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 |
---|---|---|
|
@@ -464,12 +464,16 @@ def validate_no_forbidden_keys(self): | |
if key in self.model_fields: | ||
raise ValidationError | ||
|
||
@cached_property | ||
def basedir_logfiles(self): | ||
p = Path(self.basedir_coldata) / "logfiles" | ||
if not p.exists(): | ||
p.mkdir(parents=True, exist_ok=True) | ||
return str(p) | ||
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 | ||
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. the previous validator returns `self, why this one does not? |
||
|
||
@model_validator(mode="after") | ||
@classmethod | ||
|
@@ -492,6 +496,13 @@ def validate_obs_config(cls, v: PyaroConfig): | |
cls.obs_id = v.name | ||
return v | ||
|
||
@cached_property | ||
def basedir_logfiles(self): | ||
p = Path(self.basedir_coldata) / "logfiles" | ||
if not p.exists(): | ||
p.mkdir(parents=True, exist_ok=True) | ||
Comment on lines
+502
to
+503
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 see no need for the p.mkdir(parents=True, exist_ok=True) |
||
return str(p) | ||
|
||
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
?