rosemariafontana commited on
Commit
fa532ba
·
verified ·
1 Parent(s): 1c169df

Create schema_classes.py

Browse files
Files changed (1) hide show
  1. schema_classes.py +126 -0
schema_classes.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field, validator, ValidationError
2
+ from typing import List, Dict, Any, Optional, Literal, Union
3
+ from enum import Enum
4
+
5
+ # These are the necessary components that make up the Trials
6
+ #class Variables(BaseModel):
7
+ # controlled: List[str] = Field(..., title="Controlled Variables", description="A list of controlled variables, which will be constant (controlled) across all trials")
8
+ # 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")
9
+ # outcome: List[str] = Field(..., title="Outcome Variables", description="A list of outcome variables (ie dependent or response variables)")
10
+
11
+ class Treatment(BaseModel):
12
+ name: str = Field(..., title="Name", description="The treatment name")
13
+ description: str = Field(..., title="Description", description="The treatment description, including the conditions within this treatment")
14
+ crops: List[str] = Field(..., title="Crops", description="A list of crops being tested in this treatment")
15
+ fields: List[str] = Field(..., title="Fields", description="A list of fields in which this treatment has occured or will occur")
16
+ #learnings: List[str] = Field(..., title="Learnings", description="A list of lessons learned from this experiment")
17
+ #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)")
18
+ #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")
19
+
20
+ class Trial(BaseModel):
21
+ name: str = Field(..., title="Name", description="The name of this trial")
22
+ description: str = Field(..., title="Description", description="A description of this trial")
23
+ treatments: List[Treatment] = Field(..., title="Treatments", description="A list of different treatments (strips or blocks with the same conditions applied) performed by the partner")
24
+
25
+ #################################################################################
26
+
27
+ # These are the necessary components that make up the Interactions
28
+ class Role(str, Enum):
29
+ PARTNER = 'partner'
30
+ STAFF = 'staff'
31
+ AGRONOMIST = 'agronomist'
32
+ OTHER = 'other'
33
+
34
+ class Person(BaseModel):
35
+ name: str = Field(..., title="Name", description="Name of this person")
36
+ role: Role = Field(..., title="Role", description="Role of this person")
37
+
38
+ class Interactions(BaseModel):
39
+ people: List[Person] = Field(..., title="People", description="People involved or mentioned during interaction")
40
+ date: str = Field(..., title="Date of current interaction", description="Date of the interaction")
41
+ nextMeeting: str = Field(..., title="Date of next meeting", description="Proposed date of the next future interaction")
42
+ nextSteps: List[str] = Field(..., title="Next Steps", description="List of individual next steps derived from the interaction")
43
+ summary: str = Field(..., title="Summary", description="Summary of the interaction")
44
+
45
+ #################################################################################
46
+
47
+ # These are the components for Farm Activities, Fields, and Plantings
48
+ class Status(str, Enum):
49
+ ACTIVE = 'active'
50
+ ARCHIVED = 'archived'
51
+
52
+ # Depending on how well this works, come back and hard-code this based on some parameter(s)
53
+ class Convention(str, Enum):
54
+ ACTIVITY = 'log--activity'
55
+ OBSERVATION = 'log--observation'
56
+ FLAMING = 'log--activity--flaming'
57
+ GRAZING = 'log--activity--grazing'
58
+ MOWING = 'log--activity--mowing'
59
+ SOLARIZATION = 'log--activity--solarization'
60
+ TERMINATION = 'log--activity--termination'
61
+ TILLAGE = 'log--activity--tillage'
62
+ HARVEST = 'log--activity--harvest'
63
+ HERBICIDE = 'log--input--herbicide_or_pesticide'
64
+ IRRIGATION = 'log--input--irrigation'
65
+ LIME = 'log--input--lime'
66
+ ORGANIC = 'log--input--organic_matter'
67
+ SEEDTREAT = 'log--input--seed_treatment'
68
+ SEEDLINGTREAT = 'log--input--seedling_treatment'
69
+ MODUS = 'log--lab_test--modus_lab_test'
70
+ SEEDING = 'log--seeding--seeding'
71
+ TRANSPLANT = 'log--transplanting--transplant'
72
+
73
+ class Structure(str, Enum):
74
+ CLAY = 'clay'
75
+ SANDYCLAY = 'sandy clay'
76
+ SILTYCLAY = 'silty clay'
77
+ SANDYCLAYLOAM = 'sandy clay loam'
78
+ SILYCLAMLOAM = 'silty clay loam'
79
+ CLAYLOAM = 'clay loam'
80
+ SANDYLOAM = 'sandy loam'
81
+ SILTLOAM = 'silt loam'
82
+ LOAM = 'loam'
83
+ LOAMYSAND = 'loamy sand'
84
+ SAND = 'sand'
85
+ SILT = 'silt'
86
+
87
+ class Log(BaseModel):
88
+ convention: Convention = Field(..., title="Logs", description="This log's convention (i.e. this log's category or type)")
89
+ date: str = Field(..., title="Date", description="Date the log (i.e. action of the activity or input) was performed")
90
+ description: str = Field(..., title="Description", description="A description of the details of the log (i.e. details about farm activity performed")
91
+
92
+ class Soil(BaseModel):
93
+ description: str = Field(..., title="Description", description="A general description of the soil")
94
+ structure: List[Structure] = Field(..., title="Structure", description="The structure of the soil using options from the major soil texture classes (sand, clay, silt)")
95
+ biology: str = Field(..., title="Biology", description="Biological activity levels of the soil, including fluffiness, worms and bugs, and other evidence of soil biological activity")
96
+
97
+ class Yield(BaseModel):
98
+ quantity: str = Field(..., title="Quantity", description="A description of the total yield (harvested amount) from this planting, including units when available")
99
+ 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.")
100
+
101
+ # It breaks if soil and yield aren't lists for some reason
102
+ class Planting(BaseModel):
103
+ name: str = Field(..., title="Name", description="The name of the planting")
104
+ 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)")
105
+ crop: List[str] = Field(..., title="Crop", description="A list of the crops in this planting")
106
+ variety: List[str] = Field(..., title="Variety", description="A list of the crop varieties in this planting")
107
+ logs: List[Log] = Field(..., title="Logs", description="A list of all the logs that are associated with the farm activities")
108
+ soil: List[Soil] = Field(..., title="Soil", description="A single soil profile for this planting, containing only one soil description")
109
+ yield_: List[Yield] = Field(..., title="Yield", description="One set of quantitative and qualitative yield observations for this planting")
110
+
111
+ class FarmActivities(BaseModel):
112
+ name: str = Field(..., title="Name", description="The name of the agricultural field.")
113
+ description: str = Field(..., title="Description", description="The description of the agricultural field.")
114
+ plantings: List[Planting] = Field(..., title="Plantings", description="All of the plantings which have occurred on this field.")
115
+
116
+ # These are extra for the modular approach
117
+ class FarmActivitiesLite(BaseModel):
118
+ name: str = Field(..., title="Name", description="The name of the agricultural field.")
119
+ description: str = Field(..., title="Description", description="The description of the agricultural field.")
120
+
121
+ class PlantingLite(BaseModel):
122
+ name: str = Field(..., title="Name", description="The name of the planting")
123
+ 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)")
124
+ crop: List[str] = Field(..., title="Crop", description="A list of the crops in this planting")
125
+ variety: List[str] = Field(..., title="Variety", description="A list of the crop varieties in this planting")
126
+