From 8f7337bc043e560543ded641be1bfc6385264d59 Mon Sep 17 00:00:00 2001 From: Masato Onodera Date: Mon, 19 May 2025 09:39:39 -1000 Subject: [PATCH] Fix flux_type error by treating Enum properly. --- src/targetdb/cli/cli_main.py | 16 ++++++++-------- src/targetdb/utils.py | 6 ++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/targetdb/cli/cli_main.py b/src/targetdb/cli/cli_main.py index fd540a8..f3860ed 100644 --- a/src/targetdb/cli/cli_main.py +++ b/src/targetdb/cli/cli_main.py @@ -225,7 +225,7 @@ def checkdups( check_duplicates( indir=directory, outdir=output_dir, - file_format=file_format, + file_format=file_format.value, skip_save_merged=skip_save_merged, additional_columns=additional_columns, check_columns=check_columns, @@ -306,7 +306,7 @@ def prep_fluxstd( input_catalog_id, input_catalog_name, rename_cols=rename_cols, - file_format=file_format, + file_format=file_format.value, ) @@ -353,7 +353,7 @@ def diagram( draw_diagram( config, - generator=generator, + generator=generator.value, output_dir=output_dir, title=title, sc_info_level=sc_info_level, @@ -417,7 +417,7 @@ def insert( typer.Option( "--flux-type", help="Flux type for the flux standard star catalog." ), - ] = "total", + ] = FluxType.total, upload_id: Annotated[ str, typer.Option( @@ -449,14 +449,14 @@ def insert( add_database_rows( input_file=input_file, - table=table, + table=table.value, commit=commit, fetch=fetch, verbose=verbose, config=config, df=df, from_uploader=from_uploader, - flux_type=flux_type, + flux_type=flux_type.value, proposal_id=proposal_id, upload_id=upload_id, insert=True, @@ -663,7 +663,7 @@ def insert_targets( typer.Option( "--flux-type", help="Flux type for the flux standard star catalog." ), - ] = "total", + ] = FluxType.total, commit: Annotated[ bool, typer.Option("--commit", help="Commit changes to the database."), @@ -685,7 +685,7 @@ def insert_targets( df_input_catalogs, config, data_dir=data_dir, - flux_type=flux_type, + flux_type=flux_type.value, commit=commit, fetch=fetch, verbose=verbose, diff --git a/src/targetdb/utils.py b/src/targetdb/utils.py index f0de875..3719597 100644 --- a/src/targetdb/utils.py +++ b/src/targetdb/utils.py @@ -654,10 +654,12 @@ def make_target_df_from_uploader( except AttributeError: pass if f"flux_{band}" in df.columns: + logger.info(f"flux_{band} is renamed to {flux_type}_flux_{band}") df.rename( columns={f"flux_{band}": f"{flux_type}_flux_{band}"}, inplace=True ) if f"flux_error_{band}" in df.columns: + logger.info("flux_error_{band} is renamed to {flux_type}_flux_error_{band}") df.rename( columns={f"flux_error_{band}": f"{flux_type}_flux_error_{band}"}, inplace=True, @@ -875,6 +877,10 @@ def add_database_rows( dry_run = True logger.info("No changes will be committed to targetDB (i.e., dry run)") + # logger.info(f"{df['total_flux_r'][:100]}") + # db.close() + # exit() + if insert: db.insert(table, df, dry_run=dry_run) elif update: