Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add default= to schema_version_bump.py #1157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Acquisition(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/acquisition.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.3"]] = Field("1.0.3")
schema_version: SkipValidation[Literal["1.0.3"]] = Field(default="1.0.3")
protocol_id: List[str] = Field(default=[], title="Protocol ID", description="DOI for protocols.io")
experimenter_full_name: List[str] = Field(
...,
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/data_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DataDescription(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/data_description.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.3"]] = Field("1.0.3")
schema_version: SkipValidation[Literal["1.0.3"]] = Field(default="1.0.3")
license: Literal["CC-BY-4.0"] = Field("CC-BY-4.0", title="License")

platform: Platform.ONE_OF = Field(
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Instrument(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/instrument.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.3"]] = Field("1.0.3")
schema_version: SkipValidation[Literal["1.0.3"]] = Field(default="1.0.3")

instrument_id: Optional[str] = Field(
default=None,
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Metadata(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/metadata.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.1.1"]] = Field("1.1.1")
schema_version: SkipValidation[Literal["1.1.1"]] = Field(default="1.1.1")
id: UUID = Field(
default_factory=uuid4,
alias="_id",
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class Procedures(AindCoreModel):
_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/procedures.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})

schema_version: SkipValidation[Literal["1.1.3"]] = Field("1.1.3")
schema_version: SkipValidation[Literal["1.1.3"]] = Field(default="1.1.3")
subject_id: str = Field(
...,
description="Unique identifier for the subject. If this is not a Allen LAS ID, indicate this in the Notes.",
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Processing(AindCoreModel):

_DESCRIBED_BY_URL: str = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/processing.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.1.3"]] = Field("1.1.3")
schema_version: SkipValidation[Literal["1.1.3"]] = Field(default="1.1.3")

processing_pipeline: PipelineProcess = Field(
..., description="Pipeline used to process data", title="Processing Pipeline"
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class QualityControl(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/quality_control.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.2.1"]] = Field("1.2.1")
schema_version: SkipValidation[Literal["1.2.1"]] = Field(default="1.2.1")
evaluations: List[QCEvaluation] = Field(..., title="Evaluations")
notes: Optional[str] = Field(default=None, title="Notes")

Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Rig(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/rig.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.3"]] = Field("1.0.3")
schema_version: SkipValidation[Literal["1.0.3"]] = Field(default="1.0.3")
rig_id: str = Field(
...,
description="Unique rig identifier, name convention: <room>-<apparatus name>-<date modified YYYYMMDD>",
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class Session(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/session.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.3"]] = Field("1.0.3")
schema_version: SkipValidation[Literal["1.0.3"]] = Field(default="1.0.3")
protocol_id: List[str] = Field(default=[], title="Protocol ID", description="DOI for protocols.io")
experimenter_full_name: List[str] = Field(
...,
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema/core/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Subject(AindCoreModel):

_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/subject.py"
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
schema_version: SkipValidation[Literal["1.0.2"]] = Field("1.0.2")
schema_version: SkipValidation[Literal["1.0.2"]] = Field(default="1.0.2")
subject_id: str = Field(
...,
description="Unique identifier for the subject. If this is not a Allen LAS ID, indicate this in the Notes.",
Expand Down
4 changes: 3 additions & 1 deletion src/aind_data_schema/utils/schema_version_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def _get_updated_file(python_file_path: str, new_ver: str) -> list:
file_lines = f.readlines()
for line in file_lines:
if "schema_version: SkipValidation[Literal[" in str(line):
new_line_str = f' schema_version: SkipValidation[Literal["{new_ver}"]] = Field("{new_ver}")\n'
new_line_str = (
f' schema_version: SkipValidation[Literal["{new_ver}"]] = Field(default="{new_ver}")\n'
)
new_line = new_line_str.encode()
else:
new_line = line
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bump_schema_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def test_update_files(self, mock_write: MagicMock):
handler._update_files({Subject: new_subject_version, Session: new_session_version})

expected_line_change0 = (
f'schema_version: SkipValidation[Literal["{new_subject_version}"]] = Field("{new_subject_version}")'
f'schema_version: SkipValidation[Literal["{new_subject_version}"]] = Field(default="{new_subject_version}")'
)
expected_line_change1 = (
f'schema_version: SkipValidation[Literal["{new_session_version}"]] = Field("{new_session_version}")'
f'schema_version: SkipValidation[Literal["{new_session_version}"]] = Field(default="{new_session_version}")'
)

mock_write_args0 = mock_write.mock_calls[0].args
Expand Down
Loading