Package: packyak
PackYakPackYakPackYak is an open source platform for building versioned Data Lakehouses in AWS with Python and the AWS CDK.With one CLI command and an AWS account, you can spin up a world class Data Platform in your own AWS account with Git versioning of Data, SageMaker Domains, Spark Clusters, Streamlit Sites and more.Maintain your Data Lake just like you do your code - with git! Leverage branches, tags and commits to version your table schemas and data. Provide a consistent view of the data for consumers, enable rapid experimentation and roll back mistakes with ease.Development of ETL or ML training jobs is made easy with theyakCLI. Easily set up remote sessions on your Spark, Ray or Dask clusters to enjoy the power of cloud computing without giving up the experience of your local IDE.How it WorksPackYak combines modern Software Development, Cloud Engineering and Data Engineering practices into one Python framework:Git-like versioning of Data Tables withProject Nessie- no more worrying about the version of data, simply use branches, tags and commits to freeze data or roll back mistakes.Software-defined Assets (as seen in Dagster) - think of your data pipelines in terms of the data it produces. Greatly simplify how data is produced, modified over time and backfilled in the event of errors.Infrastructure-as-Code (AWS CDK and Pulumi) - deploy in minutes and manage it all yourself with minimal effort.Apache Spark - write your ETL as simple python processes that are then scaled automatically over a managed AWS EMR Spark Cluster.Streamlit - build Streamlit applications that integrate the Data Lakehouse and Apache Spark to provide interactive reports and exploratory tools over the versioned data lake.Get StartedInstall DockerIf you haven't already, installDocker.Install Python Poetry & Plugins# Install the Python Poetry CLIcurl-sSLhttps://install.python-poetry.org|python3-# Add the export plugin to generate narrow requirements.txtpoetryselfaddpoetry-plugin-exportInstall thepackyakCLI:pipinstallpackyakCreate a new Projectpackyaknewmy-projectcd./my-projectDeploy to AWSpoetryruncdkdeployGit-like Data Catalog (Project Nessie)PackYak comes with a Construct for hosting aProject Nessiecatalog that supports Git-like versioning of the tables in a Data Lakehouse.It deploys with an AWS DynamoDB Versioned store and an API hosted in AWS Lambda or AWS ECS. The Nessie Server is stateless and can be scaled easily with minimal-to-zero operational overhead.Create aNessieDynamoDBVersionStorefrompackyak.aws_cdkimportDynamoDBNessieVersionStoreversionStore=DynamoDBNessieVersionStore(scope=stack,id="VersionStore",versionStoreName="my-version-store",)Create a Bucket to store Data Tables (e.g. Parquet files). This will store the "Repository"'s data.myRepoBucket=Bucket(scope=stack,id="MyCatalogBucket",)Create the Nessie Catalog Service# hosted on AWS ECSmyCatalog=NessieECSCatalog(scope=stack,id="MyCatalog",vpc=vpc,warehouseBucket=myRepoBucket,catalogName=lakeHouseName,versionStore=versionStore,)Create a BranchBranch off themainbranch of data into adevbranch to "freeze" the data as of a particular commitCREATEBRANCHdevFROMmainDeploy a Spark ClusterCreate an EMR Cluster for processing dataspark=Cluster(scope=stack,id="Spark",clusterName="my-cluster",vpc=vpc,catalogs={# use the Nessie Catalog as the default data catalog for Spark SQL queries"spark_catalog":myCatalog,},installSSMAgent=true,)SSH into the Spark Clusteryak sshmakes it easy to develop on AWS EMR, SageMaker and EC2 instances using your local VS Code IDE by facilitating SSH connections to the host over AWS SSM without complicated networking rules or bastion hosts. Everything is secured by AWS IAM.yakssh{ec2-instance-id}Initialize a SparkSessionTo create a SparkSession using your code reposistory's.venvfile instead of the system one, use theinit_sessionhelper:frompackyak.sparkimportinit_sessionspark=init_session()[!TIP]
This is usually found in the first cell of a Jupyter notebook.If you want to customize the SparkSession further, usesession_builderinstead:spark=init_session().getOrCreate()Remote VS Code over SSHOnce connected to a remote host, you can useVS Code's Remote SSHto start editing code and running commands on the remote host with the comfort of your local VS Code IDE.SSH in and forward port22to a local port of your choice:yakssh{ec2-instance-id}-L9001:localhost:22Configure the remote host in your.ssh/config:HostemrHostNamelocalhostPort9001UserrootIdentityFile~/.ssh/id_rsaConfigure SparkSQL to be served over JDBCsparkSQL=spark.jdbc(port=10001)Deploy Streamlit SiteStand up a Streamlit Site to serve interactive reports and applications over your data.site=StreamlitSite(scope=stack,# Point it at the Streamlit site entrypointhome="app/home.py",# Where the Streamlit pages/tabs are, defaults to `dirname(home)/pages/*.py`# pages="app/pages")Deploy to AWSpackyakdeployOr via the AWS CDK CLI:poetryruncdkdeploy