Skip to main content

Python SDK for interacting with the Evolve App Server

Project description

Evolve App Server Python Client

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.

Usage

from geojson import FeatureCollection
from zepben.eas import EasClient, Study, Result, Section, GeoJsonOverlay

eas_client = EasClient(
    host="<host>",
    port=1234,
    client_id="<client_id>",
    username="<username>",
    password="<password>",
    client_secret="<client_secret>"
)

eas_client.upload_study(
    Study(
        name="<study name>",
        description="<study description>",
        tags=["<tag>", "<tag2>"],
        results=[
            Result(
                name="<result_name>",
                geo_json_overlay=GeoJsonOverlay(
                    data=FeatureCollection( ... ),
                    styles=["style1"]
                ),
                sections=Section(
                    type="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()

AsyncIO

Asyncio is also supported using aiohttp. A session will be created for you when you create an EasClient if not provided via the session parameter to EasClient.

To use the asyncio API use async_upload_study like so:

from aiohttp import ClientSession
from geojson import FeatureCollection
from zepben.eas import EasClient, Study, Result, Section, GeoJsonOverlay

async def upload():
    eas_client = EasClient(
        host="<host>",
        port=1234,
        client_id="<client_id>",
        username="<username>",
        password="<password>",
        client_secret="<client_secret>",
        session=ClientSession(...)
    )

    await eas_client.async_upload_study(
        Study(
            name="<study name>",
            description="<study description>",
            tags=["<tag>", "<tag2>"],
            results=[
                Result(
                    name="<result_name>",
                    geo_json_overlay=GeoJsonOverlay(
                        data=FeatureCollection( ... ),
                        styles=["style1"]
                    ),
                    sections=Section(
                        type="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.aclose()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

zepben.eas-0.16.0b1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file zepben.eas-0.16.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for zepben.eas-0.16.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a7aa79e3bd84370cf1e263d4e73654e6f0ca7677412e9a58945becb06feaaa
MD5 2366591d3effc5a54088d19bc30aacc9
BLAKE2b-256 da73f95b2250e1bcc7d6fe6cb175cb1610d29b9954fcab74dd7fdb3b976359a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page