This library provides a wrapper to the Evolve App Server's API, allowing users of the Evolve SDK to authenticate with the Evolve App Server and upload studies.
from geojson import FeatureCollection
from src.zepben.eas import EasClient, StudyInput, StudyResultInput, GeoJsonOverlayInput, ResultSectionInput,
SectionType, Mutation
eas_client = EasClient(
host="<host>",
port=1234,
access_token="<access_token>",
asynchronous=False,
)
eas_client.mutation(
Mutation.add_studies(
[
StudyInput(
name="<study name>",
description="<study description>",
tags=["<tag>", "<tag2>"],
results=[
StudyResultInput(
name="<result_name>",
geoJsonOverlay=GeoJsonOverlayInput(
data=FeatureCollection(...),
styles=["style1"]
),
sections=[
ResultSectionInput(
type=SectionType.TABLE,
name="<table name>",
description="<table description>",
columns=[
{"key": "<column 1 key>", "name": "<column 1 name>"},
{"key": "<column 2 key>", "name": "<column 2 name>"},
],
data=[
{"<column 1 key>": "<column 1 row 1 value>",
"<column 2 key>": "<column 2 row 1 value>"},
{"<column 1 key>": "<column 1 row 2 value>",
"<column 2 key>": "<column 2 row 2 value>"}
]
)
]
)
],
styles=[
{
"id": "style1",
# other Mapbox GL JS style properties
}
]
)
]
)
)
eas_client.close()The EasClient can operate in async mode if specified, like so:
from aiohttp import ClientSession
from geojson import FeatureCollection
from src.zepben.eas import EasClient, StudyInput, StudyResultInput, GeoJsonOverlayInput, ResultSectionInput,
SectionType, Mutation
async def upload():
eas_client = EasClient(
host="<host>",
port=1234,
access_token="<access_token>",
asynchronous=True, # returns all methods as plain async methods
)
await eas_client.mutation(
Mutation.add_studies(
[
StudyInput(
name="<study name>",
description="<study description>",
tags=["<tag>", "<tag2>"],
results=[
StudyResultInput(
name="<result_name>",
geoJsonOverlay=GeoJsonOverlayInput(
data=FeatureCollection(...),
styles=["style1"]
),
sections=[
ResultSectionInput(
type=SectionType.TABLE,
name="<table name>",
description="<table description>",
columns=[
{"key": "<column 1 key>", "name": "<column 1 name>"},
{"key": "<column 2 key>", "name": "<column 2 name>"},
],
data=[
{"<column 1 key>": "<column 1 row 1 value>",
"<column 2 key>": "<column 2 row 1 value>"},
{"<column 1 key>": "<column 1 row 2 value>",
"<column 2 key>": "<column 2 row 2 value>"}
]
)
]
)
],
styles=[
{
"id": "style1",
# other Mapbox GL JS style properties
}
]
)
]
)
)
await eas_client.close()To regenerate the graphql client, run the following command
docker compose run codegenIf you have done any of the following, you will need to regenerate the docker image if testing locally.
- Made changes to anything that affects the python package
- Changed anything under
ariadne_plugins
docker build .