|
2 | 2 | from collections.abc import ItemsView, Iterable, Iterator, KeysView, ValuesView
|
3 | 3 | from pathlib import PosixPath
|
4 | 4 | from typing import Any, Callable, NewType, Tuple, TypedDict, cast
|
5 |
| -from urllib.parse import urlparse, urlunparse |
6 | 5 |
|
7 | 6 | import numpy as np
|
8 | 7 |
|
|
24 | 23 | "cos://",
|
25 | 24 | "minio://",
|
26 | 25 | "file:///",
|
| 26 | + "http://", |
| 27 | + "https://", |
27 | 28 | }
|
28 | 29 |
|
29 | 30 |
|
@@ -68,39 +69,13 @@ def validate_and_normalize_path_to_uri(path: str, fs_root: str | None = None) ->
|
68 | 69 | if path == "":
|
69 | 70 | # (empty paths are allowed through as they represent missing chunks)
|
70 | 71 | return path
|
71 |
| - |
72 |
| - # TODO ideally we would just use cloudpathlib.AnyPath to handle all types of paths but that would require extra dependencies, see https://github.com/drivendataorg/cloudpathlib/issues/489#issuecomment-2504725280 |
73 |
| - |
74 |
| - if path.startswith("http://") or path.startswith("https://"): |
75 |
| - # hopefully would raise if given a malformed URL |
76 |
| - components = urlparse(path) |
77 |
| - |
78 |
| - if not PosixPath(components.path).suffix: |
79 |
| - raise ValueError( |
80 |
| - f"entries in the manifest must be paths to files, but this path has no file suffix: {path}" |
81 |
| - ) |
82 |
| - |
83 |
| - return urlunparse(components) |
84 |
| - |
85 | 72 | elif any(path.startswith(prefix) for prefix in VALID_URI_PREFIXES):
|
86 |
| - # Question: This feels fragile, is there a better way to ID a Zarr |
87 |
| - if not PosixPath(path).suffix and "zarr" not in path: |
88 |
| - raise ValueError( |
89 |
| - f"entries in the manifest must be paths to files, but this path has no file suffix: {path}" |
90 |
| - ) |
91 |
| - |
92 | 73 | return path # path is already in URI form
|
93 |
| - |
94 | 74 | else:
|
95 | 75 | # must be a posix filesystem path (absolute or relative)
|
96 | 76 | # using PosixPath here ensures a clear error would be thrown on windows (whose paths and platform are not officially supported)
|
97 | 77 | _path = PosixPath(path)
|
98 | 78 |
|
99 |
| - if not _path.suffix and "zarr" not in path: |
100 |
| - raise ValueError( |
101 |
| - f"entries in the manifest must be paths to files, but this path has no file suffix: {path}" |
102 |
| - ) |
103 |
| - |
104 | 79 | # only posix paths can possibly not be absolute
|
105 | 80 | if not _path.is_absolute():
|
106 | 81 | if fs_root is None:
|
|
0 commit comments