Skip to content

Commit

Permalink
fix: cfp_summary table name column value
Browse files Browse the repository at this point in the history
  • Loading branch information
khalsz committed Dec 16, 2024
1 parent dbf6ff5 commit 637c171
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Do not remove. Sqlalchemy needs this import to create tables
from . import models # noqa: F401
from .environment import DB_NAME, SQLALCHEMY_DATABASE_URL, SQLALCHEMY_DEBUG
from sqlalchemy.inspection import inspect

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -112,9 +113,10 @@ def create_cpf_summary(self, data_path: Path):
paths = data_path.glob("cpf/*_cpf_columns.parquet")
for path in paths:
df = pd.read_parquet(path)
print(df, "duty")
# replacing col name row values with cpf alias value in shotmodel
df["name"] = df["name"].apply(lambda x: models.ShotModel.__fields__.get("cpf_"+x.lower()).alias
if models.ShotModel.__fields__.get("cpf_"+x.lower()) else x)
df.to_sql("cpf_summary", self.uri, if_exists="replace")

def create_scenarios(self, data_path: Path):
"""Create the scenarios metadata table"""
shot_file_name = data_path / "shots.parquet"
Expand Down Expand Up @@ -263,4 +265,5 @@ def create_db_and_tables(data_path):

if __name__ == "__main__":
dask.config.set({"dataframe.convert-string": False})
# print(models.ShotModel.__fields__)
create_db_and_tables()

0 comments on commit 637c171

Please sign in to comment.