Skip to content

Commit

Permalink
🔊(xi) add possibility to ignore error when indexing courses
Browse files Browse the repository at this point in the history
Validation errors that happens on course indexing were not ignored by the
`ignore_errors` flag.
Fixing it.
  • Loading branch information
wilbrdt committed Jun 3, 2024
1 parent 3949e08 commit 759856d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/api/core/warren/xi/indexers/moodle/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ async def _extract(self) -> List[Course]:

def _transform(self, raw: List[Course]) -> Iterator[ExperienceCreate]:
"""Transform courses into experiences."""
return (course.to_experience(base_url=self._lms.url) for course in raw)
for course in raw:
try:
yield course.to_experience(base_url=self._lms.url)
except ValidationError as err:
if not self._ignore_errors:
raise err
logger.exception("Skipping invalid course %s", course.id)
pass

async def _load(self, data: Iterator[ExperienceCreate]) -> None:
"""Load experiences into the Experience Index (XI)."""
Expand Down Expand Up @@ -121,6 +128,7 @@ def _transform(self, raw: List[Section]) -> Iterator[ExperienceCreate]:
if not self._ignore_errors:
raise err
logger.exception("Skipping invalid module %s", module.id)
pass

async def _load(self, data: Iterator[ExperienceCreate]) -> None:
"""Load experiences into the Experience Index (XI) and create relations."""
Expand Down

0 comments on commit 759856d

Please sign in to comment.