Skip to content

Commit 32443a8

Browse files
authored
Merge pull request #57 from ImageMarkup/prepare-for-parquet
Prepare metadata schema for parquet-compatible version
2 parents 2364c8d + f94145c commit 32443a8

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

isic_metadata/metadata.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,26 @@ class MetadataRow(BaseModel):
215215
personal_hx_mm: bool | None = None
216216
family_hx_mm: bool | None = None
217217
clin_size_long_diam_mm: (
218-
Annotated[Decimal, BeforeValidator(ClinSizeLongDiamMm.parse_measurement_str)] | None
218+
Annotated[
219+
Decimal,
220+
BeforeValidator(ClinSizeLongDiamMm.parse_measurement_str),
221+
Field(max_digits=5, decimal_places=2),
222+
]
223+
| None
219224
) = None
220225
fitzpatrick_skin_type: FitzpatrickSkinType | None = None
221226
melanocytic: bool | None = None
222227
concomitant_biopsy: bool | None = None
223228

224229
mel_mitotic_index: MelMitoticIndexEnum | None = None
225-
mel_thick_mm: Annotated[Decimal, BeforeValidator(MelThickMm.parse_measurement_str)] | None = (
226-
None
227-
)
230+
mel_thick_mm: (
231+
Annotated[
232+
Decimal,
233+
BeforeValidator(MelThickMm.parse_measurement_str),
234+
Field(max_digits=5, decimal_places=2),
235+
]
236+
| None
237+
) = None
228238
mel_ulcer: bool | None = None
229239

230240
patient_id: str | None = None
@@ -239,7 +249,7 @@ class MetadataRow(BaseModel):
239249

240250
rcm_case_id: str | None = None
241251

242-
unstructured: dict[str, Any] = {}
252+
unstructured: dict[str, Any] = Field(default_factory=dict, exclude=True)
243253

244254
# Unused and undocumented
245255
marker_pen: bool | None = None

tests/test_fields.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def test_mel_thick_mm_invalid():
101101
clin_size=st.one_of(
102102
# keep max values bounded so they don't generate larger than representable decimals.
103103
# disallow infinity to avoid the string 'inf'.
104-
st.floats(min_value=0, max_value=1_000_000, exclude_min=True, allow_infinity=False),
105-
st.integers(min_value=1, max_value=1_000),
104+
st.floats(min_value=0, max_value=9999, exclude_min=False, allow_infinity=False),
105+
st.integers(min_value=1, max_value=9999),
106106
).map(lambda x: f"{x} mm")
107107
)
108108
def test_clin_size_long_diam_mm_always_rounded(clin_size: str):

0 commit comments

Comments
 (0)