Chef Recipe | How to cook a joke

A simple example to learn how to use Chef and it’s ingredients
recipe
python
jupyter
Author

Davide Fornelli

Published

November 18, 2021

Call graph

Call graph

Configuration

Parameters

gist_user = 'davidefornelli'
gist_chef_id = '1bc116f05d09e598a1a2dcfbb0e2fc22'
gist_ingredients_id = '5c75b7cdea330d15dcd93adbb08648c3'
ingredients_to_import = [
    (gist_ingredients_id, 'joking.py')
]

Configure environment

%pip install httpimport
Requirement already satisfied: httpimport in /home/daforne/repos/github/davidefornelli/cookbook/.venv/lib/python3.7/site-packages (0.7.2)
Note: you may need to restart the kernel to use updated packages.

Import chef

import httpimport

with httpimport.remote_repo(
    ['chef'],
    f"https://gist.githubusercontent.com/{gist_user}/{gist_chef_id}/raw"
):
    import chef

Import ingredients

def ingredients_import(ingredients):
    for ingredient in ingredients:
        mod, package = chef.process_gist_ingredient(
            gist_id=ingredient[0],
            gist_file=ingredient[1],
            gist_user=gist_user
        )
        globals()[package] = mod


ingredients_import(ingredients=ingredients_to_import)
Collecting pyjokes
  Using cached pyjokes-0.6.0-py2.py3-none-any.whl (26 kB)
Installing collected packages: pyjokes
Successfully installed pyjokes-0.6.0

Tell me a joke

joking.tell_me_a_joke()
How many programmers does it take to kill a cockroach? Two: one holds, the other installs Windows on it.