Skip to content

Commit e31881a

Browse files
committed
add get_resolved_source_path
1 parent f7e0eac commit e31881a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bioimageio/spec/shared/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
BIOIMAGEIO_COLLECTION_ERROR,
99
BIOIMAGEIO_SITE_CONFIG,
1010
BIOIMAGEIO_SITE_CONFIG_ERROR,
11-
RDF_NAMES,
1211
DownloadCancelled,
12+
RDF_NAMES,
1313
_resolve_json_from_url,
14+
get_resolved_source_path,
1415
resolve_local_source,
1516
resolve_rdf_source,
1617
resolve_rdf_source_and_type,

bioimageio/spec/shared/_resolve_source.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ def _resolve_source_importable_path(
317317
)
318318

319319

320+
def get_resolved_source_path(source, root_path: typing.Union[os.PathLike, URI], pbar=None) -> pathlib.Path:
321+
resolved = resolve_source(source, root_path=root_path, pbar=pbar)
322+
if isinstance(resolved, os.PathLike):
323+
return pathlib.Path(resolved)
324+
elif isinstance(resolved, raw_nodes.ResolvedImportableSourceFile):
325+
return resolved.source_file
326+
else:
327+
raise NotImplementedError(type(resolved))
328+
329+
320330
@resolve_source.register
321331
def _resolve_source_list(
322332
source: list,

0 commit comments

Comments
 (0)