Skip to main content

A Python interface for the Daisi Platform

Project description

Simples steps for using the PyDaisi SDK

Preliminary tasks

Install with PIP:

  • pip install pydaisi

(Optional) Set your personal access token:

Create your personal access token

Set it in the environment:

export DAISI_ACCESS_TOKEN=a1b2c3d4e5f67890abcdef124567890

or in a .env file:

DAISI_ACCESS_TOKEN=a1b2c3d4e5f67890abcdef124567890

Using PyDaisi

Normal calls

You can call the Daisi function, it will run until complete, and the result will be available in the value attribute when it has returned.

from pydaisi import Daisi

# instantiate a Daisi object
daisi = Daisi("my-pebble-tutorial")
# call a Daisi function. You can also use positional parameters: daisi.median("London")
temp = daisi.median(city="London")
print(f"Median temperature in London was: {temp.value}")
print(f"Mean temperature in Amsterdam was: {daisi.mean('Amsterdam')}.value")

Async calls

You can also use Python asyncio functions to create and dispatch many calls asynchronously.

from pydaisi import Daisi
import asyncio

async def callmany()
    calls = []
    # sets up a call, but does not execute
    with Daisi("my-pebble-tutorial") as daisi:
        calls.append(daisi.defer.mean("Paris").fetch_result())
        calls.append(daisi.defer.mean("London").fetch_result())
        calls.append(daisi.defer.mean("Amsterdam").fetch_result())
        await asyncio.gather(calls)

Parallel Execution

You may also use helper functions to execute many calls from your synchronous code

from pydaisi import Daisi

with Daisi('my_daisi_name`) as my_daisi:
    calls = []
    calls.append(my_daisi.endpoint1_(**kwargs))
    calls.append(my_daisi.endpoint2_(**kwargs))
    calls.append(my_daisi.endpoint3_(**kwargs))
    print(Daisi.parallel_run(*calls))

Project details


Release history Release notifications | RSS feed

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

pydaisi-0.2.4.6-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file pydaisi-0.2.4.6-py3-none-any.whl.

File metadata

  • Download URL: pydaisi-0.2.4.6-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.0

File hashes

Hashes for pydaisi-0.2.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 970bb4cff3681f78481131f58a40d053246f498f287f406f628c6df65a77db7b
MD5 a703cd2452a42da14120bc99299b60d8
BLAKE2b-256 96139119fa0c17a7f3c6aec42051abfdab64385d38d2df80a0e39cd5aac18572

See more details on using hashes here.

Provenance

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