Skip to content

Commit

Permalink
Merge pull request #554 from bioimage-io/patch_incoming
Browse files Browse the repository at this point in the history
patch settings.CI
  • Loading branch information
FynnBe authored Mar 12, 2024
2 parents c3e56f3 + abe1d10 commit 4fc3e74
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.3.2
hooks:
- id: ruff
args: [--fix]
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ Made with [contrib.rocks](https://contrib.rocks).

### bioimageio.spec Python package

#### bioimageio.spec 0.5.0post2

* don't fail if CI env var is a string

#### bioimageio.spec 0.5.0post1

* fix `_internal.io_utils.identify_bioimageio_yaml_file()`
Expand Down
2 changes: 1 addition & 1 deletion bioimageio/spec/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.5.0post1"
"version": "0.5.0post2"
}
4 changes: 2 additions & 2 deletions bioimageio/spec/_internal/_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
Expand Down Expand Up @@ -27,7 +27,7 @@ class Settings(BaseSettings, extra="ignore"):
Existence of local absolute file paths is still being checked."""

CI: Annotated[bool, Field(alias="CI")] = False
CI: Annotated[Union[bool, str], Field(alias="CI")] = False
"""wether or not the execution happens in a continuous integration (CI) environment"""

user_agent: Optional[str] = None
Expand Down
21 changes: 13 additions & 8 deletions bioimageio/spec/_internal/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@
SLOTS = {"slots": True}


Sha256 = ValidatedString[
Annotated[
str,
StringConstraints(
strip_whitespace=True, to_lower=True, min_length=64, max_length=64
),
]
]
class Sha256(
ValidatedString[
Annotated[
str,
StringConstraints(
strip_whitespace=True, to_lower=True, min_length=64, max_length=64
),
]
],
frozen=True,
):
"""SHA-256 hash value"""


AbsolutePathT = TypeVar(
"AbsolutePathT", bound=Union[HttpUrl, AbsoluteDirectory, AbsoluteFilePath]
Expand Down
20 changes: 12 additions & 8 deletions bioimageio/spec/_internal/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ def _serialize_datetime_json(dt: datetime) -> str:
return dt.isoformat()


Datetime = RootModel[
Annotated[
datetime,
BeforeValidator(_validate_datetime),
PlainSerializer(_serialize_datetime_json, when_used="json-unless-none"),
class Datetime(
RootModel[
Annotated[
datetime,
BeforeValidator(_validate_datetime),
PlainSerializer(_serialize_datetime_json, when_used="json-unless-none"),
]
]
]
"""Timestamp in [ISO 8601](#https://en.wikipedia.org/wiki/ISO_8601) format
with a few restrictions listed [here](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat)."""
):
"""Timestamp in [ISO 8601](#https://en.wikipedia.org/wiki/ISO_8601) format
with a few restrictions listed [here](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat).
"""


Doi = ValidatedString[Annotated[str, StringConstraints(pattern=DOI_REGEX)]]
FormatVersionPlaceholder = Literal["latest", "discover"]
Expand Down
8 changes: 8 additions & 0 deletions bioimageio/spec/_internal/version_type.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any, Optional, Tuple, Union

import packaging.version
Expand All @@ -16,6 +18,12 @@ def model_post_init(self, __context: Any) -> None:
self._version = packaging.version.Version(str(self.root))
return super().model_post_init(__context)

def __lt__(self, other: Version):
return self._version < other._version

def __eq__(self, other: Version):
return self._version == other._version

# the properties below are adopted from and mirror properties of packaging.version.Version
@property
def epoch(self) -> int:
Expand Down
6 changes: 1 addition & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ def check_bioimageio_yaml(

json_data = rd.model_dump(mode="json")
# check compatibility to our latest json schema...
if (
bioimageio_json_schema is not None
and "v0_"
not in downloaded_source.path.name # ...unless it's a historic example
):
if bioimageio_json_schema is not None:
try:
jsonschema.validate(json_data, bioimageio_json_schema)
except jsonschema.ValidationError:
Expand Down

0 comments on commit 4fc3e74

Please sign in to comment.