Skip to main content

SRA

Version License Python Status Format Wheel Build Coverage Downloads


SPARK-REST-API

Async wrapper for Spark REST API. See more in documentation

INSTALL

pip install spark-rest-api

USAGE

import asyncio
import io
import zipfile
import aiohttp
import pandas as pd
from spark_rest_api import SparkRestApi


sra = SparkRestApi(spark_host="https://<host>:<port>")
sra.show_templates()


async def main(sra):
    base_app_id = "application_XXXXXXXXXXXXX_XXXXXX"
    async with aiohttp.ClientSession() as session:
        resp = (
            await sra.execute(
                session=session,
                url=sra.render_url(template_id=0)
            )
        )
        assert resp.status == 200
        df = resp.to_df()
        attempts = df[df["id"] == base_app_id].attempts.tolist()
        if attempts:
            urls = map(
                lambda x: sra.render_url(3, app_id=f"{base_app_id}/{x['attemptId']}"),
                attempts[0]
                )
            df_result = pd.concat(
                map(
                    lambda x: x.to_df(),
                    (
                        await asyncio.gather(*(sra.execute(session, url) for url in urls))
                        )
                    )
                )
            print(df_result)


        log_data = await sra.execute(session, sra.render_url(template_id=13, base_app_id=base_app_id))
        with zipfile.ZipFile(io.BytesIO(log_data.raw), "r") as zip_file:
            for f in zip_file.infolist():
                print(zip_file.read(f).decode())


loop = asyncio.get_event_loop()
loop.run_until_complete(main(sra))

Metadata

Release files for spark-rest-api 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spark-rest-api 0.0.0
File Size Uploaded Provenance Actions
spark-rest-api-0.0.0.tar.gz 9.9 kB Without provenance Details for spark-rest-api-0.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spark-rest-api 0.0.0
File Interpreter ABI Platform Actions
spark_rest_api-0.0.0-py3-none-any.whl Python 3 none any Details for spark_rest_api-0.0.0-py3-none-any.whl

Total release size: 19.0 kB

Release files / spark-rest-api-0.0.0.tar.gz

Download URL spark-rest-api-0.0.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9e0e3367390aba4050a067903dbe41b654a6856eaf782dd68bb7ddc12781da6c
BLAKE2b-256 checksum
How to use checksums
f6e4dbd44f19dc7fc134132b3fa88b0806afcad341dfb57bf5451a2fe4110cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / spark_rest_api-0.0.0-py3-none-any.whl

Download URL spark_rest_api-0.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c138d8cbfa71e02f6c67d8baa18cc8eec11aa29969c1936dc7cd7fd1e232f57
BLAKE2b-256 checksum
How to use checksums
269a5cc0901193c645e482efd89687d183deac5cad1ada7360ab738253646e07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Security for spark-rest-api 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page