Skip to content

Commit

Permalink
Fix nimbus URL joining (#1997)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Fixed an issue that was causing URLs to include a `//` between the
repository and branch fields.

### Does this PR introduce a breaking change?

No.

### Other information:

While this was working fine for returning files already available on
disk, when `nimbus` was fetching files remotely when launched from a
Jupyter notebook, this was failing.

Related: Ouranosinc/xscen#492
  • Loading branch information
Zeitsperre authored Nov 15, 2024
1 parent e928777 commit fe4066e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Breaking changes
Bug fixes
^^^^^^^^^
* Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`).
* Fixed an issue with ``nimbus`` that was causing URL path components to be improperly joined. (:pull:`1997`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
12 changes: 9 additions & 3 deletions xclim/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ def load_registry(
dict
Dictionary of filenames and hashes.
"""
remote_registry = audit_url(f"{repo}/{branch}/data/registry.txt")
remote_registry = audit_url(
urljoin(
urljoin(repo, branch if branch.endswith("/") else f"{branch}/"),
"data/registry.txt",
)
)

if branch != default_testdata_version:
custom_registry_folder = Path(
Expand Down Expand Up @@ -511,8 +516,9 @@ def nimbus( # noqa: PR01
"The `pooch` package is required to fetch the xclim testing data. "
"You can install it with `pip install pooch` or `pip install xclim[dev]`."
)

remote = audit_url(f"{repo}/{branch}/data")
remote = audit_url(
urljoin(urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), "data")
)
return pooch.create(
path=cache_dir,
base_url=remote,
Expand Down

0 comments on commit fe4066e

Please sign in to comment.