In this page:
https://databallpy.readthedocs.io/en/latest/getting_started/visualizations_page.html
This line:
fails with this traceback:
In [3]: game = get_open_game()
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 game = get_open_game()
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/logging.py:26, in logging_wrapper.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
22 except Exception as e:
23 logger.error(
24 f"Error in the function `{func.__name__}`: {e}\n{traceback.format_exc()}"
25 )
---> 26 raise e
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/logging.py:19, in logging_wrapper.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
17 try:
18 logger.info(f"Trying to run the function `{func.__name__}`")
---> 19 result = func(*args, **kwargs)
20 logger.info(f"Successfully ran the function `{func.__name__}`")
21 return result
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/get_game.py:556, in get_open_game(provider, game_id, verbose, use_cache)
554 save_path = os.path.join("datasets", "IDSSE", game_id)
555 if use_cache and os.path.exists(save_path):
--> 556 return get_saved_game(save_path)
558 tracking_data, metadata = load_sportec_open_tracking_data(
559 game_id=game_id,
560 verbose=verbose,
561 )
562 event_data, ed_metadata, databallpy_events = load_sportec_open_event_data(
563 game_id=game_id
564 )
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/logging.py:26, in logging_wrapper.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
22 except Exception as e:
23 logger.error(
24 f"Error in the function `{func.__name__}`: {e}\n{traceback.format_exc()}"
25 )
---> 26 raise e
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/logging.py:19, in logging_wrapper.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
17 try:
18 logger.info(f"Trying to run the function `{func.__name__}`")
---> 19 result = func(*args, **kwargs)
20 logger.info(f"Successfully ran the function `{func.__name__}`")
21 return result
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/databallpy/utils/get_game.py:364, in get_saved_game(name, path)
361 if not os.path.isdir(full_path):
362 raise ValueError(f"Directory {full_path} does not exist")
--> 364 with open(os.path.join(full_path, "metadata.json"), "rb") as f:
365 metadata = json.load(f)
367 return Game(
368 tracking_data=TrackingData(
369 pd.read_parquet(os.path.join(full_path, "tracking_data.parquet")),
(...)
404 _check_inputs_=False,
405 )
FileNotFoundError: [Errno 2] No such file or directory: '/Users/felix/datasets/IDSSE/J03WMX/metadata.json'
I would have expected this to download an open game like it did with provider="metrica" on this page: https://databallpy.readthedocs.io/en/latest/getting_started/loading_in_a_game_page.html
As a consequence, I could not continue this tutorial, because the game opened with provider="metrica" fails:
game = get_open_game(provider="metrica")
from databallpy.visualize import plot_tracking_data
import numpy as np
game.tracking_data.add_velocity(
column_ids=game.get_column_ids(),
filter_type="savitzky_golay",
max_velocity=13.0,
allow_overwrite=True
)
second_pass_id = game.event_data.loc[game.event_data["databallpy_event"]=="pass", "event_id"].iloc[1]
idx = game.tracking_data[game.tracking_data["event_id"]==second_pass_id].index[0]
x_grid, _ = np.meshgrid(np.linspace(0, 1, 15), np.linspace(0, 1, 10))
fig, ax = plot_soccer_pitch(field_dimen=game.pitch_dimensions, pitch_color="white")
fig, ax = plot_tracking_data(
game,
idx,
fig=fig,
ax=ax,
events=["pass"],
title="First pass after the kick-off",
add_velocities=True,
variable_of_interest=game.tracking_data.loc[idx, "frame"],
heatmap_overlay=x_grid,
overlay_cmap="coolwarm",
)
with the following traceback:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
3811 try:
-> 3812 return self._engine.get_loc(casted_key)
3813 except KeyError as err:
File pandas/_libs/index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas/_libs/hashtable_class_helper.pxi:7096, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'event_id'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[8], line 12
4 game.tracking_data.add_velocity(
5 column_ids=game.get_column_ids(),
6 filter_type="savitzky_golay",
7 max_velocity=13.0,
8 allow_overwrite=True
9 )
11 second_pass_id = game.event_data.loc[game.event_data["databallpy_event"]=="pass", "event_id"].iloc[1]
---> 12 idx = game.tracking_data[game.tracking_data["event_id"]==second_pass_id].index[0]
14 x_grid, _ = np.meshgrid(np.linspace(0, 1, 15), np.linspace(0, 1, 10))
16 fig, ax = plot_soccer_pitch(field_dimen=game.pitch_dimensions, pitch_color="white")
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/pandas/core/frame.py:4113, in DataFrame.__getitem__(self, key)
4111 if self.columns.nlevels > 1:
4112 return self._getitem_multilevel(key)
-> 4113 indexer = self.columns.get_loc(key)
4114 if is_integer(indexer):
4115 indexer = [indexer]
File /opt/miniconda3/envs/databallpy/lib/python3.10/site-packages/pandas/core/indexes/base.py:3819, in Index.get_loc(self, key)
3814 if isinstance(casted_key, slice) or (
3815 isinstance(casted_key, abc.Iterable)
3816 and any(isinstance(x, slice) for x in casted_key)
3817 ):
3818 raise InvalidIndexError(key)
-> 3819 raise KeyError(key) from err
3820 except TypeError:
3821 # If we have a listlike key, _check_indexing_error will raise
3822 # InvalidIndexError. Otherwise we fall through and re-raise
3823 # the TypeError.
3824 self._check_indexing_error(key)
KeyError: 'event_id'
In this page:
https://databallpy.readthedocs.io/en/latest/getting_started/visualizations_page.html
This line:
fails with this traceback:
I would have expected this to download an open game like it did with
provider="metrica"on this page: https://databallpy.readthedocs.io/en/latest/getting_started/loading_in_a_game_page.htmlAs a consequence, I could not continue this tutorial, because the game opened with
provider="metrica"fails:with the following traceback: