Repository: aeye-lab/pymovements
Pull request #305 (2023-03-27 18:55:24)

Dataset: Use DatasetDefinition in init
## Description

With this PR `Dataset` is now also initiliazed by a `DatasetDefinition`.

## Implemented changes

- [x] Use `definition` as initialization argument

## Type of change

- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change is or requires a documentation update

## How Has This Been Tested?

- [x] All tests have been adjusted as necessary
- [x] No new tests added

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have checked my code and corrected any misspellings


codecov-commenter: ## [Codecov](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) Report
Patch coverage: **`100.00`**% and no project coverage change.
> Comparison is base [(`948bb41`)](https://codecov.io/gh/aeye-lab/pymovements/commit/948bb41213f19f42a0ea65b8d219ccb52409daf5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) 100.00% compared to head [(`05726c0`)](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) 100.00%.

> :exclamation: Current head 05726c0 differs from pull request most recent head e6215c1. Consider uploading reports for the commit e6215c1 to get more accurate results

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main      #305   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           38        38           
  Lines         1534      1521   -13     
  Branches       348       344    -4     
=========================================
- Hits          1534      1521   -13     
```


| [Impacted Files](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) | Coverage Δ | |
|---|---|---|
| [src/pymovements/dataset/dataset.py](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab#diff-c3JjL3B5bW92ZW1lbnRzL2RhdGFzZXQvZGF0YXNldC5weQ==) | `100.00% <100.00%> (ø)` | |
| [src/pymovements/dataset/public\_dataset.py](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab#diff-c3JjL3B5bW92ZW1lbnRzL2RhdGFzZXQvcHVibGljX2RhdGFzZXQucHk=) | `100.00% <100.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab)

</details>

[:umbrella: View full report in Codecov by Sentry](https://codecov.io/gh/aeye-lab/pymovements/pull/305?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab).


Patch:
diff --git a/docs/source/tutorials/local-dataset.ipynb b/docs/source/tutorials/local-dataset.ipynb
index 7fbb180..346fb14 100644
--- a/docs/source/tutorials/local-dataset.ipynb
+++ b/docs/source/tutorials/local-dataset.ipynb
@@ -51,13 +51,13 @@
     "\n",
     "We will download the resources of this dataset the directory to simulate a local dataset for you.\n",
     "All downloaded archive files are automatically extracted and then removed.\n",
-    "The directory of the dataset will be `data/ToyDataset`.\n",
+    "The directory of the dataset will be `data/my_dataset`.\n",
     "\n",
     "After that we won't use the python class anymore and delete the object\n",
     "(the files on your system will stay in place).\n",
     "Don't worry if you're confused about these lines as they are not relevant to your use case.\n",
     "\n",
-    "Just keep in mind that we now have some files with gaze data in the directory `data/ToyDataset`."
+    "Just keep in mind that we now have some files with gaze data in the directory `data/my_dataset`."
    ]
   },
   {
@@ -67,7 +67,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "toy_dataset = pm.PublicDataset('ToyDataset', root='data/')\n",
+    "toy_dataset = pm.PublicDataset('ToyDataset', root='data/', dataset_dirname='my_dataset')\n",
     "toy_dataset.download(remove_finished=True)\n",
     "\n",
     "del toy_dataset"
@@ -161,7 +161,7 @@
    "id": "e039de9b",
    "metadata": {},
    "source": [
-    "The `column_map` dictionary maps the original column names in the CSV files to the desired column names. Here the original column names are 'timestamp', **'x'**, and **'y'**, and the desired column names are **'time'**, **'x_right_pix'**, and **'y_right_pix'**, respectively."
+    "The `column_map` dictionary maps the original column names in the CSV files to the desired column names. Here the original column names are 'timestamp', **'x'**, and **'y'**, and the desired column names are **'time'**, **'x_pix'**, and **'y_pix'**, respectively."
    ]
   },
   {
@@ -173,8 +173,8 @@
    "source": [
     "column_map = {\n",
     "    'timestamp': 'time',\n",
-    "    'x': 'x_right_pix',\n",
-    "    'y': 'y_right_pix',\n",
+    "    'x': 'x_pix',\n",
+    "    'y': 'y_pix',\n",
     "}"
    ]
   },
