whisk.setup

Module Contents

whisk.setup.logger[source]
whisk.setup.NOTEBOOK_EXAMPLE_PATH = notebooks/getting_started.ipynb[source]
whisk.setup.log_subprocess_output(logger_with_level, log_lines)[source]

Calls the logger on each of the log_lines. The log lines are prefixed with whisk.cli.log_tree.CHILD_TREE_NODE_PREFIX.

logger_with_level : Logger
A logger instance (ex: logger.debug).
log_lines : str
A string of log lines separated with \n.
whisk.setup.exec(desc, cmd)[source]

Executes the cmd, and logs desc prior to execution and “DONE” after. If the cmd has stdout or stderr output this is logged as well.

If the exit code is nonzero, raises a SystemExit execption.

desc : str
A description of the command operation.
cmd : str
The command to execute.
whisk.setup.init_git_repo()[source]
whisk.setup.init_direnv()[source]
whisk.setup.exec_setup(project)[source]

Sets up an environment for the given project.

project : whisk.project.Project
A whisk project.
whisk.setup.notebook_exists(notebook_path)[source]
whisk.setup.set_example_notebook_kernel(nbenv)[source]

Updates the NOTEBOOK_EXAMPLE_PATH notebook kernel to use the kernel with name nbenv.

whisk.setup.log_success(dir)[source]

Logs that the setup completed successfully and provides next steps.

whisk.setup.log_pip_freeze()[source]

Logs the output of pip freeze at the debug level.

whisk.setup.setup(dir)[source]

Sets up the project environment.

Setup performs the following actions after changing the working directory to dir:

  • Creates a Python3 venv named “venv”
  • Installs the dependencies listed in the project’s requirements.txt.
  • Initializes a Git repo
  • Creates an iPython kernel for use in Jupyter notebooks with name = <project_name>.
  • Creates a .envrc file based on .envrc.example for use with direnv. direnv loads environment variables listed in .envrc into the shell and is also used to auto-activate and deactivate the venv when entering and exiting the project directory.
  • Calls direnv allow . so the .envrc file can be loaded.
  • Makes an initial Git commit
dir : str
The full path to the project directory.