{"id":20532028,"url":"https://github.com/prefecthq/prefect-census","last_synced_at":"2025-04-14T06:23:19.796Z","repository":{"id":62106191,"uuid":"550223967","full_name":"PrefectHQ/prefect-census","owner":"PrefectHQ","description":"Prefect integrations for working with Census syncs","archived":false,"fork":false,"pushed_at":"2024-02-08T20:33:26.000Z","size":1814,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T02:58:16.336Z","etag":null,"topics":["census","prefect"],"latest_commit_sha":null,"homepage":"https://prefecthq.github.io/prefect-census/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PrefectHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-12T12:00:25.000Z","updated_at":"2024-04-24T07:36:06.000Z","dependencies_parsed_at":"2024-02-08T22:08:11.971Z","dependency_job_id":"1a8c825d-c23d-4cf5-9c71-43636c64f8f1","html_url":"https://github.com/PrefectHQ/prefect-census","commit_stats":{"total_commits":12,"total_committers":7,"mean_commits":"1.7142857142857142","dds":0.75,"last_synced_commit":"d64d0477bcb363b32a7773420a70a41903da014b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrefectHQ%2Fprefect-census","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrefectHQ%2Fprefect-census/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrefectHQ%2Fprefect-census/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrefectHQ%2Fprefect-census/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PrefectHQ","download_url":"https://codeload.github.com/PrefectHQ/prefect-census/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248831204,"owners_count":21168422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["census","prefect"],"created_at":"2024-11-16T00:12:16.181Z","updated_at":"2025-04-14T06:23:19.749Z","avatar_url":"https://github.com/PrefectHQ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prefect-census\n\nVisit the full docs [here](https://PrefectHQ.github.io/prefect-census) to see additional examples and the API reference.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pypi.python.org/pypi/prefect-census/\" alt=\"PyPI version\"\u003e\n        \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/prefect-census?color=0052FF\u0026labelColor=090422\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PrefectHQ/prefect-census/\" alt=\"Stars\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/PrefectHQ/prefect-census?color=0052FF\u0026labelColor=090422\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://pepy.tech/badge/prefect-census/\" alt=\"Downloads\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/dm/prefect-census?color=0052FF\u0026labelColor=090422\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PrefectHQ/prefect-census/pulse\" alt=\"Activity\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/commit-activity/m/PrefectHQ/prefect-census?color=0052FF\u0026labelColor=090422\" /\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://prefect-community.slack.com\" alt=\"Slack\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/slack-join_community-red.svg?color=0052FF\u0026labelColor=090422\u0026logo=slack\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://discourse.prefect.io/\" alt=\"Discourse\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/discourse-browse_forum-red.svg?color=0052FF\u0026labelColor=090422\u0026logo=discourse\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\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### 💡  **NOTE**\n\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprefecthq%2Fprefect-census","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprefecthq%2Fprefect-census","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprefecthq%2Fprefect-census/lists"}