Help with cookiecutter Prompts in Databricks Notebooks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 08:25 AM
Hi everyone! I’m working on using cookiecutter to help us set up consistent project templates on Databricks. So far, it’s mostly working, but I’m struggling with the prompts – they’re not displaying well in the Databricks environment.
I’ve tried some workarounds, but I’m hoping someone has a simpler solution or knows of any future updates to improve compatibility in notebook environment.
Here’s what I’ve done so far:
def get_user_input():
project_date = input("What is your project date? YYYYMMDD: ")
client = input("What is your client name?: ")
id_project = input("What is your project ID? XXX: ")
return {
"project_date ": project_date ,
"client": client ,
"id_project ": id_project
}
cookiecutter(
repo_url,
directory='databricks',
no_input=True,
extra_context=get_user_input()
)
I’m looking for tips on making these prompts more user-friendly and avoiding repeated input requests. If anyone has done something similar or has tips for handling cookiecutter in Databricks, I’d really appreciate your advice!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2025 08:56 AM - edited 08-20-2025 08:57 AM
Hi! Great initiative using cookiecutter to standardize project templates on Databricks — I’ve been exploring similar workflows.
I ran into the same issue with prompts not displaying well in the notebook environment. One workaround I found effective was running cookiecutter directly in a notebook cell without custom input() functions. Databricks does support interactive prompts to some extent, especially when using %pip install followed by a Python restart (dbutils.library.restartPython()), and then calling cookiecutter() with the template URL.
Here’s a snippet that worked for me:
from cookiecutter.main import cookiecutter
cookiecutter(
'https://github.com/drivendata/cookiecutter-data-science',
checkout='v1'
)
This approach triggers the built-in prompts from the template, and they seem to work more reliably than custom input() calls. It also avoids repeated input requests since cookiecutter handles the flow internally.