Skip to content

Commit d7bcf5e

Browse files
committed
Allow arbitrary strings for patient/lesion id
1 parent 32d94dc commit d7bcf5e

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

isic_metadata/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
Diagnosis,
1313
DiagnosisConfirmType,
1414
ImageType,
15-
LesionId,
1615
MelClass,
1716
MelMitoticIndex,
1817
MelThickMm,
1918
MelType,
2019
NevusType,
21-
PatientId,
2220
Sex,
2321
)
2422

@@ -62,8 +60,8 @@
6260
("mel_mitotic_index", MelMitoticIndex),
6361
("anatom_site_general", AnatomSiteGeneral),
6462
("color_tint", ColorTint),
65-
("patient_id", PatientId),
66-
("lesion_id", LesionId),
63+
("patient_id", str),
64+
("lesion_id", str),
6765
]:
6866
FIELD_REGISTRY[field] = {
6967
"validator": validator,

isic_metadata/fields.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import re
55
from typing import Optional, Union
66

7-
from pydantic.types import constr
8-
97

108
class BaseStr(str):
119
@classmethod
@@ -323,7 +321,3 @@ def validate(cls, value: str) -> Optional[str]:
323321

324322
class AcquisitionDay(int):
325323
pass
326-
327-
328-
PatientId = constr(pattern=r"^IP_[0-9]{7}$")
329-
LesionId = constr(pattern=r"^IL_[0-9]{7}$")

isic_metadata/metadata.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
DiagnosisConfirmTypeEnum,
2626
DiagnosisEnum,
2727
ImageTypeEnum,
28-
LesionId,
2928
MelClassEnum,
3029
MelMitoticIndexEnum,
3130
MelThickMm,
3231
MelTypeEnum,
3332
NevusTypeEnum,
34-
PatientId,
3533
Sex,
3634
)
3735

@@ -74,8 +72,8 @@ class MetadataRow(BaseModel):
7472
] = None
7573
melanocytic: Optional[bool] = None
7674
# these can be passed as ints, floats, etc from pandas so they need to be coerced to strings
77-
patient_id: Optional[Annotated[PatientId, BeforeValidator(lambda x: str(x))]] = None
78-
lesion_id: Optional[Annotated[LesionId, BeforeValidator(lambda x: str(x))]] = None
75+
patient_id: Optional[Annotated[str, BeforeValidator(lambda x: str(x))]] = None
76+
lesion_id: Optional[Annotated[str, BeforeValidator(lambda x: str(x))]] = None
7977
acquisition_day: Optional[int] = None
8078
marker_pen: Optional[bool] = None
8179
hairy: Optional[bool] = None

0 commit comments

Comments
 (0)