Package: prefect-census
prefect-censusVisit the full docshereto see additional examples and the API reference.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 aCensusClientusing yourCensusCredentials(see how)For information on how to get started with Census, refer to theCensus docs.Getting StartedPython setupRequires 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 thePrefect documentation.InstallationInstallprefect-censuswithpip:pipinstallprefect-censusA list of available blocks inprefect-censusand their setup instructions can be foundhere.Get a Census API KeyYou 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 theGetting API Accesssection of the Census docs.Once you have a Census API key, you can configure aCensusCredentialsblock 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 thePrefect docs.💡NOTEAllCensus Syncs are incremental, which means they only capture records that are new or changed data since the previous sync.Write and run a flowUse aCensusSyncjob block to run a sync and wait for completionfromprefectimportflowfromprefect_censusimport(CensusCredentials,CensusSync,run_census_sync)census_sync=CensusSync(credentials=CensusCredentials(api_key="my_api_key"),sync_id=42)@flowdefmy_census_flow():# do some setuprun_census_sync(census_sync)# do some cleanupGet Census sync run info:fromprefectimportflowfromprefect_censusimportCensusCredentialsfromprefect_census.runsimportget_census_sync_run_info@flowdefget_sync_run_info_flow():credentials=CensusCredentials(api_key="my_api_key")returnget_census_sync_run_info(credentials=credentials,run_id=42)get_sync_run_info_flow()Call a custom endpoint:fromprefectimportflowfromprefect_censusimportCensusCredentialsfromprefect_census.clientimportCensusClient@flowdefmy_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}")returnresponsemy_flow(42)For more tips on how to use tasks and flows in a Collection, check outUsing Collections!ResourcesIf you encounter any bugs while usingprefect-census, feel free to open an issue in theprefect-censusrepository.If you have any questions or issues while usingprefect-census, you can find help in either thePrefect Discourse forumor thePrefect Slack community.Feel free to star or watchprefect-censusfor updates too!ContributingIf you'd like to help contribute to fix an issue or add a feature toprefect-census, pleasepropose changes through a pull request from a fork of the repository.Here are the steps:Fork the repositoryClone the forked repositoryInstall the repository and its dependencies:pip install -e ".[dev]"Make desired changesAdd testsInsert an entry toCHANGELOG.mdInstallpre-committo perform quality checks prior to commit:pre-commit installgit commit,git push, and create a pull request