Skip to content

Commit

Permalink
feature/change type of distribution.title to an array of texts (#354)
Browse files Browse the repository at this point in the history
# PR Context
- update to mex-model 3.4

# Changes
- BREAKING: change type of distribution.title to an array of texts
  • Loading branch information
cutoffthetop authored Dec 18, 2024
1 parent 314b3e1 commit d458beb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -25,7 +25,7 @@ repos:
- id: fix-byte-order-marker
name: byte-order
- repo: https://github.com/pdm-project/pdm
rev: 2.20.1
rev: 2.22.0
hooks:
- id: pdm-lock-check
name: pdm
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changes

- BREAKING: change type of distribution.title to an array of texts

### Deprecated

### Removed
Expand Down
53 changes: 21 additions & 32 deletions mex/common/models/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
MergedDistributionIdentifier,
MergedPrimarySourceIdentifier,
MIMEType,
Text,
Year,
YearMonth,
YearMonthDay,
Expand All @@ -41,6 +42,14 @@ class _OptionalLists(_Stem):
downloadURL: list[Link] = []


class _RequiredLists(_Stem):
title: Annotated[list[Text], Field(min_length=1)]


class _SparseLists(_Stem):
title: list[Text] = []


class _OptionalValues(_Stem):
accessService: MergedAccessPlatformIdentifier | None = None
license: License | None = None
Expand All @@ -51,28 +60,11 @@ class _OptionalValues(_Stem):
class _RequiredValues(_Stem):
accessRestriction: AccessRestriction
issued: YearMonthDayTime | YearMonthDay | YearMonth | Year
title: Annotated[
str,
Field(
examples=["theNameOfTheFile"],
min_length=1,
),
]


class _SparseValues(_Stem):
accessRestriction: AccessRestriction | None = None
issued: YearMonthDayTime | YearMonthDay | YearMonth | Year | None = None
title: (
Annotated[
str,
Field(
examples=["theNameOfTheFile"],
min_length=1,
),
]
| None
) = None


class _VariadicValues(_Stem):
Expand All @@ -82,18 +74,11 @@ class _VariadicValues(_Stem):
license: list[License] = []
mediaType: list[MIMEType] = []
modified: list[YearMonthDayTime | YearMonthDay | YearMonth | Year] = []
title: list[
Annotated[
str,
Field(
examples=["theNameOfTheFile"],
min_length=1,
),
]
] = []


class BaseDistribution(_OptionalLists, _OptionalValues, _RequiredValues):


class BaseDistribution(
_OptionalLists, _RequiredLists, _OptionalValues, _RequiredValues
):
"""All fields for a valid distribution except for provenance."""


Expand Down Expand Up @@ -126,7 +111,9 @@ class MergedDistribution(BaseDistribution, MergedItem):
identifier: Annotated[MergedDistributionIdentifier, Field(frozen=True)]


class PreviewDistribution(_OptionalLists, _OptionalValues, _SparseValues, PreviewItem):
class PreviewDistribution(
_OptionalLists, _SparseLists, _OptionalValues, _SparseValues, PreviewItem
):
"""Preview for merging all extracted items and rules for a distribution."""

entityType: Annotated[
Expand All @@ -136,7 +123,7 @@ class PreviewDistribution(_OptionalLists, _OptionalValues, _SparseValues, Previe


class AdditiveDistribution(
_OptionalLists, _OptionalValues, _SparseValues, AdditiveRule
_OptionalLists, _SparseLists, _OptionalValues, _SparseValues, AdditiveRule
):
"""Rule to add values to merged distribution items."""

Expand All @@ -145,7 +132,9 @@ class AdditiveDistribution(
] = "AdditiveDistribution"


class SubtractiveDistribution(_OptionalLists, _VariadicValues, SubtractiveRule):
class SubtractiveDistribution(
_OptionalLists, _SparseLists, _VariadicValues, SubtractiveRule
):
"""Rule to subtract values from merged distribution items."""

entityType: Annotated[
Expand Down
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"click>=8,<9",
"langdetect>=1,<2",
"ldap3>=2,<3",
"mex-model @ git+https://github.com/robert-koch-institut/mex-model.git@3.3.2",
"mex-model @ git+https://github.com/robert-koch-institut/mex-model.git@3.4.0",
"numpy>=2,<3",
"pandas>=2,<3",
"pyarrow>=18,<19",
Expand Down

0 comments on commit d458beb

Please sign in to comment.