Skip to main content

No project description provided

Project description

AsyncGraphs

AsyncGraphs is a tiny ETL framework that leverages asyncio to make the execution more efficient.

Installation

pip install asyncgraphs

Basic usage

import asyncio
import datetime
from random import random

import pytz
from asyncgraphs import Graph, run


async def my_extract():
    while True:
        await asyncio.sleep(1)
        yield {"timestamp": datetime.datetime.now(tz=pytz.UTC), "value": random()}


def my_transform(in_doc):
    if in_doc["value"] < 0.5:
        in_doc["value"] = None
    return in_doc


class MyForwardFill:
    def __init__(self):
        self.last_value = None

    def __call__(self, in_doc):
        if in_doc["value"] is None:
            in_doc["value"] = self.last_value
        else:
            self.last_value = in_doc["value"]
        return in_doc


async def main():
    g = Graph()
    g | my_extract() | my_transform | MyForwardFill() | print
    await run(g)

if __name__ == '__main__':
    asyncio.run(main())

The example above shows some dummy extract/transform/load steps. In the example most are synchronous, but regular applications should use async libraries as often as possible.

Project details


Download files

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

Source Distribution

asyncgraphs-0.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

asyncgraphs-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file asyncgraphs-0.0.2.tar.gz.

File metadata

  • Download URL: asyncgraphs-0.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for asyncgraphs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 16b18e035079db219e028ddc41726e33c376eca5a17081a4c04568d0a576d32c
MD5 1adce5caeb0d1d6c2664be6cbb8134f3
BLAKE2b-256 5bd9930a3942176f1b7c5a0c93a62546d55fff542c24d52e079d603529bfd392

See more details on using hashes here.

File details

Details for the file asyncgraphs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: asyncgraphs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for asyncgraphs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d35cd1c6279bf0ad2f1262471abebb407c4223d1ade8fe4660a03ba5ea2f728
MD5 7f3220c6b2739412d533e8c353f43156
BLAKE2b-256 f3ff0a2934210311319edd9af101e0c9a1790ccbc2db55faa76a6e84c27e0c71

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