Commit
·
1b55f5e
1
Parent(s):
3c4c67b
fix(phase-1): implement URL materialization and add requests dep
Browse files- pyproject.toml +3 -0
- src/stroke_deepisles_demo/data/staging.py +8 -3
- uv.lock +2 -0
pyproject.toml
CHANGED
|
@@ -33,6 +33,9 @@ dependencies = [
|
|
| 33 |
|
| 34 |
# UI (Gradio 5.x)
|
| 35 |
"gradio>=5.0.0",
|
|
|
|
|
|
|
|
|
|
| 36 |
]
|
| 37 |
|
| 38 |
[dependency-groups]
|
|
|
|
| 33 |
|
| 34 |
# UI (Gradio 5.x)
|
| 35 |
"gradio>=5.0.0",
|
| 36 |
+
|
| 37 |
+
# Networking
|
| 38 |
+
"requests>=2.0.0",
|
| 39 |
]
|
| 40 |
|
| 41 |
[dependency-groups]
|
src/stroke_deepisles_demo/data/staging.py
CHANGED
|
@@ -123,9 +123,14 @@ def _materialize_nifti(source: Path | str | bytes | Any, dest: Path) -> None:
|
|
| 123 |
shutil.copy2(source, dest)
|
| 124 |
elif isinstance(source, str):
|
| 125 |
if source.startswith(("http://", "https://")):
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
else:
|
| 130 |
# Assume local path string
|
| 131 |
src_path = Path(source)
|
|
|
|
| 123 |
shutil.copy2(source, dest)
|
| 124 |
elif isinstance(source, str):
|
| 125 |
if source.startswith(("http://", "https://")):
|
| 126 |
+
import requests
|
| 127 |
+
|
| 128 |
+
# Download the file
|
| 129 |
+
response = requests.get(source, stream=True, timeout=30)
|
| 130 |
+
response.raise_for_status()
|
| 131 |
+
with dest.open("wb") as f:
|
| 132 |
+
for chunk in response.iter_content(chunk_size=8192):
|
| 133 |
+
f.write(chunk)
|
| 134 |
else:
|
| 135 |
# Assume local path string
|
| 136 |
src_path = Path(source)
|
uv.lock
CHANGED
|
@@ -2134,6 +2134,7 @@ dependencies = [
|
|
| 2134 |
{ name = "numpy" },
|
| 2135 |
{ name = "pydantic" },
|
| 2136 |
{ name = "pydantic-settings" },
|
|
|
|
| 2137 |
]
|
| 2138 |
|
| 2139 |
[package.dev-dependencies]
|
|
@@ -2156,6 +2157,7 @@ requires-dist = [
|
|
| 2156 |
{ name = "numpy", specifier = ">=1.26.0" },
|
| 2157 |
{ name = "pydantic", specifier = ">=2.5.0" },
|
| 2158 |
{ name = "pydantic-settings", specifier = ">=2.1.0" },
|
|
|
|
| 2159 |
]
|
| 2160 |
|
| 2161 |
[package.metadata.requires-dev]
|
|
|
|
| 2134 |
{ name = "numpy" },
|
| 2135 |
{ name = "pydantic" },
|
| 2136 |
{ name = "pydantic-settings" },
|
| 2137 |
+
{ name = "requests" },
|
| 2138 |
]
|
| 2139 |
|
| 2140 |
[package.dev-dependencies]
|
|
|
|
| 2157 |
{ name = "numpy", specifier = ">=1.26.0" },
|
| 2158 |
{ name = "pydantic", specifier = ">=2.5.0" },
|
| 2159 |
{ name = "pydantic-settings", specifier = ">=2.1.0" },
|
| 2160 |
+
{ name = "requests", specifier = ">=2.0.0" },
|
| 2161 |
]
|
| 2162 |
|
| 2163 |
[package.metadata.requires-dev]
|