Skip to content

Commit

Permalink
add version_nr, remove sem_ver
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Feb 29, 2024
1 parent 2c160aa commit 3dffcc7
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 49 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ all generic 0.3.0 changes (except models already have the `parent` field) plus:
#### generic 0.2.4 and model 0.4.10

* Breaking changes that are fully auto-convertible
* `version` is now a single number. If version is set as a string with a dot (from complying with the previous field definition, holding a SemVer 2.0 version), it is moved to the new `sem_ver` field.
* `id` overwritten with value from `config.bioimageio.nickname` if available
* Non-breaking changes
* `sem_ver` is a new, opitonal field (set from `version` if applicable)
* `version_nr` is a new, optional field indicating that an RDF is the nth published version with a given `id`
* `id_emoji` is a new, optional field (set from `config.bioimageio.nickname_icon` if available)
* `uploader` is a new, optional field with `email` and an optional `name` subfields

Expand Down
4 changes: 2 additions & 2 deletions bioimageio/spec/application/v0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ class LinkedApplication(Node):
id: ApplicationId
"""A valid application `id` from the bioimage.io collection."""

version: Optional[int] = None
"""application version"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked application"""
4 changes: 2 additions & 2 deletions bioimageio/spec/application/v0_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ class LinkedApplication(Node):
id: ApplicationId
"""A valid application `id` from the bioimage.io collection."""

version: int
"""application version"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked application"""
4 changes: 2 additions & 2 deletions bioimageio/spec/collection/v0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,5 @@ class LinkedCollection(Node):
id: CollectionId
"""A valid collection `id` from the bioimage.io collection."""

version: Optional[int] = None
"""collection version"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked collection"""
4 changes: 2 additions & 2 deletions bioimageio/spec/collection/v0_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,5 @@ class LinkedCollection(Node):
id: CollectionId
"""A valid collection `id` from the bioimage.io collection."""

version: int
"""collection version"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked collection"""
4 changes: 2 additions & 2 deletions bioimageio/spec/dataset/v0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ class LinkedDataset(Node):
id: DatasetId
"""A valid dataset `id` from the bioimage.io collection."""

version: Optional[int] = None
"""dataset version"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked dataset"""
4 changes: 2 additions & 2 deletions bioimageio/spec/dataset/v0_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ class LinkedDataset(Node):
id: DatasetId
"""A valid dataset `id` from the bioimage.io collection."""

version: int
"""dataset version"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked dataset"""
28 changes: 8 additions & 20 deletions bioimageio/spec/generic/v0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
get_args,
)

from annotated_types import Ge, Len, LowerCase, MaxLen
from annotated_types import Len, LowerCase, MaxLen
from pydantic import EmailStr, Field, ValidationInfo, field_validator, model_validator
from typing_extensions import Annotated, Self

Expand All @@ -35,9 +35,7 @@
from bioimageio.spec._internal.types import OrcidId as OrcidId
from bioimageio.spec._internal.types import RelativeFilePath as RelativeFilePath
from bioimageio.spec._internal.types import ResourceId as ResourceId
from bioimageio.spec._internal.types import (
Version as Version,
)
from bioimageio.spec._internal.types import Version as Version
from bioimageio.spec._internal.types.field_validation import (
AfterValidator as _AfterValidator,
)
Expand Down Expand Up @@ -175,8 +173,8 @@ class LinkedResource(Node):
id: ResourceId
"""A valid resource `id` from the bioimage.io collection."""

version: Optional[int] = None
"""version of linked resource"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked resource"""


class GenericModelDescrBase(ResourceDescrBase):
Expand Down Expand Up @@ -336,21 +334,11 @@ def warn_about_tag_categories(

return value

version: Annotated[int, Ge(ge=1), Field(examples=[1, 2, 3])] = 1
"""The version number of the resource.
note: previous versions of this spec accepted a SemVer 2.0 version, e.g. 0.1.0.
These are now moved to the new `sem_ver` field."""
version: Optional[Version] = None
"""The version of the resource following SemVer 2.0."""

sem_ver: Optional[Version] = None
"""A SemVer 2.0 version of the resource."""

@model_validator(mode="before")
@classmethod
def _convert_version(cls, data: Union[Any, Dict[Any, Any]]):
if isinstance(data, dict) and "." in str(data.get("version")):
data["sem_ver"] = data.pop("version")

return data
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version)"""


class GenericDescrBase(GenericModelDescrBase):
Expand Down
14 changes: 7 additions & 7 deletions bioimageio/spec/generic/v0_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Dict, List, Literal, Optional, Sequence, TypeVar, Union

import requests
from annotated_types import Ge, Len, LowerCase, MaxLen
from annotated_types import Len, LowerCase, MaxLen
from pydantic import Field, ValidationInfo, field_validator, model_validator
from typing_extensions import Annotated

Expand Down Expand Up @@ -164,8 +164,8 @@ class LinkedResource(Node):
id: ResourceId
"""A valid resource `id` from the official bioimage.io collection."""

version: int
"""version of linked resource"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked resource"""


class GenericModelDescrBase(ResourceDescrBase):
Expand Down Expand Up @@ -324,11 +324,11 @@ def warn_about_tag_categories(

return value

version: Annotated[int, Ge(ge=1), Field(examples=[1, 2, 3])] = 1
"""The version number of the resource."""
version: Optional[Version] = None
"""The version of the resource following SemVer 2.0."""

sem_ver: Optional[Version] = None
"""A SemVer 2.0 version of the resource."""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version)"""


class GenericDescrBase(GenericModelDescrBase):
Expand Down
4 changes: 2 additions & 2 deletions bioimageio/spec/model/v0_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ class LinkedModel(Node):
id: ModelId
"""A valid model `id` from the bioimage.io collection."""

version: Optional[int] = None
"""model version"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked model"""


class ModelDescr(GenericModelDescrBase, title="bioimage.io model specification"):
Expand Down
4 changes: 2 additions & 2 deletions bioimageio/spec/model/v0_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,8 @@ class LinkedModel(Node):
id: ModelId
"""A valid model `id` from the bioimage.io collection."""

version: int
"""model version"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked model"""


class ModelDescr(GenericModelDescrBase, title="bioimage.io model specification"):
Expand Down
4 changes: 2 additions & 2 deletions bioimageio/spec/notebook/v0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ class LinkedNotebook(Node):
id: NotebookId
"""A valid notebook `id` from the bioimage.io collection."""

version: Optional[int] = None
"""notebook version"""
version_nr: Optional[int] = None
"""version number (nth published version, not the semantic version) of linked notebook"""
4 changes: 2 additions & 2 deletions bioimageio/spec/notebook/v0_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ class LinkedNotebook(Node):
id: NotebookId
"""A valid notebook `id` from the bioimage.io collection."""

version: int
"""notebook version"""
version_nr: int
"""version number (nth published version, not the semantic version) of linked notebook"""

0 comments on commit 3dffcc7

Please sign in to comment.