@@ -183,7 +183,7 @@
    "id": "a1f91fdd",
    "metadata": {},
    "source": [
-    "Here, we specify that the separator in the CSV files is a tab (**'\\t'**), and we provide the list of original column names and desired column names as the **'columns'** and **'new_columns'** parameters, respectively."
+    "Here, we specify that the separator in the CSV files is a tab (**'\\t'**)."
    ]
   },
   {
@@ -193,10 +193,8 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "read_csv_kwargs = {\n",
+    "custom_read_kwargs = {\n",
     "    'sep': '\\t',\n",
-    "    'columns': list(column_map.keys()),\n",
-    "    'new_columns': list(column_map.values()),\n",
     "}"
    ]
   },
@@ -208,12 +206,37 @@
     "## Define and load the Dataset"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "37c70a20",
+   "metadata": {},
+   "source": [
+    "Next we use all these definitions and create a `DatasetDefinition` by passing in the root directory, Experiment instance, and other optional parameters such as the filename regular expression and custom CSV reading parameters."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "1aa28e15",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "dataset_definition = pm.DatasetDefinition(\n",
+    "    name='my_dataset',\n",
+    "    experiment=experiment,\n",
+    "    filename_regex=filename_regex,\n",
+    "    filename_regex_dtypes=filename_regex_dtypes,\n",
+    "    column_map=column_map,\n",
+    "    custom_read_kwargs=custom_read_kwargs,\n",
+    ")"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "190ce9f6",
    "metadata": {},
    "source": [
-    "Finaly we create a **Dataset** instance by passing in the root directory, Experiment instance, and other optional parameters such as the filename regular expression and custom CSV reading parameters. The `dataset_dirname`, `raw_dirname`, `preprocessed_dirname`, and `events_dirname` parameters define the names of the directories for the dataset, raw data, preprocessed data, and events data, respectively."
+    "Finally we create a `Dataset` instance by using the `DatasetDefinition`. The `dataset_dirname`, `raw_dirname`, `preprocessed_dirname`, and `events_dirname` parameters define the names of the directories for the dataset, raw data, preprocessed data, and events data, respectively."
    ]
   },
   {
@@ -224,15 +247,12 @@
    "outputs": [],
    "source": [
     "# Define the path to the dataset directory\n",
-    "dataset_dir = './data/ToyDataset/'\n",
+    "dataset_dir = 'data/my_dataset/'\n",
     "\n",
     "# Set up the Dataset object\n",
     "dataset = pm.Dataset(\n",
+    "    definition=dataset_definition,\n",
     "    root=dataset_dir,\n",
-    "    experiment=experiment,\n",
-    "    filename_regex=filename_regex,\n",
-    "    filename_regex_dtypes=filename_regex_dtypes,\n",
-    "    custom_read_kwargs=read_csv_kwargs,\n",
     "    dataset_dirname='.',\n",
     "    raw_dirname='raw',\n",
     "    preprocessed_dirname='preprocessed',\n",
@@ -268,7 +288,7 @@
    "id": "6b805c88-20b5-4e5b-8532-030bbd30d051",
    "metadata": {},
    "source": [
-    "# Use the Dataset"
+    "## Use the Dataset"
    ]
   },
   {
diff --git a/src/pymovements/dataset/dataset.py b/src/pymovements/dataset/dataset.py
index 860959c..c01d440 100644
--- a/src/pymovements/dataset/dataset.py
+++ b/src/pymovements/dataset/dataset.py
@@ -27,27 +27,24 @@ from typing import Any
 import polars as pl
 from tqdm.auto import tqdm
 
+from pymovements.dataset.dataset_definition import DatasetDefinition
+from pymovements.dataset.dataset_library import DatasetLibrary
 from pymovements.events.event_processing import EventGazeProcessor
 from pymovements.events.events import EventDataFrame
 from pymovements.events.events import EventDetectionCallable
 from pymovements.gaze import GazeDataFrame
-from pymovements.gaze.experiment import Experiment
 from pymovements.utils.paths import match_filepaths
 
 
 class Dataset:
     """Dataset base class."""
-    # pylint: disable=too-many-instance-attributes
-    # The Dataset class is exceptionally complex and needs many attributes.
 
     def __init__(
             self,
+            definition: str | DatasetDefinition | type[DatasetDefinition] = DatasetDefinition,
+            *,
             root: str | Path,
-            experiment: Experiment | None = None,
-            filename_regex: str = '.*',
-            filename_regex_dtypes: dict[str, type] | None = None,
-            custom_read_kwargs: dict[str, Any] | None = None,
-            dataset_dirname: str = '.',
+            dataset_dirname: str | None = '.',
             raw_dirname: str = 'raw',
             preprocessed_dirname: str = 'preprocessed',
             events_dirname: str = 'events',
@@ -62,18 +59,10 @@ class Dataset:
 
         Parameters
         ----------
+        definition : str, DatasetDefinition
+            Dataset definition to initialize dataset with.
         root : str, Path
             Path to the root directory of the dataset.
-        experiment : Experiment
-            The experiment definition.
-        filename_regex : str
-            Regular expression which needs to be matched before trying to load the file. Named
-            groups will appear in the `fileinfo` dataframe.
-        filename_regex_dtypes : dict[str, type], optional
-            If named groups are present in the `filename_regex`, this makes it possible to cast
-            specific named groups to a particular datatype.
-        custom_read_kwargs : dict[str, Any], optional
-            If specified, these keyword arguments will be passed to the file reading function.
         dataset_dirname : str, optional
             Dataset directory name under root path. Can be `.` if dataset is located in root path.
             Default: `.`
@@ -93,28 +82,23 @@ class Dataset:
         self.gaze: list[GazeDataFrame] = []
         self.events: list[EventDataFrame] = []
 
+        if isinstance(definition, str):
+            definition = DatasetLibrary.get(definition)()
+
+        if isinstance(definition, type):
+            definition = definition()
+
+        if dataset_dirname is None:
+            dataset_dirname = definition.name
+
+        self.definition = definition
+
         self._root = Path(root)
         self.dataset_dirname = dataset_dirname
         self.raw_dirname = raw_dirname
         self.preprocessed_dirname = preprocessed_dirname
         self.events_dirname = events_dirname
 
-        self.experiment = experiment
-
-        if filename_regex is None:
-            raise ValueError('filename_regex must not be None')
-        if not isinstance(filename_regex, str):
-            raise TypeError('filename_regex must be of type str')
-        self._filename_regex = filename_regex
-
-        if filename_regex_dtypes is None:
-            filename_regex_dtypes = {}
-        self._filename_regex_dtypes = filename_regex_dtypes
-
-        if custom_read_kwargs is None:
-            custom_read_kwargs = {}
-        self._custom_read_kwargs = custom_read_kwargs
-
     def load(
             self,
             events: bool = False,
@@ -191,7 +175,7 @@ class Dataset:
         # Get all filepaths that match regular expression.
         fileinfo_dicts = match_filepaths(
             path=self.raw_rootpath,
-            regex=re.compile(self._filename_regex),
+            regex=re.compile(self.definition.filename_regex),
             relative=True,
         )
 
@@ -204,7 +188,7 @@ class Dataset:
 
         fileinfo_df = fileinfo_df.with_columns([
             pl.col(fileinfo_key).cast(fileinfo_dtype)
-            for fileinfo_key, fileinfo_dtype in self._filename_regex_dtypes.items()
+            for fileinfo_key, fileinfo_dtype in self.definition.filename_regex_dtypes.items()
         ])
 
         return fileinfo_df
@@ -326,7 +310,7 @@ class Dataset:
                 if preprocessed:
                     gaze_df = pl.read_csv(filepath)
                 else:
-                    gaze_df = pl.read_csv(filepath, **self._custom_read_kwargs)
+                    gaze_df = pl.read_csv(filepath, **self.definition.custom_read_kwargs)
             elif filepath.suffix == '.feather':
                 gaze_df = pl.read_ipc(filepath)
             else:
@@ -335,7 +319,7 @@ class Dataset:
             # Add fileinfo columns to dataframe.
             gaze_df = self._add_fileinfo(gaze_df, fileinfo)
 
-            gaze_dfs.append(GazeDataFrame(gaze_df, experiment=self.experiment))
+            gaze_dfs.append(GazeDataFrame(gaze_df, experiment=self.definition.experiment))
 
         return gaze_dfs
 
@@ -1033,6 +1017,6 @@ class Dataset:
         # Cast columns from fileinfo according to specification.
         df = df.with_columns([
             pl.col(fileinfo_key).cast(fileinfo_dtype)
-            for fileinfo_key, fileinfo_dtype in self._filename_regex_dtypes.items()
+            for fileinfo_key, fileinfo_dtype in self.definition.filename_regex_dtypes.items()
         ])
         return df
diff --git a/src/pymovements/dataset/dataset_definition.py b/src/pymovements/dataset/dataset_definition.py
index 6b87899..4bb510f 100644
--- a/src/pymovements/dataset/dataset_definition.py
+++ b/src/pymovements/dataset/dataset_definition.py
@@ -62,7 +62,7 @@ class DatasetDefinition:
     custom_read_kwargs : dict[str, Any], optional
         If specified, these keyword arguments will be passed to the file reading function.
     """
-    name: str = field(init=False)
+    name: str = '.'
 
     mirrors: tuple[str, ...] = field(default_factory=tuple)
 
@@ -79,8 +79,6 @@ class DatasetDefinition:
     column_map: dict[str, str] = field(default_factory=dict)
 
     def __post_init__(self):
-        self.name = self.__class__.__name__
-
         if len(self.column_map) > 0:
             self.custom_read_kwargs['columns'] = list(self.column_map.keys())
             self.custom_read_kwargs['new_columns'] = list(self.column_map.values())
diff --git a/src/pymovements/dataset/public_dataset.py b/src/pymovements/dataset/public_dataset.py
index da5e844..27298d4 100644
--- a/src/pymovements/dataset/public_dataset.py
+++ b/src/pymovements/dataset/public_dataset.py
@@ -26,7 +26,6 @@ from urllib.error import URLError
 
 from pymovements.dataset.dataset import Dataset
 from pymovements.dataset.dataset_definition import DatasetDefinition
-from pymovements.dataset.dataset_library import DatasetLibrary
 from pymovements.utils.archives import extract_archive
 from pymovements.utils.downloads import download_file
 
@@ -61,6 +60,8 @@ class PublicDataset(Dataset, metaclass=ABCMeta):
 
         Parameters
         ----------
+        definition : str, DatasetDefinition
+            Dataset definition to initialize dataset with.
         root : str, Path
             Path to the root directory of the dataset.
         dataset_dirname : str, optional
@@ -80,28 +81,14 @@ class PublicDataset(Dataset, metaclass=ABCMeta):
             Name of directory under dataset path that will be used to store event data. We advise
             the user to keep the event data separate from the original raw data. Default: `events`
         """
-        if isinstance(definition, str):
-            definition = DatasetLibrary.get(definition)()
-
-        if isinstance(definition, type):
-            definition = definition()
-
-        if dataset_dirname is None:
-            dataset_dirname = definition.name
-
         super().__init__(
+            definition=definition,
             root=root,
-            experiment=definition.experiment,
-            filename_regex=definition.filename_regex,
-            filename_regex_dtypes=definition.filename_regex_dtypes,
-            custom_read_kwargs=definition.custom_read_kwargs,
             dataset_dirname=dataset_dirname,
             raw_dirname=raw_dirname,
             preprocessed_dirname=preprocessed_dirname,
             events_dirname=events_dirname,
         )
-        self.mirrors = definition.mirrors
-        self.resources = definition.resources
         self.downloads_dirname = downloads_dirname
 
     def download(self, *, extract: bool = True, remove_finished: bool = False) -> Dataset:
@@ -137,18 +124,18 @@ class PublicDataset(Dataset, metaclass=ABCMeta):
         PublicDataset
             Returns self, useful for method cascading.
         """
-        if len(self.mirrors) == 0:
+        if len(self.definition.mirrors) == 0:
             raise AttributeError('number of mirrors must not be zero to download dataset')
 
-        if len(self.resources) == 0:
+        if len(self.definition.resources) == 0:
             raise AttributeError('number of resources must not be zero to download dataset')
 
         self.raw_rootpath.mkdir(parents=True, exist_ok=True)
 
-        for resource in self.resources:
+        for resource in self.definition.resources:
             success = False
 
-            for mirror in self.mirrors:
+            for mirror in self.definition.mirrors:
 
                 url = f'{mirror}{resource["resource"]}'
 
@@ -195,7 +182,7 @@ class PublicDataset(Dataset, metaclass=ABCMeta):
         """
         self.raw_rootpath.mkdir(parents=True, exist_ok=True)
 
-        for resource in self.resources:
+        for resource in self.definition.resources:
             extract_archive(
                 source_path=self.downloads_rootpath / resource['filename'],
                 destination_path=self.raw_rootpath,


Test patch:
diff --git a/tests/dataset/dataset_test.py b/tests/dataset/dataset_test.py
index 9e7db2f..3edec36 100644
--- a/tests/dataset/dataset_test.py
+++ b/tests/dataset/dataset_test.py
@@ -30,6 +30,7 @@ from polars.testing import assert_frame_equal
 
 from pymovements import exceptions
 from pymovements.dataset.dataset import Dataset
+from pymovements.dataset.dataset_definition import DatasetDefinition
 from pymovements.events.detection.engbert import microsaccades
 from pymovements.events.detection.ivt import ivt
 from pymovements.events.events import EventDataFrame
@@ -225,20 +226,24 @@ def mock_toy(rootpath, raw_fileformat, eyes):
 
     create_event_files_from_fileinfo(event_dfs, fileinfo, rootpath / 'events')
 
+    dataset_definition = DatasetDefinition(
+        experiment=Experiment(
+            screen_width_px=1280,
+            screen_height_px=1024,
+            screen_width_cm=38,
+            screen_height_cm=30.2,
+            distance_cm=68,
+            origin='lower left',
+            sampling_rate=1000,
+        ),
+        filename_regex=r'(?P<subject_id>\d+).' + raw_fileformat,
+        filename_regex_dtypes={'subject_id': pl.Int64},
+    )
+
     return {
         'init_kwargs': {
+            'definition': dataset_definition,
             'root': rootpath,
-            'experiment': Experiment(
-                screen_width_px=1280,
-                screen_height_px=1024,
-                screen_width_cm=38,
-                screen_height_cm=30.2,
-                distance_cm=68,
-                origin='lower left',
-                sampling_rate=1000,
-            ),
-            'filename_regex': r'(?P<subject_id>\d+).' + raw_fileformat,
-            'filename_regex_dtypes': {'subject_id': pl.Int64},
         },
         'fileinfo': fileinfo,
         'raw_gaze_dfs': gaze_dfs,
@@ -328,26 +333,6 @@ def test_load_subset(subset, fileinfo_idx, dataset_configuration):
     assert_frame_equal(dataset.fileinfo, expected_fileinfo)
 
 
-@pytest.mark.parametrize(
-    'init_kwargs, exception',
-    [
-        pytest.param(
-            {'root': 'data', 'filename_regex': None},
-            ValueError,
-            id='filename_regex_none_value',
-        ),
-        pytest.param(
-            {'root': 'data', 'filename_regex': 1},
-            TypeError,
-            id='filename_regex_wrong_type',
-        ),
-    ],
-)
-def test_init_exceptions(init_kwargs, exception):
-    with pytest.raises(exception):
-        Dataset(**init_kwargs)
-
-
 @pytest.mark.parametrize(
     'init_kwargs, load_kwargs, exception',
     [
@@ -718,7 +703,7 @@ def test_detect_events_attribute_error(dataset_configuration):
     ],
 )
 def test_clear_events(events_init, events_expected):
-    dataset = Dataset(root='data')
+    dataset = Dataset('ToyDataset', root='data')
     dataset.events = events_init
     dataset.clear_events()
 
@@ -1067,7 +1052,7 @@ def test_save_files_have_correct_extension(
     ],
 )
 def test_paths(init_kwargs, expected_paths):
-    dataset = Dataset(**init_kwargs)
+    dataset = Dataset('ToyDataset', **init_kwargs)
 
     assert dataset.root == expected_paths['root']
     assert dataset.path == expected_paths['path']
@@ -1084,7 +1069,7 @@ def test_paths(init_kwargs, expected_paths):
     ],
 )
 def test_check_fileinfo(new_fileinfo, exception):
-    dataset = Dataset('data')
+    dataset = Dataset('ToyDataset', root='data')
 
     dataset.fileinfo = new_fileinfo
 
@@ -1100,7 +1085,7 @@ def test_check_fileinfo(new_fileinfo, exception):
     ],
 )
 def test_check_gaze_dataframe(new_gaze, exception):
-    dataset = Dataset('data')
+    dataset = Dataset('ToyDataset', root='data')
 
     dataset.gaze = new_gaze
 
@@ -1110,7 +1095,7 @@ def test_check_gaze_dataframe(new_gaze, exception):
 
 @pytest.mark.parametrize('dataset_configuration', ['ToyBino'], indirect=['dataset_configuration'])
 def test_check_experiment(dataset_configuration):
-    dataset_configuration['init_kwargs'].pop('experiment')
+    dataset_configuration['init_kwargs']['definition'].experiment = None
     dataset = Dataset(**dataset_configuration['init_kwargs'])
     dataset.load()
 
diff --git a/tests/dataset/public_dataset_test.py b/tests/dataset/public_dataset_test.py
index 59071c4..2e7f43e 100644
--- a/tests/dataset/public_dataset_test.py
+++ b/tests/dataset/public_dataset_test.py
@@ -291,9 +291,9 @@ def test_dataset_download_no_resources_raises_exception(tmp_path):
 def test_public_dataset_registered_correct_attributes(tmp_path, dataset_definition):
     dataset = PublicDataset('CustomPublicDataset', root=tmp_path)
 
-    assert dataset.mirrors == dataset_definition.mirrors
-    assert dataset.resources == dataset_definition.resources
-    assert dataset.experiment == dataset_definition.experiment
-    assert dataset._filename_regex == dataset_definition.filename_regex
-    assert dataset._filename_regex_dtypes == dataset_definition.filename_regex_dtypes
-    assert dataset._custom_read_kwargs == dataset_definition.custom_read_kwargs
+    assert dataset.definition.mirrors == dataset_definition.mirrors
+    assert dataset.definition.resources == dataset_definition.resources
+    assert dataset.definition.experiment == dataset_definition.experiment
+    assert dataset.definition.filename_regex == dataset_definition.filename_regex
+    assert dataset.definition.filename_regex_dtypes == dataset_definition.filename_regex_dtypes
+    assert dataset.definition.custom_read_kwargs == dataset_definition.custom_read_kwargs