Skip to main content

Prefect integrations for interacting with Hightouch.

Project description

prefect-hightouch

PyPI

Welcome!

Prefect integrations for interacting with Hightouch.

Getting Started

Python setup

Requires an installation of Python 3.7+.

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.

Installation

Install prefect-hightouch with pip:

pip install prefect-hightouch

Then, register to view the block on Prefect Cloud:

prefect block register -m prefect_hightouch.credentials

Note, to use the load method on Blocks, you must already have a block document saved through code or saved through the UI.

Trigger a sync run and wait for completion

from prefect import flow
from prefect_hightouch import HightouchCredentials
from prefect_hightouch.syncs import trigger_sync_run_and_wait_for_completion
@flow
def sync_flow():
    hightouch_credentials = HightouchCredentials.load("hightouch-token")
    sync_metadata = trigger_sync_run_and_wait_for_completion(
        hightouch_credentials=hightouch_credentials,
        sync_id=12345,
        full_resync=True,
        max_wait_seconds=1800,
        poll_frequency_seconds=10,
    )
    return sync_metadata
sync_flow()

List, get, and trigger syncs

from prefect import flow
from prefect_hightouch import HightouchCredentials, api_models
from prefect_hightouch.syncs import (
    list_sync,
    get_sync,
    list_sync_runs,
    trigger_run,
    trigger_run_custom,
)

@flow
def hightouch_sync_flow():
    hightouch_credentials = HightouchCredentials.load("hightouch-token")

    # list all syncs
    syncs = list_sync(
        hightouch_credentials, order_by=api_models.ListSyncOrderBy.CREATEDAT
    )

    # get first sync
    sync_id = syncs[0].id
    sync = get_sync(hightouch_credentials, sync_id)

    # list previous runs
    sync_runs = list_sync_runs(hightouch_credentials, sync_id)

    # trigger by id
    sync_run = trigger_run(
        hightouch_credentials,
        sync_id,
        json_body=api_models.TriggerRunInput(full_resync=False),
    )

    # trigger by slug
    sync_slug = syncs[0].slug
    sync_run_2 = trigger_run_custom(
        hightouch_credentials,
        json_body=api_models.TriggerRunCustomInput(
            sync_slug=sync_slug,
            full_resync=False,
        ),
    )
    return sync_runs

hightouch_sync_flow()

Call API endpoints

If an API endpoint is not exposed as a task, you can call the underlying API endpoint functions, but note, these are not Prefect tasks.

from prefect_hightouch.credentials import HightouchCredentials
from prefect_hightouch.api_client.api.default import list_destination

credentials = HightouchCredentials.load(token="my-service-token")
client = credentials.get_client()
response = list_destination.sync_detailed(client=client)
data = response.parsed.data

Resources

If you encounter any bugs while using prefect-hightouch, feel free to open an issue in the prefect-hightouch repository.

If you have any questions or issues while using prefect-hightouch, you can find help in either the Prefect Discourse forum or the Prefect Slack community.

Feel free to ⭐️ or watch prefect-hightouch for updates too!

Development

If you'd like to install a version of prefect-hightouch for development, clone the repository and perform an editable install with pip:

git clone https://github.com/PrefectHQ/prefect-hightouch.git

cd prefect-hightouch/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install

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

prefect-hightouch-0.1.0.post2.tar.gz (49.1 kB view details)

Uploaded Source

Built Distribution

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

prefect_hightouch-0.1.0.post2-py3-none-any.whl (79.5 kB view details)

Uploaded Python 3

File details

Details for the file prefect-hightouch-0.1.0.post2.tar.gz.

File metadata

  • Download URL: prefect-hightouch-0.1.0.post2.tar.gz
  • Upload date:
  • Size: 49.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for prefect-hightouch-0.1.0.post2.tar.gz
Algorithm Hash digest
SHA256 39744c2d715e2ca522f0bf99e31085d0b80185030cd7a25a20abcc91cb8adb15
MD5 c19f73afbaeacc126abb6180cfe704b5
BLAKE2b-256 7d56c4cd309343f408cb9a0d6c7aa9200abb26001840d79dba814d1dab4928cb

See more details on using hashes here.

File details

Details for the file prefect_hightouch-0.1.0.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for prefect_hightouch-0.1.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0626f0a097f6866d4b6b4e494c890389e57f238546e0651d3068e7c8df1f138
MD5 bcfa21d0c905b9deb27d4d857dab2391
BLAKE2b-256 44c1c38e98d819fcafe0459300b3adae43b8b9e39c46526cf0db98117a3bfbfb

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