data-translation-experiments / schema_classes.py
rosemariafontana's picture
Update schema_classes.py
3eaa798 verified
raw
history blame
9 kB
from pydantic import BaseModel, Field, validator, ValidationError
from typing import List, Dict, Any, Optional, Literal, Union
from enum import Enum
# These are the necessary components that make up the Trials
#class Variables(BaseModel):
# controlled: List[str] = Field(..., title="Controlled Variables", description="A list of controlled variables, which will be constant (controlled) across all trials")
# independent: List[str] = Field(..., title="Independent Variables", description="A list of independent variables (ie treatments), which will be intentionally varied across one or more trials")
# outcome: List[str] = Field(..., title="Outcome Variables", description="A list of outcome variables (ie dependent or response variables)")
class Treatment(BaseModel):
name: str = Field(..., title="Name", description="The treatment name")
description: str = Field(..., title="Description", description="The treatment description, including the conditions within this treatment")
crops: List[str] = Field(..., title="Crops", description="A list of crops being tested in this treatment")
fields: List[str] = Field(..., title="Fields", description="A list of fields in which this treatment has occured or will occur")
#learnings: List[str] = Field(..., title="Learnings", description="A list of lessons learned from this experiment")
#variables: Variables = Field(..., title="Variables", description="Variables (ie factors) in this experiment. Some variables are constant (controlled) and some will vary in order to learn something (independent)")
#confoundingFactors: List[str] = Field(..., title="Confounding Factors", description="A list of factors which may impact the outcomes of the experiment that were not planned for")
class Trial(BaseModel):
name: str = Field(..., title="Name", description="The name of this trial")
description: str = Field(..., title="Description", description="A description of this trial")
treatments: List[Treatment] = Field(..., title="Treatments", description="A list of different treatments (strips or blocks with the same conditions applied) performed by the partner")
class TrialLite(BaseModel):
name: str = Field(..., title="Name", description="The name of this trial")
description: str = Field(..., title="Description", description="A description of this trial")
#################################################################################
# These are the necessary components that make up the Interactions
class Role(str, Enum):
PARTNER = 'partner'
STAFF = 'staff'
AGRONOMIST = 'agronomist'
OTHER = 'other'
class Person(BaseModel):
name: str = Field(..., title="Name", description="Name of this person")
role: Role = Field(..., title="Role", description="Role of this person")
class Interactions(BaseModel):
people: List[Person] = Field(..., title="People", description="People involved or mentioned during interaction")
date: str = Field(..., title="Date of current interaction", description="Date of the interaction")
nextMeeting: str = Field(..., title="Date of next meeting", description="Proposed date of the next future interaction")
nextSteps: List[str] = Field(..., title="Next Steps", description="List of individual next steps derived from the interaction")
summary: str = Field(..., title="Summary", description="Summary of the interaction")
class InteractionsLite(BaseModel):
date: str = Field(..., title="Date of current interaction", description="Date of the interaction")
nextMeeting: str = Field(..., title="Date of next meeting", description="Proposed date of the next future interaction")
nextSteps: List[str] = Field(..., title="Next Steps", description="List of individual next steps derived from the interaction")
summary: str = Field(..., title="Summary", description="Summary of the interaction")
#################################################################################
# These are the components for Farm Activities, Fields, and Plantings
class Status(str, Enum):
ACTIVE = 'active'
ARCHIVED = 'archived'
# Depending on how well this works, come back and hard-code this based on some parameter(s)
class Convention(str, Enum):
ACTIVITY = 'log--activity'
OBSERVATION = 'log--observation'
FLAMING = 'log--activity--flaming'
GRAZING = 'log--activity--grazing'
MOWING = 'log--activity--mowing'
SOLARIZATION = 'log--activity--solarization'
TERMINATION = 'log--activity--termination'
TILLAGE = 'log--activity--tillage'
HARVEST = 'log--activity--harvest'
HERBICIDE = 'log--input--herbicide_or_pesticide'
IRRIGATION = 'log--input--irrigation'
LIME = 'log--input--lime'
ORGANIC = 'log--input--organic_matter'
SEEDTREAT = 'log--input--seed_treatment'
SEEDLINGTREAT = 'log--input--seedling_treatment'
MODUS = 'log--lab_test--modus_lab_test'
SEEDING = 'log--seeding--seeding'
TRANSPLANT = 'log--transplanting--transplant'
class Structure(str, Enum):
CLAY = 'clay'
SANDYCLAY = 'sandy clay'
SILTYCLAY = 'silty clay'
SANDYCLAYLOAM = 'sandy clay loam'
SILYCLAMLOAM = 'silty clay loam'
CLAYLOAM = 'clay loam'
SANDYLOAM = 'sandy loam'
SILTLOAM = 'silt loam'
LOAM = 'loam'
LOAMYSAND = 'loamy sand'
SAND = 'sand'
SILT = 'silt'
class Log(BaseModel):
convention: Convention = Field(..., title="Logs", description="This log's convention (i.e. this log's category or type)")
date: str = Field(..., title="Date", description="Date the log (i.e. action of the activity or input) was performed")
description: str = Field(..., title="Description", description="A description of the details of the log (i.e. details about farm activity performed")
class Soil(BaseModel):
description: str = Field(..., title="Description", description="A general description of the soil")
structure: List[Structure] = Field(..., title="Structure", description="The structure of the soil using options from the major soil texture classes (sand, clay, silt)")
biology: str = Field(..., title="Biology", description="Biological activity levels of the soil, including fluffiness, worms and bugs, and other evidence of soil biological activity")
class Yield(BaseModel):
quantity: str = Field(..., title="Quantity", description="A description of the total yield (harvested amount) from this planting, including units when available")
quality: str = Field(..., title="Quality", description="The product quality of the harvest. For example, small or large fruits, sweet or tart flavor, easily molding or containing mold, high number of product seconds, etc.)")
# It breaks if soil and yield aren't lists for some reason
class Planting(BaseModel):
name: str = Field(..., title="Name", description="The name of the planting")
status: Status = Field(..., title="Status", description="The status of the planting. \"active\" is a planting which is currently still in the field. \"archived\" is a planting which is no longer in the field (has been terminated or harvested)")
crop: List[str] = Field(..., title="Crop", description="A list of the crops in this planting")
variety: List[str] = Field(..., title="Variety", description="A list of the crop varieties in this planting")
logs: List[Log] = Field(..., title="Logs", description="A list of all the logs that are associated with the farm activities")
soil: List[Soil] = Field(..., title="Soil", description="A single soil profile for this planting, containing only one soil description")
yield_: List[Yield] = Field(..., title="Yield", description="One set of quantitative and qualitative yield observations for this planting")
class FarmActivities(BaseModel):
name: str = Field(..., title="Name", description="The name of the agricultural field.")
description: str = Field(..., title="Description", description="The description of the agricultural field.")
plantings: List[Planting] = Field(..., title="Plantings", description="All of the plantings which have occurred on this field.")
# These are extra for the modular approach (step-wise)
class FarmActivitiesLite(BaseModel):
name: str = Field(..., title="Name", description="The name of the agricultural field.")
description: str = Field(..., title="Description", description="The description of the agricultural field.")
class PlantingLite(BaseModel):
name: str = Field(..., title="Name", description="The name of the planting")
status: Status = Field(..., title="Status", description="The status of the planting. \"active\" is a planting which is currently still in the field. \"archived\" is a planting which is no longer in the field (has been terminated or harvested)")
crop: List[str] = Field(..., title="Crop", description="A list of the crops in this planting")
variety: List[str] = Field(..., title="Variety", description="A list of the crop varieties in this planting")