Skip to main content

Prefect integrations for working with Census syncs

Project description

prefect-census

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

PyPI

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)
  • Call a custom endpoint with a CensusClient using your CensusCredentials (see how)

For information on how to get started with Census, refer to the Census docs.

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

pip install prefect-census

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

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 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.

💡 NOTE

All Census Syncs are incremental, 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

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:

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:

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!

Resources

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

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

Feel free to star or watch 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.

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

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-census-0.2.2.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

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

prefect_census-0.2.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file prefect-census-0.2.2.tar.gz.

File metadata

  • Download URL: prefect-census-0.2.2.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for prefect-census-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c068e6d2d400905ad85d06485a95f4c03d657ae3424da98ce2537373750f62ee
MD5 f593aa2d630dad4d6a22a19b325eb47e
BLAKE2b-256 8a8231d9f0376e14e042ca993aa4d2c45d81f2840378b75c992497f8f9951050

See more details on using hashes here.

File details

Details for the file prefect_census-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: prefect_census-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for prefect_census-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c545dcc2d4d744c9cd3a798bdff7926498e9577d59545b56f4c3b3b9d661d91
MD5 789a0de9953aa6fc16895a655af6630c
BLAKE2b-256 22300264a1f122e4b3eedec5058eb1606b17f71c90de91873411d5013e398244

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