Merge remote-tracking branch 'origin/main'
This commit is contained in:
@ -191,84 +191,84 @@ class SpreadsheetModel(BaseModel):
|
|||||||
raise ValueError(f" '{v}' is not valid. Value must be one of {allowed}.")
|
raise ValueError(f" '{v}' is not valid. Value must be one of {allowed}.")
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator('spacegroupnumber', mode="before")
|
@field_validator('spacegroupnumber', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def spacegroupnumber_allowed(cls, v):
|
def spacegroupnumber_allowed(cls, v):
|
||||||
if v is not None:
|
if v is not None:
|
||||||
try:
|
try:
|
||||||
v = int(v)
|
v = int(v)
|
||||||
if not (1 <= v <= 230):
|
if not (1 <= v <= 230):
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be an integer between 1 and 230.")
|
raise ValueError(f" '{v}' is not valid. Value must be an integer between 1 and 230.")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be an integer between 1 and 230.") from e
|
raise ValueError(f" '{v}' is not valid. Value must be an integer between 1 and 230.") from e
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator('cellparameters', mode="before")
|
@field_validator('cellparameters', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def cellparameters_format(cls, v):
|
def cellparameters_format(cls, v):
|
||||||
if v:
|
if v:
|
||||||
values = [float(i) for i in v.split(",")]
|
values = [float(i) for i in v.split(",")]
|
||||||
if len(values) != 6 or any(val <= 0 for val in values):
|
if len(values) != 6 or any(val <= 0 for val in values):
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a set of six positive floats or integers.")
|
raise ValueError(f" '{v}' is not valid. Value must be a set of six positive floats or integers.")
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator('rescutkey', 'rescutvalue', mode="before")
|
@field_validator('rescutkey', 'rescutvalue', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def rescutkey_value_pair(cls, values):
|
def rescutkey_value_pair(cls, values):
|
||||||
rescutkey = values.get('rescutkey')
|
rescutkey = values.get('rescutkey')
|
||||||
rescutvalue = values.get('rescutvalue')
|
rescutvalue = values.get('rescutvalue')
|
||||||
if rescutkey and rescutvalue:
|
if rescutkey and rescutvalue:
|
||||||
if rescutkey not in {"is", "cchalf"}:
|
if rescutkey not in {"is", "cchalf"}:
|
||||||
raise ValueError("Rescutkey must be either 'is' or 'cchalf'")
|
raise ValueError("Rescutkey must be either 'is' or 'cchalf'")
|
||||||
if not isinstance(rescutvalue, float) or rescutvalue <= 0:
|
if not isinstance(rescutvalue, float) or rescutvalue <= 0:
|
||||||
raise ValueError("Rescutvalue must be a positive float if rescutkey is provided")
|
raise ValueError("Rescutvalue must be a positive float if rescutkey is provided")
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@field_validator('trustedhigh', mode="before")
|
@field_validator('trustedhigh', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def trustedhigh_allowed(cls, v):
|
def trustedhigh_allowed(cls, v):
|
||||||
if v is not None:
|
if v is not None:
|
||||||
try:
|
try:
|
||||||
v = float(v)
|
v = float(v)
|
||||||
if not (0 <= v <= 2.0):
|
if not (0 <= v <= 2.0):
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 2.0.")
|
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 2.0.")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 2.0.") from e
|
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 2.0.") from e
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator('chiphiangles', mode="before")
|
@field_validator('chiphiangles', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def chiphiangles_allowed(cls, v):
|
def chiphiangles_allowed(cls, v):
|
||||||
if v is not None:
|
if v is not None:
|
||||||
try:
|
try:
|
||||||
v = float(v)
|
v = float(v)
|
||||||
if not (0 <= v <= 30):
|
if not (0 <= v <= 30):
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 30.")
|
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 30.")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 30.") from e
|
raise ValueError(f" '{v}' is not valid. Value must be a float between 0 and 30.") from e
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator('dose', mode="before")
|
@field_validator('dose', mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def dose_positive(cls, v):
|
def dose_positive(cls, v):
|
||||||
if v is not None:
|
if v is not None:
|
||||||
try:
|
try:
|
||||||
v = float(v)
|
v = float(v)
|
||||||
if v <= 0:
|
if v <= 0:
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a positive float.")
|
raise ValueError(f" '{v}' is not valid. Value must be a positive float.")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
raise ValueError(f" '{v}' is not valid. Value must be a positive float.") from e
|
raise ValueError(f" '{v}' is not valid. Value must be a positive float.") from e
|
||||||
return v
|
return v
|
||||||
|
|
||||||
class TELLModel(SpreadsheetModel):
|
class TELLModel(SpreadsheetModel):
|
||||||
input_order: int
|
input_order: int
|
||||||
samplemountcount: int = 0
|
samplemountcount: int = 0
|
||||||
samplestatus: str = "not present"
|
samplestatus: str = "not present"
|
||||||
puckaddress: str = "---"
|
puckaddress: str = "---"
|
||||||
username: str
|
username: str
|
||||||
puck_number: int
|
puck_number: int
|
||||||
prefix: Optional[str]
|
prefix: Optional[str]
|
||||||
folder: Optional[str]
|
folder: Optional[str]
|
||||||
|
|
||||||
class SpreadsheetResponse(BaseModel):
|
class SpreadsheetResponse(BaseModel):
|
||||||
data: List[SpreadsheetModel] # Validated data rows as SpreadsheetModel instances
|
data: List[SpreadsheetModel] # Validated data rows as SpreadsheetModel instances
|
||||||
|
@ -110,7 +110,7 @@ contacts = [
|
|||||||
# Example data for return addresses
|
# Example data for return addresses
|
||||||
return_addresses = [
|
return_addresses = [
|
||||||
Address(id=1, street='123 Hobbiton St', city='Shire', zipcode='12345', country='Middle Earth'),
|
Address(id=1, street='123 Hobbiton St', city='Shire', zipcode='12345', country='Middle Earth'),
|
||||||
Address(id=2, street='456 Rohan Rd', city='Edoras', zipcode='67890', country='Middle Earth')
|
Address(id=2, street='456 Rohan Rd', city='Edoras', zipcode='67890', country='Middle Earth'),
|
||||||
Address(id=3, street='789 Greenwood Dr', city='Mirkwood', zipcode='13579', country='Middle Earth'),
|
Address(id=3, street='789 Greenwood Dr', city='Mirkwood', zipcode='13579', country='Middle Earth'),
|
||||||
Address(id=4, street='321 Gondor Ave', city='Minas Tirith', zipcode='24680', country='Middle Earth'),
|
Address(id=4, street='321 Gondor Ave', city='Minas Tirith', zipcode='24680', country='Middle Earth'),
|
||||||
Address(id=5, street='654 Falgorn Pass', city='Rivendell', zipcode='11223', country='Middle Earth')
|
Address(id=5, street='654 Falgorn Pass', city='Rivendell', zipcode='11223', country='Middle Earth')
|
||||||
|
Reference in New Issue
Block a user