Skip to main content

prefect-hex

Visit the full docs here to see additional examples and the API reference.

PyPI

Welcome!

Prefect integrations for interacting with Hex.

Hex is a powerful platform for collaborative data science and analytics. For information getting started with Hex, check out Hex's quickstart guide.

The tasks within this collection were created by a code generator using Hex's OpenAPI spec.

Hex's REST API documentation can be found here.

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-hex with pip:

pip install prefect-hex

A list of available blocks in prefect-hex and their setup instructions can be found here.

Gather and store authentication

  1. Create new token on https://app.hex.tech/ Settings page:

image

  1. Store token on https://app.prefect.cloud/ Blocks page:

image

  1. Copy project ID from browser URL (in red):

image

Write and run a flow

Trigger a Hex project run and wait for completion

from prefect import flow
from prefect_hex import HexCredentials
from prefect_hex.project import trigger_project_run_and_wait_for_completion

@flow
def trigger_project_run_and_wait_for_completion_flow(project_id: str):
    hex_credentials = HexCredentials.load("hex-token")
    project_metadata = trigger_project_run_and_wait_for_completion(
        project_id=project_id,
        hex_credentials=hex_credentials
    )
    return project_metadata

trigger_project_run_and_wait_for_completion_flow(
    project_id="012345c6-b67c-1234-1b2c-66e4ad07b9f3"
)

Run project, get status, cancel run, and get list of projects

from prefect import flow
from prefect_hex import HexCredentials
from prefect_hex.project import (
    get_project_runs,
    run_project,
    get_run_status,
    cancel_run,
)

@flow
def example_hex_flow():
    # load stored credentials
    hex_credentials = HexCredentials.load("hex-token")

    # run project
    project_id='5a8591dd-4039-49df-9202-96385ba3eff8',
    project_run = run_project(project_id=project_id, hex_credentials=hex_credentials)

    # get status
    run_id = project_run.run_id
    project_run_status = get_run_status(
        project_id=project_id, run_id=run_id, hex_credentials=hex_credentials
    )
    print(project_run_status.run_url)

    # cancel run if needed
    cancel_run(project_id=project_id, run_id=run_id, hex_credentials=hex_credentials)

    # get list of project runs
    project_runs = get_project_runs(
        project_id=project_id, hex_credentials=hex_credentials
    )

    return project_runs

example_hex_flow()

For more tips on how to use tasks and flows in a Collection, check out Using Collections!

Resources

Blog Posts

Videos

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

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

Feel free to star or watch prefect-hex for updates too!

Contributing

-```bash -git clone https://github.com/PrefectHQ/prefect-hex.git If you'd like to help contribute to fix an issue or add a feature to prefect-hex, please propose changes through a pull request from a fork of the repository.

-cd prefect-hex/ Here are the steps:

  1. Fork the repository
  2. Clone the forked repository
  3. Install the repository and its dependencies:
 pip install -e ".[dev]"
  1. Make desired changes
  2. Add tests
  3. Insert an entry to CHANGELOG.md
  4. Install pre-commit to perform quality checks prior to commit:
 pre-commit install
  1. git commit, git push, and create a pull request install

Metadata

Release files for prefect-hex 0.2.1

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

Source distribution (sdist)

Source distribution for prefect-hex 0.2.1
File Size Uploaded
prefect-hex-0.2.1.tar.gz 36.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prefect-hex 0.2.1
File Interpreter ABI Platform
prefect_hex-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 53.0 kB

Release files / prefect-hex-0.2.1.tar.gz

Download URL prefect-hex-0.2.1.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1fcbab1b3b6b858afe9d272a57e7e0fe776c7f6a24b423d5f3acd707ed8d3827
BLAKE2b-256 checksum
How to use checksums
2ce9d29503dd63e7d3d4e9ecf7075288f10fcb7c7851de4e2bfda9f524b0f456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / prefect_hex-0.2.1-py3-none-any.whl

Download URL prefect_hex-0.2.1-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f7f23931cb2aaf953132a8cce0d1fa1e5bb07b6ede2e66fa42b0d2aed6bad85
BLAKE2b-256 checksum
How to use checksums
f7a53373601d3ca197cd28b6684945bd581c5ee4b6d04583912203efa2c1d472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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