TamNguyen- Handling Custom Jupyter Data Sources | JupyterCon 2020
Key Takeaways
Handles custom Jupyter data sources using Kedro
Full Transcript
hello jupitercon my name is tom also known as data engineer one and today i'm going to be showing you guys how you can use kedro and jupiter notebooks pedro is a framework built by quantum black geared towards data scientists and data engineers to help them write better data pipelines oftentimes what happens is a lot of data sciencing and data engineering work is collated inside of notebooks which are very useful for those experimentation and iterations but can fall away when you want to try to reuse that pipeline you want to try to move that pipeline or you want to try to understand that pipeline a month down the line in that process of finding out how best to collaborate between data engineers and data scientists pedro was born pedro is a scalable modular pipeline building framework in today's video we're just going to be talking about a single jupiter notebook and turn it into a kedro pipeline this notebook in particular comes from the british natural history museum we're going to be taking the apis that are available and downloading the data and then creating the transformation nodes that we would like to reuse inside of ketro and we can go ahead and get started by cloning example now that that's done let's go ahead and install kedrow now to get kendro you just type in pip install dash u and drone android comes with an awesome cli that we use in order to interact with our quetro project to create a new project we type in kedrow new let's go ahead and just name this on example for now we can go ahead and hit enter through all of these we can open up that project i'm going to use pycharm pedro comes with a standard template for data pipeline projects the most important folders for our exercise today are going to be the conf folder the source folder and the data folder the conf folder holds configurations for your data pipeline and i think that's something interesting because not many people realize or think about how they hard code configurations inside of their jupyter notebooks often it's just simple parameters but it also can include paths to data this creates a barrier that prevents an individual from copying that jupyter notebook and pasting it somewhere else because that means you also have to paste a lot of these data paths exactly in the same way petro abstracts this with its catalog which we'll be investigating in just a little bit the next folder on this list is the data folder now this is an obvious folder it's where we keep some of the data metro comes with a simple structure for designating your different tiers of data we're going to be using this folder to store our data but it is not required to store your data in this folder to use kedro finally the source folder is where all of the kedra pipeline code is going to be sitting as you can see here the con example project name has been populated inside of the source folder and this is where we're going to be putting a bunch of our pipes very quickly i'm going to explain what i mean by data pipeline in kedrow now if you'll take a moment to take a look at this graphic here i have an example circles to triangles pipeline this pipeline consists of four elements the circles data set is an example data set which contains a bunch of circles right you can consider it as a row of circles next we have in here the center the circles to triangle node transformation function this is a transformation function that will turn the nodes into triangles next we have a triangles data set and this captures the output of our circles to triangle's node transformation function finally the fourth element here is the pipeline itself so the pipeline is what contains each of these elements the two data sets on our transformation node and is responsible for extracting data from the data set and then passing it into the circles to triangle node then it is also responsible for extracting the data from the circles to triangle node transformation function and then inputting it into the triangles data set so these four elements are the basic elements of a ketro pipeline and these are going to be the elements that we'll be using today for our notebook conversion now that we have created a catcher's project and we have a copy of the notebook in question into the notebooks folder now making sure to source the virtual environment i'm going to cd into our con example project and type in pedro jupiter notebook pedro comes with a jupiter notebook integration it makes it very easy to operate pedro pipelines as well as jupiter notebooks simultaneously navigating into our notebooks folder i'm going to go ahead and open this notebook and we'll see here that there's actually a lot of libraries that we also need to install sourcing bin activate we're going to do pip install dash you oleum shapely numpy pandas matplotlib requests next we're going to install a kedro library because of how many different ways you can connect to different data sources in kedrow the ketchup team has split up the kedro library into several distinct chunks and one of those chunks is the kedro pandas chunk this will allow us to read and write data using pandas all right let's go ahead with the very first portion here there's a web api for the global biodiversity information facility that allows us to gather data for particular years let's go ahead and gather data and copy the url very simply i've just imported requests and i'm using the request.get function now that we have access to this object i'm going to go ahead and just write it directly to disk into our data directory at zero one raw and we're gonna name this field data.json now that we have that initial data let's go ahead and use ketro to open it up in order for kedro to be aware of this data we have to create a data abstraction this is known as creating a data set inside of the catalog so here i'm going to create a new key inside of this yaml file called field data the type of which is going to be a json.json dataset and the file path is going to be the relative path to the o1 raw folder field data.json file so now we've added this data set to the catalog this means that kejrow has access to it there's a few special objects that the jupiter notebook ketchup comes with we have the context object which just gives us the context of our project and the catalog which is the object that points to our ketchup catalog if we do catalog.list we're going to see nothing right now because we just added this but using some jupiter line magic reload kedro we're going to reload all the ketchup configurations and when we run catalog that list one more time we're going to see field data appears calling catalog dot load for the field data data set we'll find our json file the reason why this data abstraction is important is because if you want to move your jupyter notebook you no longer have to worry about making sure that all the file paths inside of that jupyter notebook are correct you can simply use the ketchup catalog's data abstraction to refer to the file that you need and then in the target machine or the remote machine just change the catalog.yml file to point those data sets to the correct file paths and you can start to imagine how portability can be achieved using catro in this way now scrolling down a little bit more we see that there's actually a cleaning function here for every result that comes back in those pages we're filtering those results to make sure that decimal latitude exists and turn it into a pandas data frame this is going to be the first function that we create it's going to be a cleaning function let's go ahead and name this clean raw field data and now we have a data frame from the clean raw field data function and here we see our new data frame with the clean json data but what about kendra where does kedra come in now well here's where it gets really interesting going into view i want you to go to cell toolbar and i want you to allow tags on this first cell with the function i want you to type in node and add that as a tag then save now going back to our terminal i want you to type in kendra jupiter it has three commands the first command convert what this is going to do is it's going to go through all of our notebooks that are inside of our notebook folder and convert any cells that we have tagged with node into a kedrow node we're going to go ahead and type in kedro jupiter invert dash dash all and you should see this converting notebook message if you don't see this message make sure that you've saved your changes with your tags in your notebook now what this has done is created a brand new python file located inside of the nodes folder going back to parcharm here is our python file created from our notebook let's go ahead and just rename this guy bnhm now that we've created a function to transform our json data into a pandas data frame let's create a function that'll plot our pandas data frame the function i'm going to write is very simple it's going to be called plot field data it's going to take in the field data data frame and it's going to return a pi plot figure and in true pandas fashion we've written a very long line let's go ahead and try this guy out and here we get the plotted field data now let's go ahead and tag this as a node and then rerun our conversion function and thankfully we're using pycharm because here as you can see i've made a typo great now we have a field cleaner as well as a field plotter let's go ahead and create a brand new pipeline now by default the pipelines are registered inside of the register pipelines function inside of the hook stock pi in the root of your project module in order to write our pipeline it's actually very trivial we're going to go ahead and take advantage of the current default pipeline that's available to us and in here we're going to add a node and we're going to import it from kendrick pipeline we're going to go ahead and use the clean raw field data function as our first argument now the next two arguments which are required by the node are the inputs and the outputs now notice here that we're taking advantage of the abstraction and this field data is pointing to a json file finally for outputs we're actually going to create something arbitrary intro is going to automatically turn that into an in-memory data set now the next node in the pipeline that we're going to create is going to be our plot field data function and then the inputs is going to be the output of the previous one and for the output field data plot going back into our catalog yaml file we're going to call this field data plot the type of which is going to be the matplotlib writer the file path is going to be data08reportingfielddata.png now with these two nodes we've actually successfully created our entire kedro pipeline opening up the terminal again we're going to type in kedro run and here we have a very convenient log output showing us kedra went through when we open up our data folder opening up this png file will give us exactly the png that we saw inside of our jupiter notebook thank you for joining me on this jupiter con video if you'd like to see more videos like this make sure you check me out on youtube at youtube.com dataengineer1 and if you have any questions feel free to hit me up on twitter i hope you guys learned something today and i hope you guys have a wonderful rest of your jupiter conference take care and i'll see you guys next time bye
Original Description
Brief Summary
In this talk, Tam will show you how to transform a Jupyter notebook into a Kedro pipeline. He will convert built-in functions from a Jupyter notebook like the one from the (Berkley National History Museum)[https://github.com/BNHM/jupyter/blob/master/IB105-2017-BNHM.ipynb] into modular pipelines showcasing preprocessing workflows.
Outline
The proposal aims to teach users how to convert a simple Jupyter notebook into a Kedro pipeline. Most data science and data engineering models are built using Jupyter notebooks. While notebooks are great for an exploratory workflow, they are challenging to debug and difficult to maintain. When we want to scale analytics, we use Kedro. Kedro is an open-source Python library that implements software engineering best-practices for data and machine-learning pipelines. Kedro helps data scientists structure an exploratory data science workflow while creating production-ready code. Some users describe it as the React or Django of Data Science.
In this talk, Tam will show you how to transform a Jupyter notebook into a Kedro pipeline. He will convert built-in functions from a Jupyter Notebook like the one from the (Berkley National History Museum)[https://github.com/BNHM/jupyter/blob/master/IB105-2017-BNHM.ipynb] into modular pipelines showcasing preprocessing workflows. Tam will guide you through understanding the powerful features in Kedro such as modular programming, extracting Notebook cell functions as Pipeline tasks and data abstraction. This talk is designed for Data Scientists and Data Engineers from the novice level. One does not require to have previous knowledge of Kedro to enjoy this talk.
---
JupyterCon brings together data scientists, business analysts, researchers, educators, developers, core Project contributors, and tool creators for in-depth training, insightful keynotes, networking, and practical talks exploring the Project Jupyter ecosystem.
https://jupytercon.com/
JupyterCon is possible thanks to the
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from JupyterCon · JupyterCon · 17 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
▶
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Interview Joshua Patterson NVIDIA
JupyterCon
Dave Stuart - Jupyter as an Enterprise “Do It Yourself” (DIY) Analytic Platform | JupyterCon 2020
JupyterCon
Jeffrey Mew - Supercharge your Data Science workflow | JupyterCon 2020
JupyterCon
Michelle Ufford- Supercharging SQL Users with Jupyter Notebooks | JupyterCon 2020
JupyterCon
Alan Yu - What we learned from introducing Jupyter Notebooks to the SQL community | JupyterCon 2020
JupyterCon
Chris Holdgraf- 2i2c: sustaining open source through hosted Jupyter infrastructure | JupyterCon 2020
JupyterCon
Yiwen Li - Intro to Elyra - an AI centric extension for JupyterLab | JupyterCon 2020
JupyterCon
Luciano Resende - What's new on Elyra - A set of AI centric JupyterLab extensions | JupyterCon 2020
JupyterCon
Alan Chin - Explore and Extend AI Pipeline Runtimes with Elyra and JupyterLab | JupyterCon 2020
JupyterCon
Eduardo Blancas- Streamline your Data Science projects with Ploomber | JupyterCon 2020
JupyterCon
Thorin Tabor - Democratizing the accessibility of computational workflows | JupyterCon 2020
JupyterCon
Simon Willison- Using Datasette with Jupyter to publish your data | JupyterCon 2020
JupyterCon
Brendan O'Brien - Using Qri (“query”) to fetch, query, combine and publish datasets.|JupyterCon 2020
JupyterCon
Georgiana Dolocan - Putting the JupyterHub puzzle pieces together | JupyterCon 2020
JupyterCon
Yuvi Panda- Running nonjupyter applications on JupyterHub with jupyter-server-proxy| JupyterCon 2020
JupyterCon
Richard Wagner- The Streetwise Guide to JupyterHub Security | JupyterCon 2020
JupyterCon
TamNguyen- Handling Custom Jupyter Data Sources | JupyterCon 2020
JupyterCon
Immanuel Bayer- ipyannotator - the infinitely hackable annotation framework | JupyterCon 2020
JupyterCon
Rebecca Kelly- A shared Python, R and Q Jupyter Notebook - A Quant Sandbox Dream |JupyterCon 2020
JupyterCon
Itay Dafna - Leap of faith: Transitioning from Excel to Jupyter-based applications | JupyterCon 2020
JupyterCon
Damián Avila - Using the Jupyterverse to power MADS | JupyterCon 2020
JupyterCon
Chiin Rui Tan- From Zero to Hero | JupyterCon 2020
JupyterCon
Firas Moosvi- Teaching an Active Learning class with Jupyter Book| JupyterCon 2020
JupyterCon
Daniel Mietchen- Jupyter in the Wikimedia ecosystem | JupyterCon 2020
JupyterCon
Qiusheng Wu- How Jupyter and geemap enable interactive mapping and analysis | JupyterCon 2020
JupyterCon
Stephanie Juneau- Jupyterenabled astrophysical analysis for researchers and students|JupyterCon 2020
JupyterCon
Denton Gentry- The Care and Feeding of JupyterHub for Climate Solution Models| JupyterCon 2020
JupyterCon
Tingkai Liu- FlyBrainLab: Interactive Computing in the Connectomic/Synaptomic Era | JupyterCon 2020
JupyterCon
Kunal Bhalla- A Notebook Style Guide| JupyterCon 2020
JupyterCon
Julia Wagemann - How to avoid 'Death by Jupyter Notebooks' | JupyterCon 2020
JupyterCon
David Pugh - Best practices for managing Jupyter-based data science | JupyterCon 2020
JupyterCon
Karla Spuldaro - Debugging notebooks and python scripts in JupyterLab | JupyterCon 2020
JupyterCon
Shreyas Dalia - assert browserTest == True # Frontend Testing JupyterLab | JupyterCon 2020
JupyterCon
Chris Holdgraf - The new Jupyter Book stack | JupyterCon 2020
JupyterCon
Hamel Husain - Fastpages - A new, open source Jupyter notebook blogging system | JupyterCon 2020
JupyterCon
Marc Wouts - Jupytext: Jupyter Notebooks as Markdown Documents | JupyterCon 2020
JupyterCon
Sheeba Samuel- ProvBook |JupyterCon 2020
JupyterCon
Philipp Rudiger - To Jupyter and back again | JupyterCon 2020
JupyterCon
Jacob Tomlinson - What is my GPU doing? | JupyterCon 2020
JupyterCon
Afshin Darian - A visual debugger in Jupyter | JupyterCon 2020
JupyterCon
Eric Charles - Jupyter Real Time Collaboration| JupyterCon 2020
JupyterCon
Devin Robison - Optimizing model performance | JupyterCon 2020
JupyterCon
Junhua zhao - PayPal Notebooks: ML & Data Science experience | JupyterCon 2020
JupyterCon
April Wang - Redesigning Notebooks for Better Collaboration | JupyterCon 2020
JupyterCon
Bryan Weber - Distributing and Collecting Jupyter Notebooks for Manual Grading| JupyterCon 2020
JupyterCon
Georgiana Dolocan - The Littlest JupyterHub distribution | JupyterCon 2020
JupyterCon
Tim Metzler - Electronic Examination using Jupyter Notebook | JupyterCon 2020
JupyterCon
Blaine Mooers - Why develop a snippet library for Jupyter in your subject domain? | JupyterCon 2020
JupyterCon
Ryan Abernathey - Cloud Native Repositories for Big Scientific Data | JupyterCon 2020
JupyterCon
Tanya Rai - Introducing Bento: Jupyter Notebooks @ Facebook | JupyterCon 2020
JupyterCon
Kenton McHenry - From Papers to Notebooks | JupyterCon 2020
JupyterCon
Ryan Herr - After model.fit, before you deploy| JupyterCon 2020
JupyterCon
Ana Ruvalcaba - Community building is a sustainability strategy | JupyterCon 2020
JupyterCon
Martin Renou - Xeus: an ecosystem of Jupyter kernels | JupyterCon 2020
JupyterCon
Michael Wilson - Teaching teenagers to understand Dark Energy | JupyterCon 2020
JupyterCon
Davide De Marchi - Voilà dashboards for policy support | JupyterCon 2020
JupyterCon
Marcos Lopez Caniego - ESASky's JupyterLab widget| JupyterCon 2020
JupyterCon
Praveen Kanamarlapud - Kernel Life Cycle Management | JupyterCon 2020
JupyterCon
Aaron Bray - Pulse Physiology Engine | JupyterCon 2020
JupyterCon
Aaron Watters - Using WebGL2 transform/feedback in Jupyter widgets | JupyterCon 2020
JupyterCon
Related Reads
📰
📰
📰
📰
I Wanted To Automate Website Testing Without Writing Hundreds Of Scripts. AI Changed The Approach.
Medium · AI
Claude Count Tokens API: Know What a Request Costs Before You Send It (Beginner’s Guide)
Medium · AI
Claude Count Tokens API: Know What a Request Costs Before You Send It (Beginner’s Guide)
Medium · Programming
Smarter Syncing: The Rise of AI in Your Cloud Storage
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI