Current collected state Current
Observed since 20 Oct, 18:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
achain
Library used for chaining together synchronous and asynchronous functions for data transformation
Library used for chaining together synchronous and asynchronous functions for data transformation
The achain.Chain class allows for the construction of chained synchronous and asynchronous functions
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
)
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
pydanticEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.8",
"evaluation": "NOT_EVALUATED"
} | pydantic>=2.8.2 | runtime |
typing-extensionsEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.8",
"evaluation": "NOT_EVALUATED"
} | typing-extensions | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.8",
"evaluation": "NOT_EVALUATED"
} | pytest; extra == "dev" | runtime |
bdist_wheel · 15.52 KB · Python py3
sdist · 15.48 KB · Python source
Observed since 20 Oct, 18:12 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:45f9a3b98e959dca7e5131e634048653e9e247d4d201ba67a0f0f16def30a7bd