Package: ddataflow
DDataFlowDDataFlow is an end2end tests and local development solution for machine learning and data pipelines using pyspark.
It samples the data as an approach to get slow pipelines run fast in the CI.You can find our documentation in thedocs folder. And see the complete code referencehere.FeaturesRead a subset of our data so to speed up the running of the pipelines during testsWrite to a test location our artifacts so you don't pollute productionDownload data for enabling local machine developmentEnables to run on the pipelines in the CI1. Install Ddataflowpipinstallddataflowddataflow --helpwill give you an overview of the available commands.Getting Started (<5min Tutorial)This tutorial aims to show you the core features though, for the complete reference see theintegration manualin the docs.1. Setup some synthetic dataSee theexamples folder.2. Create a ddataflow_config.py fileThe commandddtaflow setup_projectcreates a file like this for you.fromddataflowimportDDataflowconfig={# add here your tables or paths with customized sampling logic"data_sources":{"demo_tours":{"source":lambdaspark:spark.table('demo_tours'),"filter":lambdadf:df.limit(500)}"demo_locations":{"source":lambdaspark:spark.table('demo_locations'),"default_sampling":True,}},"project_folder_name":"ddataflow_demo",}# initialize the application and validate the configurationddataflow=DDataflow(**config)3. Use ddataflow in a pipeline# filename: pipeline.pyfrompyspark.sqlimportSparkSessionfromddataflow_configimportddataflowspark=SparkSession.builder.getOrCreate()# register the tables to mimick a real environment# when you use ddatflow for real you will have your production tables in place alreadyspark.read.parquet("/tmp/demo_locations.parquet").registerTempTable("demo_locations")spark.read.parquet("/tmp/demo_tours.parquet").registerTempTable("demo_tours")# pyspark code using a different source nametotal_locations=spark.table(ddataflow.name('demo_locations')).count()# sql code also workstotal_tours=spark.sql(f""" SELECT COUNT(1) from{ddataflow.name('demo_tours')}""").collect()[0]['count(1)']print("Totals follow below:")print({"total_locations":total_locations,"total_tours":total_tours,})Now run it twice and observe the difference in the amount of records:python pipeline.pyENABLE_DDATAFLOW=True python pipeline.pyYou will see that the dataframes are sampled when ddataflow is enabled and full when the tool is disabled.You completed the short demo!How to developThe recommended approach to use ddataflow is to use the offline mode, which allows you to test your pipelines without the need for an active cluster. This is especially important for development and debugging purposes, as it allows you to quickly test and identify any issues with your pipelines.Alternatively, you can use Databricks Connect to test your pipelines on an active cluster. However, our experience with this approach has not been great, memory issues are common and there is the risk of overriding production data, so we recommend using the offline mode instead.If you have any questions or need any help, please don't hesitate to reach out. We are here to help you get the most out of ddataflow.SupportIn case of questions feel free to reach out or create an issue.Check out ourFAQ in case of problemsContributingThis project requires manual release at the moment. See the docs and request a pypi access if you want to contribute.