Skip to main content

Send custom, realtime logs to Pantomath through the Pantomath Python SDK

Project description

Pantomath SDK

Installation and Setup

  1. Install the Pantomath SDK for Python:

    $ pip install pantomath-sdk
    

    This is the preferred method to install the Pantomath SDK, as it will always install the most recent stable release.

    If you don't have pip installed, this Python installation guide can guide you through the process.

  2. Add configuration ENVs to your runtime:

    PANTOMATH_API_BASE_URL = ******,
    PANTOMATH_API_KEY = ******
    

Example

from pantomath_sdk import PantomathSDK, AstroTask, S3Bucket, SnowflakePipe
from time import sleep

def main():
    # Create an instance of the PantomathSDK
    pantomath_sdk = PantomathSDK(api_key="****")

    # Construct your job
    astro_task = AstroTask(
        name="astro_task_1",
        dag_name="astro_dag_1",
        host_name="astro_host_1"
    )

    # Construct your source and target data sets
    source_data_sets = [
        S3Bucket(s3_bucket="s3://some-bucket-1/file.csv")
    ]

    target_data_sets = [
        SnowflakePipe(
            name="snowpipe_1",
            schema="snowflake_schema_1",
            database="snowflake_database_1",
            port=443,
            host="snowflake_host_1.example.com",
        )
    ]

    # Capture your job run
    job_run = pantomath_sdk.new_job_run(
        job=astro_task,
        source_data_sets=source_data_sets,
        target_data_sets=target_data_sets,
    )
    try:
        job_run.log_start(message="Starting Astro task")
        for i in range(5):
            job_run.log_progress(
                message=f"Completed step {i + 1}",
                records_effected=i * 100
            )
            sleep(2)
    except Exception as e:
        job_run.log_failure(message=e.message)
    finally:
        job_run.log_success(message="Succeeded!")

if __name__ == '__main__':
    main()

Limitations

The SDK will not publish logs to Pantomath until the Job Run has received a success or failure message via a call to log_success() or log_failure(). Therefore, the SDK is unable to trigger any latency incident events within Pantomath.

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

pantomath_sdk-0.4.0.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

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

pantomath_sdk-0.4.0-py3-none-any.whl (55.6 kB view details)

Uploaded Python 3

File details

Details for the file pantomath_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: pantomath_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for pantomath_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0f236f5b6797770c19577dab0f199ff368893757ef6050f21f6713a6d89eaef1
MD5 8a1b962285f0e2010e1548aaadd8ba5b
BLAKE2b-256 8e631bc404fca0c4490c9e9d171dd3927b45b1c477ec64e2f9683e5aa0b614a3

See more details on using hashes here.

File details

Details for the file pantomath_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pantomath_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 55.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for pantomath_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 835a37b6dc1d33082459a32b067a6c895647093c90f80154a8e24b176794af83
MD5 51b34d79ba85fe8a98c65d07a3c7c9cc
BLAKE2b-256 4bb221923c7b01be5a5d1ba7a1eb0b23dd7b67f7af0e5636a3a5a0ef4d54c8bd

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