1919import logging
2020import tempfile
2121from contextlib import contextmanager
22- from functools import lru_cache , partial
22+ from functools import lru_cache
2323from typing import (
2424 Any ,
2525 BinaryIO ,
4646# Type for PDP converter functions (DataFrame -> DataFrame); used for cohort/course.
4747PDPConverterFunc = Optional [Callable [[pd .DataFrame ], pd .DataFrame ]]
4848
49+
50+ def _default_pdp_course_duplicate_converter (df : pd .DataFrame ) -> pd .DataFrame :
51+ """
52+ PDP course duplicate cleanup for read_raw_pdp_course_data.
53+
54+ Passes the schema selector as the second *positional* argument so this works
55+ with current edvise (``schema_type``) and older builds that used the same slot
56+ for ``school_type``. Do not pass bare ``handling_duplicates`` as a converter:
57+ read_raw_pdp_course_data calls ``converter_func(df)`` with a single argument.
58+ """
59+ return handling_duplicates (df , "pdp" )
60+
61+
4962# --------------------------------------------------------------------------- #
5063# Logging
5164# --------------------------------------------------------------------------- #
@@ -867,9 +880,8 @@ def _read_pdp_course_edvise(
867880
868881 Tries each datetime format with each converter. If a custom
869882 course_converter_func is provided (e.g. from a school), it is tried first;
870- then the default handling_duplicates(..., school_type="pdp"), then
871- handling_duplicates for older edvise. Raises HardValidationError if all
872- attempts fail.
883+ then :func:`_default_pdp_course_duplicate_converter` (``handling_duplicates``
884+ with PDP settings). Raises HardValidationError if all attempts fail.
873885
874886 Args:
875887 path: Path to course CSV.
@@ -882,10 +894,7 @@ def _read_pdp_course_edvise(
882894 Raises:
883895 HardValidationError: If no (converter, format) pair succeeded.
884896 """
885- default_converters = (
886- partial (handling_duplicates , school_type = "pdp" ),
887- handling_duplicates ,
888- )
897+ default_converters = (_default_pdp_course_duplicate_converter ,)
889898 converters = (
890899 (course_converter_func ,) if course_converter_func is not None else ()
891900 ) + default_converters
@@ -903,7 +912,7 @@ def _read_pdp_course_edvise(
903912 except ValueError as e :
904913 last_error = e
905914 except TypeError as e :
906- if "school_type" in str (e ):
915+ if "school_type" in str (e ) or "schema_type" in str ( e ) :
907916 last_error = None
908917 break
909918 raise
0 commit comments