Skip to content

Commit 4a8c056

Browse files
Agrifood/test infra (Azure#18779)
1 parent 66dd15e commit 4a8c056

28 files changed

+4506
-359
lines changed

sdk/agrifood/azure-agrifood-farming/README.md

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,148 @@ client = FarmBeatsClient(endpoint="https://<my-account-name>.farmbeats.azure.net
4747

4848
## Examples
4949

50-
The following section shows you how to initialize and authenticate your client, then get all of your type-defs.
50+
### Create a Farmer
51+
Once you have authenticated and created the client object as shown in the [Authenticate the client](#authenticate-the-client)
52+
section, you can create a farmer within the FarmBeats resource like this:
53+
54+
```python
55+
from azure.agrifood.farming.models import Farmer
56+
57+
farmer = client.farmers.create_or_update(
58+
farmer_id="farmer-1",
59+
body=Farmer(
60+
name="Contoso Farmer",
61+
description="Your custom farmer description here",
62+
status="Active",
63+
properties={
64+
"your-custom-key": "queryable value",
65+
}
66+
)
67+
)
68+
```
69+
70+
### Create a Farm
71+
72+
73+
```python
74+
from azure.agrifood.farming.models import Farm
75+
76+
farm = client.farms.create_or_update(
77+
farmer_id=farmer.id,
78+
farm_id="farm-1",
79+
body=Farm(
80+
name="Contoso Westlake Farm",
81+
properties={
82+
"location": "Westlake",
83+
"country": "USA"
84+
}
85+
)
86+
)
87+
```
88+
89+
### Create a Season
90+
91+
```python
92+
from azure.agrifood.farming.models import Season
93+
from isodate.tzinfo import Utc
94+
from datetime import datetime
95+
96+
season = client.seasons.create_or_update(
97+
season_id="season-summer-2021",
98+
body=Season(
99+
start_date_time=datetime(2021, 4, 1, tzinfo=Utc()),
100+
end_date_time=datetime(2021, 8, 31, tzinfo=Utc()),
101+
name="Summer of 2021",
102+
year=2021
103+
)
104+
)
105+
```
106+
107+
### Create a Seasonal Field
108+
109+
```python
110+
from azure.agrifood.farming.models import SeasonalField
111+
112+
seasonal_field = client.seasonal_fields.create_or_update(
113+
farmer_id=farmer.id,
114+
seasonal_field_id="westlake-summer-2021",
115+
body=SeasonalField(
116+
farm_id=farm.id,
117+
season_id=season.id
118+
)
119+
)
120+
```
121+
122+
### Create a Boundary
123+
124+
```python
125+
from azure.agrifood.farming.models import Boundary, Polygon
126+
127+
boundary = client.boundaries.create_or_update(
128+
farmer_id=farmer.id,
129+
boundary_id="westlake-boundary-1",
130+
body=Boundary(
131+
parent_id=seasonal_field.id,
132+
geometry=Polygon(
133+
coordinates=[
134+
[
135+
[73.70457172393799, 20.545385304358106],
136+
[73.70457172393799, 20.545385304358106],
137+
[73.70448589324951, 20.542411534243367],
138+
[73.70877742767334, 20.541688176010233],
139+
[73.71023654937744, 20.545083911372505],
140+
[73.70663166046143, 20.546992723579137],
141+
[73.70457172393799, 20.545385304358106],
142+
]
143+
]
144+
)
145+
)
146+
)
147+
```
148+
149+
### Ingest Satellite Imagery
150+
151+
```python
152+
from isodate.tzinfo import Utc
153+
from datetime import datetime
154+
155+
from azure.agrifood.farming.models import SatelliteData,
156+
157+
# Queue the job
158+
satellite_job_poller = client.scenes.begin_create_satellite_data_ingestion_job(
159+
job_id="westlake-boundary-1-lai-jan2020",
160+
body=SatelliteDataIngestionJob(
161+
farmer_id=farmer.id,
162+
boundary_id=boundary.id,
163+
start_date_time=datetime(2020, 1, 1, tzinfo=Utc()),
164+
end_date_time=datetime(2020, 1, 31, tzinfo=Utc()),
165+
data=SatelliteData(
166+
image_names=[
167+
"LAI"
168+
]
169+
)
170+
)
171+
)
172+
173+
# Wait for the job to terminate
174+
satellite_job = satellite_job_poller.result()
175+
```
176+
177+
### Get Ingested Satellite Scenes
178+
179+
```python
180+
scenes = client.scenes.list(
181+
farmer_id=farmer.id,
182+
boundary_id=boundary.id,
183+
start_date_time=datetime(2020, 1, 1, tzinfo=Utc()),
184+
end_date_time=datetime(2020, 1, 31, tzinfo=Utc()),
185+
)
186+
187+
for scene in scenes:
188+
bands = [image_file.name for image_file in scene.image_files]
189+
bands_str = ", ".join(bands)
190+
print(f"Scene at {scene.scene_date_time} has the bands {bands_str}")
191+
```
51192

52193
## Troubleshooting
53194

sdk/agrifood/azure-agrifood-farming/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
'azure.agrifood',
7979
]),
8080
install_requires=[
81-
"azure-core<2.0.0,>=1.8.2",
81+
"azure-core<2.0.0,>=1.14.0",
8282
"msrest>=0.6.21",
8383
'six>=1.11.0',
8484
],

0 commit comments

Comments
 (0)