Skip to content

Commit e310267

Browse files
committed
Remove some noisy logging
1 parent 7d71966 commit e310267

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

learning_resources/etl/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ def get_url_from_module_id(
457457
str: The URL for the module
458458
"""
459459
if not module_id:
460-
log.warning("Module ID is empty")
461460
return None
462461
root_url = get_root_url_for_source(run.learning_resource.etl_source)
463462
# OLL needs to have 'course-v1:' added to the run_id
@@ -479,7 +478,6 @@ def get_url_from_module_id(
479478
elif module_id.startswith("block") and is_valid_uuid(module_id.split("@")[-1]):
480479
return f"{root_url}/courses/{run_id}/jump_to_id/{module_id.split('@')[-1]}"
481480
else:
482-
log.warning("Unknown module ID format: %s", module_id)
483481
return None
484482

485483

@@ -494,7 +492,7 @@ def get_assets_metadata(olx_path: str) -> dict:
494492
with Path.open(Path(olx_path, "policies/assets.json"), "rb") as f:
495493
return json.loads(f.read())
496494
except FileNotFoundError:
497-
log.warning("Assets metadata file does not exist: %s", olx_path)
495+
log.debug("Assets metadata file does not exist: %s", olx_path)
498496

499497

500498
def parse_video_transcripts_xml(
@@ -533,7 +531,7 @@ def get_video_metadata(olx_path: str, run: LearningResourceRun) -> dict:
533531
video_transcript_mapping = {}
534532
video_path = Path(olx_path, "video")
535533
if not video_path.exists():
536-
log.warning("No video directory found in OLX path: %s", olx_path)
534+
log.debug("No video directory found in OLX path: %s", olx_path)
537535
return video_transcript_mapping
538536
for root, _, files in os.walk(str(Path(olx_path, "video"))):
539537
for filename in files:

learning_resources/etl/utils_test.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,7 @@ def test_get_assets_metadata(mocker, tmp_path, assets_exist):
614614
assert result == assets_data
615615
else:
616616
# No assets.json file exists
617-
mock_log = mocker.patch("learning_resources.etl.utils.log")
618-
result = utils.get_assets_metadata(str(olx_path))
619-
assert result is None
620-
mock_log.warning.assert_called_once()
617+
assert utils.get_assets_metadata(str(olx_path)) is None
621618

622619

623620
@pytest.mark.parametrize(
@@ -687,8 +684,6 @@ def test_get_video_metadata(mocker, tmp_path, video_dir_exists):
687684
olx_path = tmp_path / "course"
688685
olx_path.mkdir()
689686

690-
mock_log = mocker.patch("learning_resources.etl.utils.log")
691-
692687
if video_dir_exists:
693688
video_dir = olx_path / "video"
694689
video_dir.mkdir()
@@ -720,9 +715,7 @@ def test_get_video_metadata(mocker, tmp_path, video_dir_exists):
720715
assert call_args[1] == video_xml
721716
else:
722717
# No video directory
723-
result = utils.get_video_metadata(str(olx_path), run)
724-
assert result == {}
725-
mock_log.warning.assert_called_once()
718+
assert utils.get_video_metadata(str(olx_path), run) == {}
726719

727720

728721
@pytest.mark.parametrize(
@@ -798,7 +791,6 @@ def test_get_video_metadata(mocker, tmp_path, video_dir_exists):
798791
],
799792
)
800793
def test_get_url_from_module_id( # noqa: PLR0913
801-
mocker,
802794
settings,
803795
etl_source,
804796
module_id,
@@ -836,9 +828,6 @@ def test_get_url_from_module_id( # noqa: PLR0913
836828
else None
837829
)
838830

839-
# Mock log for warning cases
840-
mock_log = mocker.patch("learning_resources.etl.utils.log")
841-
842831
result = utils.get_url_from_module_id(
843832
olx_path, module_id, run, assets_metadata, video_srt_metadata
844833
)
@@ -847,9 +836,3 @@ def test_get_url_from_module_id( # noqa: PLR0913
847836
assert result == expected_url_pattern
848837
else:
849838
assert result is None
850-
if not module_id:
851-
mock_log.warning.assert_any_call("Module ID is empty")
852-
elif module_id.endswith(".srt") and not has_video_meta:
853-
mock_log.debug.assert_any_call("No video metadata for %s", module_id)
854-
elif "unknown-format" in module_id or "invalid-uuid" in module_id:
855-
mock_log.warning.assert_any_call("Unknown module ID format: %s", module_id)

0 commit comments

Comments
 (0)