Skip to content

dataset list always returns [] (load_dataset returns a dict, not a model) #11

Description

@roll

dataset list always returns an empty list because load_dataset returns a dict.

Environment

  • fairspec 0.1.4 (installed from PyPI)
  • Python 3.12.3, Linux
  • Reproduced in a clean virtualenv against the published wheel.

Repro

cat > dataset.json <<'JSON'
{ "resources": [ { "name": "products", "data": "products.csv" } ] }
JSON
fairspec dataset validate dataset.json --json   # {"valid": true, "errors": []}
fairspec dataset list dataset.json --json        # []   <-- expected ["products"]

Root cause
commands/dataset/list_.py does:

dataset = load_dataset(path)
resource_names = [
    resource.name or infer_resource_name(resource)
    for resource in getattr(dataset, "resources", None) or []
]

but load_dataset() returns a plain dict, so getattr(dict_obj, "resources", None) is always None → the comprehension iterates over [].

from fairspec import load_dataset
ds = load_dataset("dataset.json")
print(type(ds).__name__)            # dict
print(getattr(ds, "resources", None))  # None

The dataset script docs (docs/terminal/dataset.md) also show dataset.resources[0].name, which would fail for the same dict-vs-model reason.

Expected: dataset list returns the resource names (e.g. ["products"]).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions