Skip to content

Commit

Permalink
new script for standardizing tables
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Nov 12, 2024
1 parent 0d908bc commit 51e3ff5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/depiction_targeted_preproc/workflow/panel/standardize_panel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import cyclopts
import polars as pl
from pathlib import Path
from rich.pretty import pprint

from depiction_targeted_preproc.panel.schema import PanelMainSchema
from depiction_targeted_preproc.panel.standardize_input_panel import StandardizeConfig, standardize

app = cyclopts.App()


def _standardize(input_panel_path: Path, config_name: str) -> pl.DataFrame:
input_df = pl.read_csv(input_panel_path)
config = StandardizeConfig.load_packaged(config_name)
return standardize(config=config, raw_df=input_df)


def _validate(output_df: pl.DataFrame) -> None:
results = PanelMainSchema.validate(output_df)
pprint(results)


@app.default
def standardize_panel(input_panel_path: Path, config_name: str, output_panel_path: Path) -> None:
output_df = _standardize(input_panel_path=input_panel_path, config_name=config_name)
_validate(output_df=output_df)
output_df.write_csv(output_panel_path)


if __name__ == "__main__":
app()

0 comments on commit 51e3ff5

Please sign in to comment.