Skip to content

Commit

Permalink
Merge pull request #366 from Tomaz-Vieira/spec_v0_5__fix_core_io
Browse files Browse the repository at this point in the history
Fixes typing issues in core.io
  • Loading branch information
FynnBe authored Nov 24, 2023
2 parents f2c3f82 + 46c840d commit 412255a
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions bioimageio/core/io.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
from __future__ import annotations

import collections.abc
import io
import os
import shutil
from dataclasses import dataclass
from pathlib import Path
from tempfile import NamedTemporaryFile, mkdtemp
from typing import Any, Dict, List, Literal, Mapping, Optional, Sequence, TextIO, TypedDict, Union, cast
from zipfile import ZIP_DEFLATED, ZipFile, is_zipfile
from typing import List, Literal, Optional, Union

import pooch
from pydantic import AnyUrl, DirectoryPath, FilePath, HttpUrl, TypeAdapter
from ruamel.yaml import YAML
from typing_extensions import NotRequired, Unpack

from bioimageio.spec import ResourceDescription
from bioimageio.spec import build_description
from bioimageio.spec import load_description as load_description
from bioimageio.spec._internal.base_nodes import ResourceDescriptionBase
from bioimageio.spec._description import ResourceDescr
from bioimageio.spec._internal.constants import DISCOVER
from bioimageio.spec._internal.types import FileName, RdfContent, RelativeFilePath, Sha256, ValidationContext, YamlValue
from bioimageio.spec._internal.validation_context import ValidationContext
from bioimageio.spec._internal.io_utils import open_bioimageio_yaml
from bioimageio.spec.common import BioimageioYamlContent, FileSource, InvalidDescription
from bioimageio.spec.model.v0_4 import WeightsFormat
from bioimageio.spec.package import extract_file_name, get_resource_package_content
from bioimageio.spec.summary import ValidationSummary


Expand All @@ -31,7 +17,7 @@ def load_description_and_validate(
/,
*,
format_version: Union[Literal["discover"], Literal["latest"], str] = DISCOVER,
) -> Union[ResourceDescription, InvalidDescription]:
) -> Union[ResourceDescr, InvalidDescription]:
opened = open_bioimageio_yaml(source)

return build_description_and_validate(
Expand All @@ -47,15 +33,15 @@ def build_description_and_validate(
*,
context: Optional[ValidationContext] = None,
format_version: Union[Literal["discover"], Literal["latest"], str] = DISCOVER,
) -> Union[ResourceDescription, InvalidDescription]:
) -> Union[ResourceDescr, InvalidDescription]:
"""load and validate a BioImage.IO description from the content of a resource description file (RDF)"""
descr = build_description(rdf_content, context=context, format_version=format_version)
rd = build_description(data, context=context, format_version=format_version)
# todo: add dynamic validation
return rd


def validate(
source: RdfSource,
source: "FileSource | BioimageioYamlContent",
/,
*,
context: Optional[ValidationContext] = None,
Expand Down

0 comments on commit 412255a

Please sign in to comment.