diff --git a/kloppy/_providers/sportec.py b/kloppy/_providers/sportec.py index c1d0574f..fe152c6d 100644 --- a/kloppy/_providers/sportec.py +++ b/kloppy/_providers/sportec.py @@ -13,6 +13,8 @@ from kloppy.io import open_as_file, FileLike from kloppy.utils import deprecated +from requests.exceptions import HTTPError + def load_event( event_data: FileLike, @@ -121,19 +123,32 @@ def load_open_event_data( coordinates: Optional[str] = None, event_factory: Optional[EventFactory] = None, ) -> EventDataset: + """ + Data associated with research paper: + Bassek, M., Weber, H., Rein, R., & Memmert, D. (2024). + "An integrated dataset of synchronized spatiotemporal and event data in elite soccer." In Submission. + """ if not META_DATA_MAP.get(match_id): raise ValueError( f"This match_id is not available, please select from {list(META_DATA_MAP.keys())}" ) - return load_event( - event_data=DATA_URL.format(file_id=EVENT_DATA_MAP[match_id]), - meta_data=DATA_URL.format(file_id=META_DATA_MAP[match_id]), - event_types=event_types, - coordinates=coordinates, - event_factory=event_factory, - ) + try: + return load_event( + event_data=DATA_URL.format(file_id=EVENT_DATA_MAP[match_id]), + meta_data=DATA_URL.format(file_id=META_DATA_MAP[match_id]), + event_types=event_types, + coordinates=coordinates, + event_factory=event_factory, + ) + except HTTPError as e: + raise HTTPError( + "Unable to retrieve data. The dataset archive location may have changed. " + "Please verify the `kloppy.sportec.DATA_URL` and file mappings. " + "This issue might be resolved by updating to the latest version of kloppy. " + "Original error: {}".format(e) + ) def load_open_tracking_data( @@ -143,17 +158,30 @@ def load_open_tracking_data( coordinates: Optional[str] = None, only_alive: Optional[bool] = True, ) -> EventDataset: + """ + Data associated with research paper: + Bassek, M., Weber, H., Rein, R., & Memmert, D. (2024). + "An integrated dataset of synchronized spatiotemporal and event data in elite soccer." In Submission. + """ if not META_DATA_MAP.get(match_id): raise ValueError( f"This match_id is not available, please select from {list(META_DATA_MAP.keys())}" ) - return load_tracking( - raw_data=DATA_URL.format(file_id=TRACKING_DATA_MAP[match_id]), - meta_data=DATA_URL.format(file_id=META_DATA_MAP[match_id]), - sample_rate=sample_rate, - limit=limit, - coordinates=coordinates, - only_alive=only_alive, - ) + try: + return load_tracking( + raw_data=DATA_URL.format(file_id=TRACKING_DATA_MAP[match_id]), + meta_data=DATA_URL.format(file_id=META_DATA_MAP[match_id]), + sample_rate=sample_rate, + limit=limit, + coordinates=coordinates, + only_alive=only_alive, + ) + except HTTPError as e: + raise HTTPError( + "Unable to retrieve data. The dataset archive location may have changed. " + "Please verify the `kloppy.sportec.DATA_URL` and file mappings. " + "This issue might be resolved by updating to the latest version of kloppy. " + "Original error: {}".format(e) + )