Skip to content

Commit

Permalink
Create output directories in write_*
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Dec 20, 2024
1 parent 6a9ecd0 commit 7679b19
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
4 changes: 3 additions & 1 deletion petab/v1/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def write_condition_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab condition table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_condition_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=True)


Expand Down
4 changes: 3 additions & 1 deletion petab/v1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def write_simulation_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab simulation table
filename: Destination file name
filename: Destination file name. The parent directory will be created
if necessary.
"""
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=False)


Expand Down
4 changes: 3 additions & 1 deletion petab/v1/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def write_mapping_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab mapping table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_mapping_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=True)


Expand Down
4 changes: 3 additions & 1 deletion petab/v1/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def write_measurement_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab measurement table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_measurement_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=False)


Expand Down
4 changes: 3 additions & 1 deletion petab/v1/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def write_observable_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab observable table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_observable_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=True)


Expand Down
4 changes: 3 additions & 1 deletion petab/v1/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ def write_parameter_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab parameter table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_parameter_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=True)


Expand Down
3 changes: 2 additions & 1 deletion petab/v1/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ def write_yaml(yaml_config: dict[str, Any], filename: str | Path) -> None:
Arguments:
yaml_config: Data to write
filename: File to create
filename: File to create. Parent directories are created if necessary.
"""
Path(filename).parent.mkdir(parents=True, exist_ok=True)
with open(filename, "w") as outfile:
yaml.dump(
yaml_config, outfile, default_flow_style=False, sort_keys=False
Expand Down
4 changes: 3 additions & 1 deletion petab/v2/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def write_experiment_df(df: pd.DataFrame, filename: str | Path) -> None:
Arguments:
df: PEtab experiments table
filename: Destination file name
filename: Destination file name. Parent directories are created if
necessary.
"""
df = get_experiment_df(df)
Path(filename).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(filename, sep="\t", index=False)

0 comments on commit 7679b19

Please sign in to comment.