wooden-dusk-90720
12/14/2023, 4:56 PMuser
12/14/2023, 4:58 PMwooden-dusk-90720
12/14/2023, 4:58 PMuser
12/14/2023, 5:02 PMwooden-dusk-90720
12/14/2023, 5:02 PMuser
12/14/2023, 5:06 PM1. Many data scientists are familiar with notebooks that shine at open-ended exploration and quick sketching of solutions. When developing with Metaflow, it is totally ok (although not required) to use notebooks for analysis. Use the Metaflow Client API to access and organize results of Metaflow runs in a notebook.Hmmm... the content isn't super specific about that. Let me see what I can find...
user
12/14/2023, 5:06 PMwooden-dusk-90720
12/14/2023, 5:08 PMcrooked-jordan-29960
12/14/2023, 5:22 PMmy_module.py that I will iteratively develop in a notebook.
• in dev notebook, use the %%writefile my_module.py magic in a cell
• in other cells, iteratively develop functions my_logic, and when it is passing test cases, put it in the %%writefile cell
• restart the notebook, and import my_logic from my_module exactly as in the DAG
• now keep developing until satisfied that my_module is solid, once this is true the workflow is using all the same logic developed in the notebook.
I like this because it isn't fancy and the magic part can be easily replaced with copy pasting notebooks cells into the script/module, which sometimes is faster.
I have also used https://github.com/nteract/papermill which let's you parameterize and execute the notebook from python so can run in a DAG @step function. I don't find this as ergonomic with Metaflow, but it does work if people strongly prefer never leaving notebooks for writing modules/scripts.fresh-laptop-72652
12/14/2023, 7:03 PM@cards came out and the section on visualizing results was made. My 2c is that notebooks are nothing special from a dev perspective, just another place where you could run the same python code as anywhere else, so from a client API/docs perspective it's not too specific.
more broadly on dev ergonomics using notebooks, the most common pattern I've seen DS use is to first iterate on code in a notebook, as it becomes more complete the code cells/snippets are refactored out into steps of a flow. Even better IMO is to encourage DS to refactor the code into proper python modules that can be imported/run/tested in isolation – then you can import those functions/classes/etc into metaflow steps as needed, while also keeping them easy to write tests for or reuse