prefect-hex


Nameprefect-hex JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/PrefectHQ/prefect-hex
SummaryPrefect integrations for interacting with Hex.
upload_time2023-11-13 22:52:21
maintainer
docs_urlNone
authorPrefect Technologies, Inc.
requires_python>=3.7
licenseApache License 2.0
keywords prefect
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # prefect-hex

Visit the full docs [here](https://PrefectHQ.github.io/prefect-hex) to see additional examples and the API reference.

<p align="center">
    <a href="https://pypi.python.org/pypi/prefect-hex/" alt="PyPI version">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-hex?color=0052FF&labelColor=090422"></a>
    <a href="https://github.com/PrefectHQ/prefect-hex/" alt="Stars">
        <img src="https://img.shields.io/github/stars/PrefectHQ/prefect-hex?color=0052FF&labelColor=090422" /></a>
    <a href="https://pepy.tech/badge/prefect-hex/" alt="Downloads">
        <img src="https://img.shields.io/pypi/dm/prefect-hex?color=0052FF&labelColor=090422" /></a>
    <a href="https://github.com/PrefectHQ/prefect-hex/pulse" alt="Activity">
        <img src="https://img.shields.io/github/commit-activity/m/PrefectHQ/prefect-hex?color=0052FF&labelColor=090422" /></a>
    <br>
    <a href="https://prefect-community.slack.com" alt="Slack">
        <img src="https://img.shields.io/badge/slack-join_community-red.svg?color=0052FF&labelColor=090422&logo=slack" /></a>
    <a href="https://discourse.prefect.io/" alt="Discourse">
        <img src="https://img.shields.io/badge/discourse-browse_forum-red.svg?color=0052FF&labelColor=090422&logo=discourse" /></a>
</p>

## 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](https://learn.hex.tech/quickstart).

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](https://learn.hex.tech/docs/develop-logic/hex-api/api-reference).

## 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](https://orion-docs.prefect.io/).

### Installation

Install `prefect-hex` with `pip`:

```bash
pip install prefect-hex
```

A list of available blocks in `prefect-hex` and their setup instructions can be found [here](https://PrefectHQ.github.io/prefect-hex/#blocks-catalog).


### Gather and store authentication

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

![image](https://user-images.githubusercontent.com/15331990/201996947-07765380-50c4-4c61-9044-bd93e4b8efc7.png)

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

![image](https://user-images.githubusercontent.com/15331990/201997292-b3a18254-229f-4689-aaec-07a990cdaf87.png)

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

![image](https://user-images.githubusercontent.com/15331990/202002588-55a895b2-de89-438f-ac96-c86940946336.png)

### Write and run a flow

#### Trigger a Hex project run and wait for completion
```python
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
```python
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](https://orion-docs.prefect.io/collections/usage/)!

## Resources

### Blog Posts

- [Create Observable and Reproducible Notebooks with Hex](https://towardsdatascience.com/create-observable-and-reproducible-notebooks-with-hex-460e75818a09) by Khuyen Tran

### Videos

- [Create Observable and Reproducible Notebooks with Hex: Why Hex (Part 1)](https://youtu.be/_BjqCrun4nE)

If you encounter any bugs while using `prefect-hex`, feel free to open an issue in the [prefect-hex](https://github.com/PrefectHQ/prefect-hex) repository.

If you have any questions or issues while using `prefect-hex`, you can find help in either the [Prefect Discourse forum](https://discourse.prefect.io/) or the [Prefect Slack community](https://prefect.io/slack).

Feel free to star or watch [`prefect-hex`](https://github.com/PrefectHQ/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](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
 
-cd prefect-hex/
Here are the steps:
 
1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)
2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)
3. Install the repository and its dependencies:
```
 pip install -e ".[dev]"
```
4. Make desired changes
5. Add tests
6. Insert an entry to [CHANGELOG.md](https://github.com/PrefectHQ/prefect-hex/blob/main/CHANGELOG.md)
7. Install `pre-commit` to perform quality checks prior to commit:
```
 pre-commit install
 ```
8. `git commit`, `git push`, and create a pull request install

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PrefectHQ/prefect-hex",
    "name": "prefect-hex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "prefect",
    "author": "Prefect Technologies, Inc.",
    "author_email": "help@prefect.io",
    "download_url": "https://files.pythonhosted.org/packages/2c/e9/d29503dd63e7d3d4e9ecf7075288f10fcb7c7851de4e2bfda9f524b0f456/prefect-hex-0.2.1.tar.gz",
    "platform": null,
    "description": "# prefect-hex\n\nVisit the full docs [here](https://PrefectHQ.github.io/prefect-hex) to see additional examples and the API reference.\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/prefect-hex/\" alt=\"PyPI version\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/prefect-hex?color=0052FF&labelColor=090422\"></a>\n    <a href=\"https://github.com/PrefectHQ/prefect-hex/\" alt=\"Stars\">\n        <img src=\"https://img.shields.io/github/stars/PrefectHQ/prefect-hex?color=0052FF&labelColor=090422\" /></a>\n    <a href=\"https://pepy.tech/badge/prefect-hex/\" alt=\"Downloads\">\n        <img src=\"https://img.shields.io/pypi/dm/prefect-hex?color=0052FF&labelColor=090422\" /></a>\n    <a href=\"https://github.com/PrefectHQ/prefect-hex/pulse\" alt=\"Activity\">\n        <img src=\"https://img.shields.io/github/commit-activity/m/PrefectHQ/prefect-hex?color=0052FF&labelColor=090422\" /></a>\n    <br>\n    <a href=\"https://prefect-community.slack.com\" alt=\"Slack\">\n        <img src=\"https://img.shields.io/badge/slack-join_community-red.svg?color=0052FF&labelColor=090422&logo=slack\" /></a>\n    <a href=\"https://discourse.prefect.io/\" alt=\"Discourse\">\n        <img src=\"https://img.shields.io/badge/discourse-browse_forum-red.svg?color=0052FF&labelColor=090422&logo=discourse\" /></a>\n</p>\n\n## Welcome!\n\nPrefect integrations for interacting with Hex. \n\nHex is a powerful platform for collaborative data science and analytics. For information getting started with Hex, check out Hex's [quickstart guide](https://learn.hex.tech/quickstart).\n\nThe tasks within this collection were created by a code generator using Hex's OpenAPI spec.\n\nHex's REST API documentation can be found [here](https://learn.hex.tech/docs/develop-logic/hex-api/api-reference).\n\n## Getting Started\n\n### Python setup\n\nRequires an installation of Python 3.7+.\n\nWe recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.\n\nThese tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the [Prefect documentation](https://orion-docs.prefect.io/).\n\n### Installation\n\nInstall `prefect-hex` with `pip`:\n\n```bash\npip install prefect-hex\n```\n\nA list of available blocks in `prefect-hex` and their setup instructions can be found [here](https://PrefectHQ.github.io/prefect-hex/#blocks-catalog).\n\n\n### Gather and store authentication\n\n1. Create new token on https://app.hex.tech/ Settings page:\n\n![image](https://user-images.githubusercontent.com/15331990/201996947-07765380-50c4-4c61-9044-bd93e4b8efc7.png)\n\n2. Store token on https://app.prefect.cloud/ Blocks page:\n\n![image](https://user-images.githubusercontent.com/15331990/201997292-b3a18254-229f-4689-aaec-07a990cdaf87.png)\n\n3. Copy project ID from browser URL (in red):\n\n![image](https://user-images.githubusercontent.com/15331990/202002588-55a895b2-de89-438f-ac96-c86940946336.png)\n\n### Write and run a flow\n\n#### Trigger a Hex project run and wait for completion\n```python\nfrom prefect import flow\nfrom prefect_hex import HexCredentials\nfrom prefect_hex.project import trigger_project_run_and_wait_for_completion\n\n@flow\ndef trigger_project_run_and_wait_for_completion_flow(project_id: str):\n    hex_credentials = HexCredentials.load(\"hex-token\")\n    project_metadata = trigger_project_run_and_wait_for_completion(\n        project_id=project_id,\n        hex_credentials=hex_credentials\n    )\n    return project_metadata\n\ntrigger_project_run_and_wait_for_completion_flow(\n    project_id=\"012345c6-b67c-1234-1b2c-66e4ad07b9f3\"\n)\n```\n\n#### Run project, get status, cancel run, and get list of projects\n```python\nfrom prefect import flow\nfrom prefect_hex import HexCredentials\nfrom prefect_hex.project import (\n    get_project_runs,\n    run_project,\n    get_run_status,\n    cancel_run,\n)\n\n@flow\ndef example_hex_flow():\n    # load stored credentials\n    hex_credentials = HexCredentials.load(\"hex-token\")\n\n    # run project\n    project_id='5a8591dd-4039-49df-9202-96385ba3eff8',\n    project_run = run_project(project_id=project_id, hex_credentials=hex_credentials)\n\n    # get status\n    run_id = project_run.run_id\n    project_run_status = get_run_status(\n        project_id=project_id, run_id=run_id, hex_credentials=hex_credentials\n    )\n    print(project_run_status.run_url)\n\n    # cancel run if needed\n    cancel_run(project_id=project_id, run_id=run_id, hex_credentials=hex_credentials)\n\n    # get list of project runs\n    project_runs = get_project_runs(\n        project_id=project_id, hex_credentials=hex_credentials\n    )\n\n    return project_runs\n\nexample_hex_flow()\n```\n\nFor more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://orion-docs.prefect.io/collections/usage/)!\n\n## Resources\n\n### Blog Posts\n\n- [Create Observable and Reproducible Notebooks with Hex](https://towardsdatascience.com/create-observable-and-reproducible-notebooks-with-hex-460e75818a09) by Khuyen Tran\n\n### Videos\n\n- [Create Observable and Reproducible Notebooks with Hex: Why Hex (Part 1)](https://youtu.be/_BjqCrun4nE)\n\nIf you encounter any bugs while using `prefect-hex`, feel free to open an issue in the [prefect-hex](https://github.com/PrefectHQ/prefect-hex) repository.\n\nIf you have any questions or issues while using `prefect-hex`, you can find help in either the [Prefect Discourse forum](https://discourse.prefect.io/) or the [Prefect Slack community](https://prefect.io/slack).\n\nFeel free to star or watch [`prefect-hex`](https://github.com/PrefectHQ/prefect-hex) for updates too!\n\n## Contributing\n \n-```bash\n-git clone https://github.com/PrefectHQ/prefect-hex.git\nIf 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](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).\n \n-cd prefect-hex/\nHere are the steps:\n \n1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)\n2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)\n3. Install the repository and its dependencies:\n```\n pip install -e \".[dev]\"\n```\n4. Make desired changes\n5. Add tests\n6. Insert an entry to [CHANGELOG.md](https://github.com/PrefectHQ/prefect-hex/blob/main/CHANGELOG.md)\n7. Install `pre-commit` to perform quality checks prior to commit:\n```\n pre-commit install\n ```\n8. `git commit`, `git push`, and create a pull request install\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Prefect integrations for interacting with Hex.",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/PrefectHQ/prefect-hex"
    },
    "split_keywords": [
        "prefect"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7a53373601d3ca197cd28b6684945bd581c5ee4b6d04583912203efa2c1d472",
                "md5": "79a54faba32aa74df1ff62fb6f1e4f91",
                "sha256": "3f7f23931cb2aaf953132a8cce0d1fa1e5bb07b6ede2e66fa42b0d2aed6bad85"
            },
            "downloads": -1,
            "filename": "prefect_hex-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79a54faba32aa74df1ff62fb6f1e4f91",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16542,
            "upload_time": "2023-11-13T22:52:20",
            "upload_time_iso_8601": "2023-11-13T22:52:20.779036Z",
            "url": "https://files.pythonhosted.org/packages/f7/a5/3373601d3ca197cd28b6684945bd581c5ee4b6d04583912203efa2c1d472/prefect_hex-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ce9d29503dd63e7d3d4e9ecf7075288f10fcb7c7851de4e2bfda9f524b0f456",
                "md5": "ab155dad4fec86772c05ca296d8d0183",
                "sha256": "1fcbab1b3b6b858afe9d272a57e7e0fe776c7f6a24b423d5f3acd707ed8d3827"
            },
            "downloads": -1,
            "filename": "prefect-hex-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ab155dad4fec86772c05ca296d8d0183",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 36470,
            "upload_time": "2023-11-13T22:52:21",
            "upload_time_iso_8601": "2023-11-13T22:52:21.992964Z",
            "url": "https://files.pythonhosted.org/packages/2c/e9/d29503dd63e7d3d4e9ecf7075288f10fcb7c7851de4e2bfda9f524b0f456/prefect-hex-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-13 22:52:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PrefectHQ",
    "github_project": "prefect-hex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "prefect-hex"
}
        
Elapsed time: 0.26183s