Skip to main content

Python client for BugSeq (https://bugseq.com)

Project description

BugSeq Python Client Library

Authentication and client code for interacting with the BugSeq API.

Installation

pip install bugseq-client

Example Usage

from pathlib import Path

import requests

from bugseq_client.auth import (
    DEFAULT_OAUTH_CONFIG,
    Session,
    get_default_credential_storage_provider,
)
import bugseq_client.openapi_client


def download_url_to_file(download_url: str, filename: str):
    with requests.get(download_url, stream=True) as r:
        r.raise_for_status()
        with open(filename, "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                if chunk:  # filter out keep-alive chunks
                    f.write(chunk)


class App:
    def __init__(self):
        storage = get_default_credential_storage_provider()
        self.session = Session(DEFAULT_OAUTH_CONFIG, storage)

    def run(self):
        token = self.session.get_token()

        configuration = bugseq_client.openapi_client.Configuration(
            host="https://api.bugseq.com",
            access_token=token,
        )

        with bugseq_client.openapi_client.ApiClient(configuration) as api_client:
            api = bugseq_client.openapi_client.JobsApi(api_client)

            print("fetching jobs")
            jobs_resp = api.list_analyses_v1_jobs_get()
            for job in jobs_resp.job_runs:
                print(
                    f"id={job.id} name={job.user_provided_name} status={job.job_status}"
                )

            print()

            job_id = jobs_resp.job_runs[0].id
            print(f"fetching outputs for job {job_id}")

            results_dir = Path(f"downloaded-results-{job_id}")

            results_resp = api.get_analysis_results_v1_jobs_job_id_results_get(job_id)
            for output in results_resp.outputs:
                print(f"  output filename={output.filename} size={output.size}")

                download_resp = (
                    api.download_analysis_result_v1_jobs_job_id_results_download_get(
                        job_id, output.filename
                    )
                )

                download_dst = results_dir / output.filename
                download_dst.parent.mkdir(exist_ok=True)
                download_url_to_file(download_resp.url, download_dst)
                print(
                    f"  downloaded filename={output.filename} dst={str(download_dst)}"
                )


def main():
    app = App()
    app.run()


if __name__ == "__main__":
    main()

Releasing to PyPI

docker run -it --rm \
    -v "$(pwd)":/work \
    -w /work \
    python:3.13 \
    bash
rm -rf dist/*
python3 -m pip install --upgrade build twine
python3 -m build
python3 -m twine upload --repository testpypi dist/*

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

bugseq_client-0.1.4.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bugseq_client-0.1.4-py3-none-any.whl (126.3 kB view details)

Uploaded Python 3

File details

Details for the file bugseq_client-0.1.4.tar.gz.

File metadata

  • Download URL: bugseq_client-0.1.4.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for bugseq_client-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2d1cd220916a45f008556cdc27b2fbcd832024acb83a1770c9da03515c7c1715
MD5 5a6ecadc7c9c8f91a9f6d37aa040b4b3
BLAKE2b-256 89930441d90d417515e9dac49d0a36a5aa45949e5b21746d1fe49c92f6377ec0

See more details on using hashes here.

File details

Details for the file bugseq_client-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: bugseq_client-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 126.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for bugseq_client-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8959aee714c0c07e47be81b8b1b600fcf938da7e3c095d43d1a82d88fcf047a6
MD5 6908d3cbc4563dfc45d8c1e0ba4b9c4e
BLAKE2b-256 a36855525a3150f1aea8ea30ef65c462e97ca0f3e4326b13d214c10dee584604

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page