Skip to content

Handle scalar download targets as single paths - #160

Open
QianyeSu wants to merge 1 commit into
ecmwf:masterfrom
QianyeSu:fix/download-targets
Open

QianyeSu wants to merge 1 commit into
ecmwf:masterfrom
QianyeSu:fix/download-targets

Conversation

@QianyeSu

@QianyeSu QianyeSu commented Oct 5, 2026

Copy link
Copy Markdown

Related to #86.

cdsapi.api.Client.download(result, "download.nc") currently splits the filename into characters, passing only "d" to the result downloader. A bytes path is split into integers, and a pathlib.Path raises TypeError because it is not iterable.

Treat a single string, bytes or os.PathLike target as one path. Keep iterable targets copied before consumption and preserve existing list/tuple and default-filename behavior. Add a method docstring and offline regression tests, including file writes through mocked HTTP responses.

This change is scoped to cdsapi.api.Client. Modern token-based clients delegate to the separate ecmwf-datastores-client implementation, which is not modified here.

Validation on Python 3.14:

  • pytest -q tests/test_download.py: 25 passed.
  • Existing instantiation tests plus the new tests, using dummy credentials with HTTP requests blocked: 29 passed, 1 live retrieval test deselected.
  • Black, isort, flake8, compile checks and git diff --check: passed.

No real CDS credentials or data downloads were used.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants