Skip to content

fix: DatasetList.get_ids() AttributeError when delayed=True#174

Open
Shreyaav18 wants to merge 3 commits intoioos:mainfrom
Shreyaav18:fix/dataset-list-delayed-attribute-error
Open

fix: DatasetList.get_ids() AttributeError when delayed=True#174
Shreyaav18 wants to merge 3 commits intoioos:mainfrom
Shreyaav18:fix/dataset-list-delayed-attribute-error

Conversation

@Shreyaav18
Copy link
Copy Markdown

Fixes #173

Two small changes to DatasetList in gliderpy/fetchers.py:

  1. Initialize self.dataset_ids = None in __init__ for consistency with GliderDataFetcher
  2. Fix get_ids() so self.dataset_ids is correctly assigned for both delayed=True and delayed=False

Problem

self.dataset_ids was only assigned inside the if not self.delayed: block. When delayed=True, this block was skipped but the method still attempted to return self.dataset_ids, which was never set, causing:

AttributeError: 'DatasetList' object has no attribute 'dataset_ids'

Changes

__init__: Added explicit initialization:

self.dataset_ids: OptionalList = None

get_ids(): Moved assignment outside the conditional block.

if not self.delayed:
    dataset_ids = [
        dataset_id
        for dataset_id in dataset_ids
        if not dataset_id.endswith("-delayed")
    ]
self.dataset_ids = dataset_ids
return self.dataset_ids

Testing

All 8 existing tests pass. DatasetList currently has no test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatasetList.get_ids() raises AttributeError when delayed=True

1 participant