Skip to content

Commit

Permalink
ENH Add input/output file validators to MergePartialator
Browse files Browse the repository at this point in the history
  • Loading branch information
gadorlhiac committed Apr 5, 2024
1 parent e5d82ee commit 2ccba6b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lute/io/models/sfx_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Config(BaseBinaryParameters.Config):
"", description="Path to input stream.", flag_type="-", rename_param="i"
)
out_file: str = Field(
"partialator.hkl",
"",
description="Path to output file.",
flag_type="-",
rename_param="o",
Expand Down Expand Up @@ -185,6 +185,29 @@ class Config(BaseBinaryParameters.Config):
rename_param="harvest-file",
)

@validator("in_file", always=True)
def validate_in_file(cls, in_file: str, values: Dict[str, Any]) -> str:
if in_file == "":
stream_file: Optional[str] = read_latest_db_entry(
f"{values['lute_config'].work_dir}",
"ConcatenateStreamFiles",
"out_file",
)
if stream_file:
return stream_file
return in_file

@validator("out_file", always=True)
def validate_out_file(cls, out_file: str, values: Dict[str, Any]) -> str:
if out_file == "":
in_file: str = values["in_file"]
if in_file:
tag: str = in_file.split(".")[0]
return f"{tag}.hkl"
else:
return "partialator.hkl"
return out_file


class CompareHKLParameters(BaseBinaryParameters):
"""Parameters for CrystFEL's `compare_hkl` for calculating figures of merit.
Expand Down

0 comments on commit 2ccba6b

Please sign in to comment.