cancel
Showing results for 
Search instead for 
Did you mean: 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with cookiecutter Prompts in Databricks Notebooks

vieiralaura
New Contributor

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!

1 REPLY 1

guigasque
New Contributor II

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.

 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now