jupyter / jupyter_client

Jupyter protocol client APIs
https://jupyter-client.readthedocs.io
BSD 3-Clause "New" or "Revised" License
383 stars 283 forks source link

Get user input in a notebook via a subprocess #846

Open gusostow opened 2 years ago

gusostow commented 2 years ago

I'm trying to figure out a way to take user input for an external AWS credential provider. This boils down to sending input from the Jupyter frontend to a subprocess and also displaying stderr.

# get-pass.py
from getpass import getpass

password=  getpass(prompt=f"password: ")
print("got pass")

In the notebook

import os
import subprocess

subprocess.run(
    ["python", "get-pass.py"],
    check=True,
)

I realize the above obviously won't work, but what direction should I go in to implement this via Jupyter APIs? I'm willing to do some hacking. Sorry if this isn't the right place to post this.