Metadata-Version: 2.4
Name: zepben.eas
Version: 2.14.0
Summary: Python SDK for interacting with the Evolve App Server
Author-email: Ramon Bouckaert <ramon.bouckaert@zepben.com>, Max Chesterfield <max.chesterfield@zepben.com>
License-Expression: MPL-2.0
Project-URL: Repository, https://github.com/zepben/eas-python-client
Project-URL: Homepage, https://zepben.com
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: geojson==2.5.0
Requires-Dist: httpx==0.28.1
Requires-Dist: graphql-core==3.2.8
Requires-Dist: pydantic
Requires-Dist: pydantic_core
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-asyncio; extra == "test"
Requires-Dist: pytest-httpserver==1.0.8; extra == "test"
Requires-Dist: trustme==0.9.0; extra == "test"
Provides-Extra: codegen
Requires-Dist: ariadne-codegen==0.18.0; extra == "codegen"
Requires-Dist: click; extra == "codegen"
Dynamic: license-file

# 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 #

```python
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()
```

## AsyncIO ##
The EasClient can operate in async mode if specified, like so:

```python
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()
```

# I'm used to the old client, what do i do? #

## Migrating existing code ##

Most of the objects passed into requests are similar.
The new EasClient is fully type hinted and self documenting.

For example.

```python
from src.zepben.eas import EasClient, WorkPackageInput, HcExecutorConfigInput, FeederConfigsInput, FeederConfigInput

client = EasClient(host='host', port=1234)
client.get_work_package_cost_estimation(
    WorkPackageInput(
        feederConfigs=FeederConfigsInput(
            configs=[
                FeederConfigInput(
                    feeder='myFeeder',
                    years=[2024, 2025],
                    scenarios=['scenario1']
                )
            ]
        )
    )
)
```

Hovering over any kwarg or looking at any class definition will show all possible parameters, and their expected types.

## Enabling legacy convenience methods ##

Legacy convenience methods can be enabled by passing `enable_legacy_methods` to `__init__` of `EasClient`. eg:

```python
from src.zepben.eas import EasClient

client = EasClient(enable_legacy_methods=True)
```

This will enable all `deprecated` and `opt_in` methods on the class, they are disabled by default.

# Development #

To regenerate the graphql client, run the following command

```shell
docker compose run codegen
```

If 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`

```shell
docker build .
```
