Skip to content

.download_version_to_local() doesn't work if version is specified? #115

Description

@kokbent

Describe the bug
As title, when you try to download a dataset to local, not specifying version_spec is fine, once you specify it it would throw InvalidSpecifier error. In addition, because the CLI command automatically sets version_spec, it would therefore fail regardless.

To Reproduce
In Python

from cfa.dataops import datacat

dc = datacat.public.stf.nssp_gold_v1
dc.load.download_version_to_local("./data")
# Using version: 2026-07-09
# True
dc.load.download_version_to_local("./data", version_spec="2026-07-09")
# InvalidSpecifier: Invalid specifier: '2026.07.09'
# Cell In[36], line 1
# ----> 1 dc.load.download_version_to_local("./data", version_spec="2026-07-09")
# Show Traceback

In shell

❯ uv run dataops_save "public.stf.nssp_gold_v1" "./data"
Traceback (most recent call last):
  File "/home/tjk3/projects/tmp/.venv/bin/dataops_save", line 10, in <module>
    sys.exit(save_data_locally())
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/cfa/dataops/command.py", line 159, in save_data_locally
    written = eval(
  File "<string>", line 1, in <module>
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/cfa/dataops/catalog.py", line 396, in download_version_to_local
    blobs = self._get_version_blobs(version_spec=version_spec, selection=selection)
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/cfa/dataops/catalog.py", line 336, in _get_version_blobs
    version = version_matcher(
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/cfa/dataops/utils.py", line 228, in version_matcher
    specset = SpecifierSet(normalize(version_spec))
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/packaging/specifiers.py", line 1389, in __init__
    self._specs: tuple[Specifier, ...] = tuple(map(Specifier, split_specifiers))
  File "/home/tjk3/projects/tmp/.venv/lib/python3.10/site-packages/packaging/specifiers.py", line 587, in __init__
    raise InvalidSpecifier(f"Invalid specifier: {spec!r}")
packaging.specifiers.InvalidSpecifier: Invalid specifier: '2026.07.09'

Additional context
Seems like typing version_spec as SpecifierSet causes this issue, which expects version_spec to be, for e.g., ==2026-07-09 (which actually works). But I'm not sure that's a good way to expect user to specify their version using == etc. Also command.save_data_locally() would use 2026-07-09 instead of ==2026-07-09, thus causing this issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions