Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log: fix error array from shape (2,) into shape (1,) #213

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ services:
#END_DATE: "2024-02-29" # optional - otherwise end of the month
BATCH_SIZE: 100 # number of records to update in one batch
# START_DATE: 1717227223 # to test batch import
CHANNEL : france2 # to reimport only one channel
CHANNEL : france-info # to reimport only one channel
MEDIATREE_USER : /run/secrets/username_api
MEDIATREE_PASSWORD: /run/secrets/pwd_api
MEDIATREE_AUTH_URL: https://keywords.mediatree.fr/api/auth/token/
Expand Down
6 changes: 4 additions & 2 deletions quotaclimat/data_processing/mediatree/api_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ async def get_and_save_api_data(exit_event):
logging.info(f"Querying API for {channel} - {channel_program} - {channel_program_type} - {start_epoch} - {end_epoch}")
df = extract_api_sub(token, channel, type_sub, start_epoch,end_epoch, channel_program,channel_program_type)
if(df is not None):
logging.debug(f"Memory df {df.memory_usage()}")
save_to_pg(df, keywords_table, conn)
else:
logging.info("Nothing to save to Postgresql")
logging.info(f"Memory df {df.memory_usage()}")

del df # memory leak test for long running jobs
gc.collect()
except Exception as err:
Expand Down Expand Up @@ -234,7 +235,8 @@ def parse_reponse_subtitle(response_sub, channel = None, channel_program = "", c
logging.debug("Schema from API before formatting :\n%s", new_df.dtypes)

new_df['timestamp'] = pd.to_datetime(new_df['start'], unit='s', utc=True)
new_df.drop('start', axis=1, inplace=True) # keep only channel.name
logging.debug("setting timestamp")
new_df.drop('start', axis=1, inplace=True)
logging.debug("renaming columns")
new_df.rename(columns={'channel.name':'channel_name',
'channel.title':'channel_title',
Expand Down
Loading