Skip to content

Commit 06f63ec

Browse files
authored
Merge pull request #712 from bioimage-io/dev
pre release fixes for 0.5.5.0
2 parents ec030a2 + 28afcee commit 06f63ec

File tree

10 files changed

+39
-34
lines changed

10 files changed

+39
-34
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/ambv/black
3-
rev: 24.2.0
3+
rev: 25.1.0
44
hooks:
55
- id: black
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.3.2
7+
rev: v0.12.8
88
hooks:
9-
- id: ruff
9+
- id: ruff-check
1010
args: [--fix, --show-fixes]
1111
- repo: local
1212
hooks:

bioimageio/spec/_internal/io.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -705,23 +705,19 @@ def _open_url(
705705
or hashlib.sha256(str(source).encode(encoding="utf-8")).hexdigest()
706706
)
707707

708-
try:
709-
reader = cache.fetch(
710-
source,
711-
fetcher=partial(_fetch_url, progressbar=progressbar),
712-
force_refetch=digest,
713-
)
714-
except Exception as e:
715-
raise ValueError(f"Failed to fetch {source}.") from e
716-
else:
717-
return BytesReader(
718-
reader,
719-
suffix=source_path.suffix,
720-
sha256=sha,
721-
original_file_name=source_path.name,
722-
original_root=source.parent,
723-
is_zipfile=None,
724-
)
708+
reader = cache.fetch(
709+
source,
710+
fetcher=partial(_fetch_url, progressbar=progressbar),
711+
force_refetch=digest,
712+
)
713+
return BytesReader(
714+
reader,
715+
suffix=source_path.suffix,
716+
sha256=sha,
717+
original_file_name=source_path.name,
718+
original_root=source.parent,
719+
is_zipfile=None,
720+
)
725721

726722

727723
def _fetch_url(

bioimageio/spec/_internal/io_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def open_bioimageio_yaml(
167167
)
168168

169169
try:
170-
r = httpx.get(url)
170+
r = httpx.get(url, follow_redirects=True)
171171
_ = r.raise_for_status()
172172
unparsed_content = r.content.decode(encoding="utf-8")
173173
content = _sanitize_bioimageio_yaml(read_yaml(unparsed_content))
@@ -232,7 +232,7 @@ def _get_id_map_impl(url: str) -> Dict[str, LightHttpFileDescr]:
232232
if not isinstance(url, str) or "/" not in url:
233233
logger.opt(depth=1).error("invalid id map url: {}", url)
234234
try:
235-
id_map_raw: Any = httpx.get(url, timeout=10).json()
235+
id_map_raw: Any = httpx.get(url, timeout=10, follow_redirects=True).json()
236236
except Exception as e:
237237
logger.opt(depth=1).error("failed to get {}: {}", url, e)
238238
return {}

bioimageio/spec/_internal/url.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,17 @@ def _validate_url_impl(
5858
try:
5959
if request_mode in ("head", "get"):
6060
request_ctxt = nullcontext(
61-
httpx.request(request_mode.upper(), val_url, timeout=timeout)
61+
httpx.request(
62+
request_mode.upper(),
63+
val_url,
64+
timeout=timeout,
65+
follow_redirects=True,
66+
)
6267
)
6368
elif request_mode == "get_stream":
64-
request_ctxt = httpx.stream("GET", val_url, timeout=timeout)
69+
request_ctxt = httpx.stream(
70+
"GET", val_url, timeout=timeout, follow_redirects=True
71+
)
6572
else:
6673
assert_never(request_mode)
6774

bioimageio/spec/_upload.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def upload(
124124
"file_path": file_name,
125125
},
126126
headers=headers,
127+
follow_redirects=True,
127128
)
128129
upload_url = response.raise_for_status().json()
129130

@@ -140,6 +141,7 @@ def upload(
140141
files=files, # pyright: ignore[reportArgumentType]
141142
# TODO: follow up on https://github.com/encode/httpx/discussions/3611
142143
headers={"Content-Type": ""}, # Important for S3 uploads
144+
follow_redirects=True,
143145
)
144146
logger.info("Uploaded '{}' successfully", file_name)
145147

@@ -153,6 +155,7 @@ def upload(
153155
"manifest": manifest,
154156
},
155157
headers=headers,
158+
follow_redirects=True,
156159
)
157160
logger.info(
158161
"Updated status of {}/{} to 'request-review'", artifact_id, artifact_version

changelog.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ This changelog includes implementation details and my reference the [changes to
1212

1313
#### bioimageio.spec 0.5.5.0
1414

15-
note: Not yet released
16-
1715
- added programmatic `uplaod` (alpha stage)
1816
- [generic format 0.3.2 and model format 0.5.5](#generic-032-and-model-055)
1917

@@ -304,8 +302,6 @@ If the changes also apply to `type` model, the coresponding model format version
304302

305303
#### generic 0.3.2 and model 0.5.5
306304

307-
note: not yet released
308-
309305
- Non-breaking changes:
310306
- New optional `version_comment` field
311307
- Many FAIR fields are optional now to make it easier to tinker with resources not ready for publishing yet.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.black]
22
line-length = 88
3-
target-version = ["py38", "py39", "py310", "py311", "py312"]
3+
target-version = ["py38", "py39", "py310", "py311", "py312", "py313"]
44
preview = true
55

66
[tool.pyright]
@@ -14,7 +14,7 @@ exclude = [
1414
]
1515
include = ["bioimageio", "scripts", "tests"]
1616
pythonPlatform = "All"
17-
pythonVersion = "3.12"
17+
pythonVersion = "3.8"
1818
reportDuplicateImport = "error"
1919
reportImplicitStringConcatenation = "error"
2020
reportImportCycles = true
@@ -48,7 +48,7 @@ testpaths = ["bioimageio/spec", "tests"]
4848

4949
[tool.ruff]
5050
line-length = 88
51-
target-version = "py312"
51+
target-version = "py38"
5252
exclude = [
5353
"bioimageio_cache",
5454
"scripts/pdoc/original.py",

scripts/update_spdx_licenses_zenodo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main(recheck: bool = False):
3232
"https://zenodo.org/api/vocabularies/licenses/"
3333
+ lic["licenseId"].lower()
3434
)
35-
r = httpx.get(url, timeout=5)
35+
r = httpx.get(url, timeout=5, follow_redirects=True)
3636

3737
if 200 <= r.status_code < 300:
3838
known = True

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
install_requires=[
3232
"annotated-types>=0.5.0,<1",
3333
"email_validator",
34-
"genericache==0.4.1",
34+
"genericache==0.5.2",
3535
"imageio",
3636
"loguru",
3737
"markdown",
@@ -47,6 +47,7 @@
4747
"tifffile>=2020.7.4",
4848
"tqdm",
4949
"typing-extensions",
50+
"exceptiongroup", # TODO: remove when py3.11 is lowest supported version
5051
"zipp",
5152
],
5253
extras_require={

tests/test_internal/test_io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,5 +255,7 @@ def test_open_url_with_wrong_sha():
255255
url = "https://example.com/file.txt"
256256
sha = Sha256("0" * 64) # invalid sha256 for testing
257257

258-
with pytest.raises(ValueError, match=f"Failed to fetch {url}."):
258+
with pytest.raises(
259+
httpx.HTTPStatusError, match=f"Client error '404 Not Found' for url '{url}'"
260+
):
259261
_ = _open_url(HttpUrl(url), sha256=sha)

0 commit comments

Comments
 (0)