whisk.setup

Module Contents

Functions

log_subprocess_output(logger_with_level, log_lines)

Calls the logger on each of the log_lines. The log lines are prefixed with

exec(desc, cmd)

Executes the cmd, and logs desc prior to execution and "DONE" after.

init_git_repo()

init_direnv()

exec_setup(project)

Sets up an environment for the given project.

notebook_exists(notebook_path)

set_example_notebook_kernel(nbenv)

Updates the NOTEBOOK_EXAMPLE_PATH notebook kernel to use

log_success(dir)

Logs that the setup completed successfully and provides next steps.

log_pip_freeze()

Logs the output of pip freeze at the debug level.

setup(dir)

Sets up the project environment.

Attributes

logger

NOTEBOOK_EXAMPLE_PATH

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_levelLogger

A logger instance (ex: logger.debug).

log_linesstr

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.

descstr

A description of the command operation.

cmdstr

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.

projectwhisk.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

dirstr

The full path to the project directory.