Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove datasets.yaml #1053

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
25 changes: 14 additions & 11 deletions src/pymovements/dataset/dataset_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
from pathlib import Path
from typing import TypeVar

import yaml

from pymovements import datasets
from pymovements.dataset.dataset_definition import DatasetDefinition

Expand Down Expand Up @@ -127,17 +125,22 @@ def register_dataset(cls: DatasetDefinitionClass) -> DatasetDefinitionClass:


def _add_shipped_datasets() -> None:
"""Add available public datasets via `src/pymovements/datasets/datasets.yaml`."""
"""Add available public datasets via yaml files in `src/pymovements/datasets`."""
dataset_definition_files = resources.files(datasets)

datasets_list_yaml = dataset_definition_files / 'datasets.yaml'
# https://github.com/aeye-lab/pymovements/pull/952#issuecomment-2690742187
assert isinstance(datasets_list_yaml, Path)
with open(datasets_list_yaml, encoding='utf-8') as f:
datasets_list = yaml.safe_load(f)

for definition_basename in datasets_list:
yaml_file_name = dataset_definition_files / f'{definition_basename}.yaml'
for filename in dataset_definition_files.iterdir():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work if users have installed pymovements as a zipped wheel. Depending on their distribution, they may not have any other option.

We already discussed this here: #914 (comment)

# mypy... don't know how to make it smarter currently (type is Traversable)
assert isinstance(filename, Path)
dataset_path = Path(filename)
if (
dataset_path.name == 'datasets.yaml' or
dataset_path.suffix == '.py' or
dataset_path.is_dir()
):
continue
# https://github.com/aeye-lab/pymovements/pull/952#issuecomment-2690742187
assert isinstance(dataset_definition_files, Path)
yaml_file_name = dataset_definition_files / filename
# https://github.com/aeye-lab/pymovements/pull/952#issuecomment-2690742187
assert isinstance(yaml_file_name, Path)
DatasetLibrary.add(yaml_file_name)
Expand Down
21 changes: 0 additions & 21 deletions src/pymovements/datasets/datasets.yaml

This file was deleted.

Loading