Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions preprocessing/sports/SAR_data/soccer/soccer_SAR_class.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```python
# Target data provider [Metrica,Robocup 2D simulation,Statsbomb,Wyscout,Opta data,DataFactory,sportec]

"""
Expand All @@ -14,6 +15,7 @@
"""

import os
from pathlib import Path
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor, as_completed

Expand Down Expand Up @@ -343,15 +345,41 @@ def preprocess_data(self, cleaning_dir=None, preprocessed_dir=None):
cleaning_dir,
preprocessed_dir,
)
)
)
# Collect results as they are completed
for future in tqdm(as_completed(futures), total=len(futures)):
future.result()
else:
raise ValueError(f"Preprocessing method not supported for {self.data_provider}")
elif self.preprocess_method == "SAR2RL":
if self.data_provider != "robocup_2d":
raise ValueError(
"SAR2RL preprocessing is only supported for data_provider='robocup_2d'."
)

if preprocessed_dir is None:
raise ValueError(
"preprocessed_dir is required for preprocess_method='SAR2RL' and data_provider='robocup_2d'."
)

sar_preprocessed_dir = Path(preprocessed_dir)
if not sar_preprocessed_dir.exists() or not sar_preprocessed_dir.is_dir():
raise ValueError(
f"SAR2RL input directory not found: {sar_preprocessed_dir}. "
"Run SAR preprocessing first or pass a valid preprocessed_dir."
)

output_dir = sar_preprocessed_dir / "rl_dataset"
print("Starting SAR-to-RL dataset conversion...")
from .soccer_sar_to_rl_dataset import build_rl_datasets_from_sar_events

build_rl_datasets_from_sar_events(
sar_preprocessed_dir=sar_preprocessed_dir,
output_dir=output_dir,
)
else:
raise ValueError(
"Preprocessing method is not defined. Please set preprocess_method to 'SAR' or other valid methods."
"Preprocessing method is not defined. Please set preprocess_method to 'SAR' or 'SAR2RL'."
)

print("Data preprocessing completed successfully!")
Expand Down
Loading