Skip to content

Commit

Permalink
fix: : could not broadcast input array from shape (2,) into shape (1,) (
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus authored Aug 27, 2024
1 parent 5f9fad6 commit f07b411
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 57 deletions.
94 changes: 39 additions & 55 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ swifter = "^1.4.0"
tenacity = "^8.2.3"
sentry-sdk = "^2.13.0"
modin = {extras = ["ray"], version = "^0.31.0"}
numpy = "1.26.4"
[build-system]
requires = ["poetry-core>=1.1"]
build-backend = "poetry.core.masonry.api"
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 @@ -122,7 +122,8 @@ async def get_and_save_api_data(exit_event):
exit_event.set()
except Exception as err:
logging.fatal("get_and_save_api_data (%s) %s" % (type(err).__name__, err))
sys.exit(0)
ray.shutdown()
sys.exit(1)

# "Randomly wait up to 2^x * 1 seconds between each retry until the range reaches 60 seconds, then randomly up to 60 seconds afterwards"
# @see https://github.com/jd/tenacity/tree/main
Expand Down Expand Up @@ -294,7 +295,8 @@ async def main():
res=health_check_task.cancel()
except Exception as err:
logging.fatal("Main crash (%s) %s" % (type(err).__name__, err))
sys.exit(0)
ray.shutdown()
sys.exit(1)
logging.info("Exiting with success")
sys.exit(0)

Expand Down
2 changes: 2 additions & 0 deletions quotaclimat/data_processing/mediatree/channel_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def get_matching_program_weekday(df_program: pd.DataFrame, start_time: pd.Timest
df_program["weekday_mask"] = df_program['weekday'].apply(
lambda x: compare_weekday(x, start_weekday)
)
logging.debug("weekday_mask done")
matching_rows = df_program[
(df_program['channel_name'] == channel_name) &
df_program["weekday_mask"] == True
]
logging.debug("matching_rows done")
matching_rows.drop(columns=['weekday_mask'], inplace=True)
matching_rows.drop(columns=['weekday'], inplace=True)

Expand Down
7 changes: 7 additions & 0 deletions test/sitemap/test_program_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ def test_get_13h_program_with_start_timestamp():
assert program_name == "13h15 le samedi"
assert program_type == "Information - Journal"

def test_get_13h_monday_program_with_start_timestamp():
df_programs = get_programs()
monday_13h18 = 1724671082
program_name, program_type = get_a_program_with_start_timestamp(df_programs, pd.to_datetime(monday_13h18, unit='s', utc=True).tz_convert('Europe/Paris'), channel_name)
assert program_name == "JT 13h"
assert program_type == "Information - Journal"

def test_compare_weekday_string():
assert compare_weekday('*', 0) == True
assert compare_weekday('*', 3) == True
Expand Down

1 comment on commit f07b411

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py43784%36–38, 56–58, 63
   insert_existing_data_example.py19384%25–27
postgres/schemas
   models.py1471093%121–128, 140–141, 199–200, 214–215
quotaclimat/data_ingestion
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py553733%21–42, 45–58, 62–73
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py21113237%44–48, 53–69, 73–76, 82, 85–126, 132–147, 151–152, 165–177, 181–187, 200–212, 215–219, 225, 261–262, 265–301, 304–306
   channel_program.py1385163%34–36, 47–49, 63, 101, 110, 148–189
   config.py15287%7, 16
   detect_keywords.py2141294%169–172, 216, 266–273
   update_pg_keywords.py543928%14–100, 125–129, 152–178, 184
   utils.py692268%27–51, 54, 63, 84–85
quotaclimat/utils
   healthcheck_config.py291452%22–24, 27–38
   logger.py241154%22–24, 28–37
   sentry.py11282%22–23
TOTAL122536270% 

Tests Skipped Failures Errors Time
87 0 💤 0 ❌ 0 🔥 1m 36s ⏱️

Please sign in to comment.