Skip to content
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

if the folder doesn't exist #835

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/troute-config/troute/config/output_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,27 @@ class ParityCheckCompareFileSet(BaseModel):

class StreamOutput(BaseModel):
# NOTE: required if writing StreamOutput files
stream_output_directory: Optional[DirectoryPath] = None
stream_output_directory: Optional[Path] = None
mask_output: Optional[FilePath] = None
stream_output_time: int = 1
stream_output_type:streamOutput_allowedTypes = ".nc"
stream_output_internal_frequency: Annotated[int, Field(strict=True, ge=5)] = 5

@validator('stream_output_directory')
def validate_stream_output_directory(cls, value):
if value is None:
return None

# expand ~/output/dir -> /home/user/output/dir
value = value.expanduser()

if value.exists() and not value.is_dir():
raise ValueError(f"'stream_output_directory'={value!s} is a file, expected directory.")

# make directory (and intermediates) if they don't exist
value.mkdir(parents=True, exist_ok=True)
return value

@validator('stream_output_internal_frequency')
def validate_stream_output_internal_frequency(cls, value, values):
if value is not None:
Expand Down
Loading