Skip to main content

A Census provider for Apache Airflow.

Project description

Census Provider for Apache Airflow

This package allows you to trigger syncs for Census.

Installation

Install the airflow-provider-census package from PyPI using your preferred way of installing python packages.

Configuration

There are 2 ways to configure a Census connection depending on whether you are using Airflow 1.10 or Airflow 2.

The CensusHook and CensusOperator use the census_default connection id as a default, although this is configurable if you would like to use your own connection id.

Finding the secret-token

  1. Go to any sync at https://app.getcensus.com/syncs
  2. Click on the Sync Configuration tab.
  3. Next to API TRIGGER, click "Click to show"
  4. The url will be of the format https://bearer:secret-token:arandomstring@app.getcensus.com/api/v1/syncs/0/trigger
  5. the secret token will be of the format "secret-token:arandomstring" in the url above, including the "secret-token:" part. Do not include the "@".

Configuration in Airflow 1.10

In the Airflow Connections UI, create a new connection:

  • Conn ID: census_default
  • Conn Type: HTTP
  • Password: secret-token

Configuration in Airflow 2

In the Airflow Connections UI, create a new connection:

  • Conn Id: census_default
  • Conn Type: Census
  • Census Secret Token: secret-token

Hooks

CensusHook

CensusHook is a class that inherits from HttpHook and can be used to run http requests for Census. You will most likely interact with the operator rather than the hook.

The hook can be imported by the following code:

from airflow_provider_census.hooks.census import CensusHook

Operators

CensusOperator

CensusOperator triggers a sync job in Census. The operator takes the following parameters:

  1. sync_id : Navigate to the sync and check the url for the sync id. For example https://app.getcensus.com/syncs/0/overview here, the sync_id would be 0.
  2. census_conn_id : The connection id to use. This is optional and defaults to 'census_default'.

The operator can be imported by the following code:

from airflow_provider_census.operators.census import CensusOperator

Sensors

CensusSensor

CensusSensor polls a sync run in Census. The sensor takes the following parameters:

  1. sync_run_id : The sync run id you get back from the CensusOperator which triggers a new sync.
  2. census_conn_id : The connection id to use. This is optional and defaults to 'census_default'.

The sensor can be imported by the following code:

from airflow_provider_census.sensors.census import CensusSensor

Example

The following example will run a Census sync once a day:

from airflow_provider_census.operators.census import CensusOperator

from airflow import DAG
from airflow.utils.dates import days_ago
from datetime import timedelta

default_args = {
    "owner": "airflow",
    "start_date": days_ago(1)
}

dag = DAG('census', default_args = default_args)

sync = CensusOperator(sync_id = 27, dag = dag, task_id = 'sync')

sensor = CensusSensor(sync_run_id = "{{ ti.xcom_pull(task_ids = 'sync') }}", dag = dag, task_id = 'sensor')

sync >> sensor

Feedback

Source code available on Github. Feedback and pull requests are greatly appreciated. Let us know if we can improve this.

From

:wave: The folks at Census originally put this together. Have data? We'll sync your data warehouse with your CRM and the customer success apps critical to your team.

Need help setting this up?

You can always contact us via support@getcensus.com or in-app via the live chat in the bottom right corner.

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

airflow-provider-census-1.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

airflow_provider_census-1.1.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file airflow-provider-census-1.1.1.tar.gz.

File metadata

  • Download URL: airflow-provider-census-1.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.9 Darwin/20.5.0

File hashes

Hashes for airflow-provider-census-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9f9fb1c1e4cbce5d3842b7056ba1091812d909f85bac1131e8fc608fc4fa675f
MD5 524589b569fa0e508d087944815188bd
BLAKE2b-256 7648ab2d6122774e8f6e6b020cab15dbfdc5d9cfee71853b52f028ac9e6c4cd0

See more details on using hashes here.

File details

Details for the file airflow_provider_census-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_provider_census-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65ec30d81ecd191dc0cba03e48f439463e961b8a1ced907d5403d13adf8f787b
MD5 03ad7a2fe82a790b83915a5c9717805b
BLAKE2b-256 09a4bdae2d7e40b10145e95f64a7b6d8e72e16648ecce0eed4a82dcbcd46d629

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