prefect-census


Nameprefect-census JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/PrefectHQ/prefect-census
SummaryPrefect integrations for working with Census syncs
upload_time2023-11-29 19:58:45
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-census

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

<p align="center">
    <a href="https://pypi.python.org/pypi/prefect-census/" alt="PyPI version">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-census?color=0052FF&labelColor=090422"></a>
    <a href="https://github.com/PrefectHQ/prefect-census/" alt="Stars">
        <img src="https://img.shields.io/github/stars/PrefectHQ/prefect-census?color=0052FF&labelColor=090422" /></a>
    <a href="https://pepy.tech/badge/prefect-census/" alt="Downloads">
        <img src="https://img.shields.io/pypi/dm/prefect-census?color=0052FF&labelColor=090422" /></a>
    <a href="https://github.com/PrefectHQ/prefect-census/pulse" alt="Activity">
        <img src="https://img.shields.io/github/commit-activity/m/PrefectHQ/prefect-census?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!

This collection contains Prefect integrations for working with Census.

Census is an Operational Analytics platform that enables you to sync your trusted analytics data from your hub into operational tools that your business teams use on a daily basis.

Some things you can do with this collection out-of-the-box include:
- Trigger a Census sync run and wait for it to finish [(see how)](#use-a-censussync-job-block-to-run-a-sync-and-wait-for-completion)
- Call a custom endpoint with a `CensusClient` using your `CensusCredentials` [(see how)](#call-a-custom-endpoint)


For information on how to get started with Census, refer to the [Census docs](https://docs.getcensus.com/).

## 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-census` with `pip`:

```bash
pip install prefect-census
```

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

### Get a Census API Key

You will need a Census API key to be able to use the integrations in this collection. 

For directions for how to generate a Census API key, refer to the [Getting API Access](https://docs.getcensus.com/basics/api#getting-api-access) section of the Census docs.

Once you have a Census API key, you can configure a `CensusCredentials` block in the Prefect UI for use with the integrations in this collection. For information about how to configure a block in the Prefect UI, refer to the [Prefect docs](https://orion-docs.prefect.io/ui/blocks/).

### 💡  **NOTE**
> All [Census Syncs are incremental](https://docs.getcensus.com/basics/core-concept#sync-behaviors), which means they only capture records that are new or changed data since the previous sync.


### Write and run a flow


#### Use a `CensusSync` job block to run a sync and wait for completion

```python
from prefect import flow
from prefect_census import (
    CensusCredentials, CensusSync, run_census_sync
)

census_sync = CensusSync(
    credentials=CensusCredentials(api_key="my_api_key"),
    sync_id=42
)

@flow
def my_census_flow():
    # do some setup
    
    run_census_sync(census_sync)
    
    # do some cleanup

```

#### **Get Census sync run info**:
```python
from prefect import flow

from prefect_census import CensusCredentials
from prefect_census.runs import get_census_sync_run_info

@flow
def get_sync_run_info_flow():
    credentials = CensusCredentials(api_key="my_api_key")

    return get_census_sync_run_info(
        credentials=credentials,
        run_id=42
    )

get_sync_run_info_flow()
```

#### **Call a custom endpoint**:
```python
from prefect import flow
from prefect_census import CensusCredentials
from prefect_census.client import CensusClient

@flow
def my_flow(sync_id):
    creds_block = CensusCredentials(api_key="my_api_key")

    client = CensusClient(
        api_key=creds_block.api_key.get_secret_value()    
    )
    response = client.call_endpoint(
        http_method="GET", path=f"/syncs/{sync_id}"
    )
    return response

my_flow(42)
```

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

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

If you have any questions or issues while using `prefect-census`, 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-census`](https://github.com/PrefectHQ/prefect-census) for updates too!

## Contributing

If you'd like to help contribute to fix an issue or add a feature to `prefect-census`, 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).

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-census/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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PrefectHQ/prefect-census",
    "name": "prefect-census",
    "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/8a/82/31d9f0376e14e042ca993aa4d2c45d81f2840378b75c992497f8f9951050/prefect-census-0.2.2.tar.gz",
    "platform": null,
    "description": "# prefect-census\n\nVisit the full docs [here](https://PrefectHQ.github.io/prefect-census) to see additional examples and the API reference.\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/prefect-census/\" alt=\"PyPI version\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/prefect-census?color=0052FF&labelColor=090422\"></a>\n    <a href=\"https://github.com/PrefectHQ/prefect-census/\" alt=\"Stars\">\n        <img src=\"https://img.shields.io/github/stars/PrefectHQ/prefect-census?color=0052FF&labelColor=090422\" /></a>\n    <a href=\"https://pepy.tech/badge/prefect-census/\" alt=\"Downloads\">\n        <img src=\"https://img.shields.io/pypi/dm/prefect-census?color=0052FF&labelColor=090422\" /></a>\n    <a href=\"https://github.com/PrefectHQ/prefect-census/pulse\" alt=\"Activity\">\n        <img src=\"https://img.shields.io/github/commit-activity/m/PrefectHQ/prefect-census?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\nThis collection contains Prefect integrations for working with Census.\n\nCensus is an Operational Analytics platform that enables you to sync your trusted analytics data from your hub into operational tools that your business teams use on a daily basis.\n\nSome things you can do with this collection out-of-the-box include:\n- Trigger a Census sync run and wait for it to finish [(see how)](#use-a-censussync-job-block-to-run-a-sync-and-wait-for-completion)\n- Call a custom endpoint with a `CensusClient` using your `CensusCredentials` [(see how)](#call-a-custom-endpoint)\n\n\nFor information on how to get started with Census, refer to the [Census docs](https://docs.getcensus.com/).\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-census` with `pip`:\n\n```bash\npip install prefect-census\n```\n\nA list of available blocks in `prefect-census` and their setup instructions can be found [here](https://PrefectHQ.github.io/prefect-census/#blocks-catalog).\n\n### Get a Census API Key\n\nYou will need a Census API key to be able to use the integrations in this collection. \n\nFor directions for how to generate a Census API key, refer to the [Getting API Access](https://docs.getcensus.com/basics/api#getting-api-access) section of the Census docs.\n\nOnce you have a Census API key, you can configure a `CensusCredentials` block in the Prefect UI for use with the integrations in this collection. For information about how to configure a block in the Prefect UI, refer to the [Prefect docs](https://orion-docs.prefect.io/ui/blocks/).\n\n### \ud83d\udca1  **NOTE**\n> All [Census Syncs are incremental](https://docs.getcensus.com/basics/core-concept#sync-behaviors), which means they only capture records that are new or changed data since the previous sync.\n\n\n### Write and run a flow\n\n\n#### Use a `CensusSync` job block to run a sync and wait for completion\n\n```python\nfrom prefect import flow\nfrom prefect_census import (\n    CensusCredentials, CensusSync, run_census_sync\n)\n\ncensus_sync = CensusSync(\n    credentials=CensusCredentials(api_key=\"my_api_key\"),\n    sync_id=42\n)\n\n@flow\ndef my_census_flow():\n    # do some setup\n    \n    run_census_sync(census_sync)\n    \n    # do some cleanup\n\n```\n\n#### **Get Census sync run info**:\n```python\nfrom prefect import flow\n\nfrom prefect_census import CensusCredentials\nfrom prefect_census.runs import get_census_sync_run_info\n\n@flow\ndef get_sync_run_info_flow():\n    credentials = CensusCredentials(api_key=\"my_api_key\")\n\n    return get_census_sync_run_info(\n        credentials=credentials,\n        run_id=42\n    )\n\nget_sync_run_info_flow()\n```\n\n#### **Call a custom endpoint**:\n```python\nfrom prefect import flow\nfrom prefect_census import CensusCredentials\nfrom prefect_census.client import CensusClient\n\n@flow\ndef my_flow(sync_id):\n    creds_block = CensusCredentials(api_key=\"my_api_key\")\n\n    client = CensusClient(\n        api_key=creds_block.api_key.get_secret_value()    \n    )\n    response = client.call_endpoint(\n        http_method=\"GET\", path=f\"/syncs/{sync_id}\"\n    )\n    return response\n\nmy_flow(42)\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\nIf you encounter any bugs while using `prefect-census`, feel free to open an issue in the [prefect-census](https://github.com/PrefectHQ/prefect-census) repository.\n\nIf you have any questions or issues while using `prefect-census`, 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-census`](https://github.com/PrefectHQ/prefect-census) for updates too!\n\n## Contributing\n\nIf you'd like to help contribute to fix an issue or add a feature to `prefect-census`, 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\nHere are the steps:\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```\npip install -e \".[dev]\"\n```\n4. Make desired changes\n5. Add tests\n6. Insert an entry to [CHANGELOG.md](https://github.com/PrefectHQ/prefect-census/blob/main/CHANGELOG.md)\n7. Install `pre-commit` to perform quality checks prior to commit:\n```\npre-commit install\n```\n8. `git commit`, `git push`, and create a pull request\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Prefect integrations for working with Census syncs",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/PrefectHQ/prefect-census"
    },
    "split_keywords": [
        "prefect"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22300264a1f122e4b3eedec5058eb1606b17f71c90de91873411d5013e398244",
                "md5": "789a0de9953aa6fc16895a655af6630c",
                "sha256": "0c545dcc2d4d744c9cd3a798bdff7926498e9577d59545b56f4c3b3b9d661d91"
            },
            "downloads": -1,
            "filename": "prefect_census-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "789a0de9953aa6fc16895a655af6630c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17766,
            "upload_time": "2023-11-29T19:58:44",
            "upload_time_iso_8601": "2023-11-29T19:58:44.504137Z",
            "url": "https://files.pythonhosted.org/packages/22/30/0264a1f122e4b3eedec5058eb1606b17f71c90de91873411d5013e398244/prefect_census-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a8231d9f0376e14e042ca993aa4d2c45d81f2840378b75c992497f8f9951050",
                "md5": "f593aa2d630dad4d6a22a19b325eb47e",
                "sha256": "c068e6d2d400905ad85d06485a95f4c03d657ae3424da98ce2537373750f62ee"
            },
            "downloads": -1,
            "filename": "prefect-census-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f593aa2d630dad4d6a22a19b325eb47e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 35916,
            "upload_time": "2023-11-29T19:58:45",
            "upload_time_iso_8601": "2023-11-29T19:58:45.553235Z",
            "url": "https://files.pythonhosted.org/packages/8a/82/31d9f0376e14e042ca993aa4d2c45d81f2840378b75c992497f8f9951050/prefect-census-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-29 19:58:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PrefectHQ",
    "github_project": "prefect-census",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "prefect-census"
}
        
Elapsed time: 0.18029s