Catalog PyPI
Back to packageRELEASE DETAILS

0.1.1

PyPI

achain

Library used for chaining together synchronous and asynchronous functions for data transformation

Published29 Aug 2024
Direct dependencies3
Transitive dependenciesNot calculated

README

Version 0.1.1 documentation

aChain

Library used for chaining together synchronous and asynchronous functions for data transformation

What does this do?

The achain.Chain class allows for the construction of chained synchronous and asynchronous functions

Example:

import typing
import json
from datetime import datetime, timedelta

from achain import Chain

SERVICE_URL = "https://www.service.com/api"
"""The address of some service containing data of interest"""

async def get_data(url, **kwargs) -> str:
    """
    Gets raw text from the given URL with the given query parameters
    """
    ...

def normalize_data(
    data: typing.Dict[str, typing.Any]
) -> typing.Dict[str, typing.Dict[str, typing.Any]]:
    """
    Transforms the passed data into one that is easier to deserialize
    """
    ...

class ExampleClass:
    """
    An example of a class that may be constructed from the generated data
    """
    def __init__(self, **kwargs):
        """Constructor"""
        ...

async def main():
    """
    Create lists of remote data
    """
    # Declare your chain
    chain: Chain[typing.List[ExampleClass]] = Chain(
        get_data,
        url=SERVICE_URL
    ).then(
        json.loads
    ).then(
        normalize_data
    ).then(
        lambda data: [ExampleClass(**values) for values in data.values()]
    )
    
    # Call Asynchronously
    yesterdays_data: typing.List[ExampleClass] = await chain(
        start=datetime.now() - timedelta(hours=48),
        end=datetime.now() - timedelta(hours=24)
    )

    # Call Synchronously
    todays_data: typing.List[ExampleClass] = chain.execute_synchronously(
        start=datetime.now() - timedelta(hours=24),
        end=datetime.now
    )

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
pydantic>=2.8.2runtime
typing-extensions
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
typing-extensionsruntime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "dev"runtime

Distribution files

2 collected
achain-0.1.1-py3-none-any.whl

bdist_wheel · 15.52 KB · Python py3

Source file
achain-0.1.1.tar.gz

sdist · 15.48 KB · Python source

Source file

Repository

PENDING
christophertubbs/achain

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:12 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:45f9a3b98e959dca7e5131e634048653e9e247d4d201ba67a0f0f16def30a7bd

Other collected versions

View all collected versions →