Install and run the Workbench CLI
Categories:
Prior reading: Command-line interface overview
Purpose: This document provides detailed instructions for installing the Workbench CLI package and using the Workbench Command Line Interface.
Installation
Install dependencies
Note
If you're using the CLI on a Verily Workbench cloud app or in Google Cloud Shell, you can skip the install dependencies steps outlined here.The following dependencies are required to run the CLI on a local machine.
A variety of methods can be used to install these tools. The instructions below show valid paths for both MacOS and Linux.
MacOS
Using homebrew:
-- Install Google Cloud SDK
brew install google-cloud-sdk
-- Install Java 17 using sdkman
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk default java 17.0.11-tem
-- Verify Java is now set to 17
java --version
-- Install jq
brew install jq
Linux
sudo apt update
-- Install Java 17 using sdkman
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk default java 17.0.11-tem
-- Verify Java is now set to 17
java --version
-- Install jq
sudo apt install jq
First installation
To install the latest version:
curl -L https://storage.googleapis.com/workbench-public/workbench-cli/download-install.sh | bash && export SUPPRESS_GCLOUD_CREDS_WARNING=true
# Optional: Move to somewhere in PATH
sudo mv wb /usr/local/bin
Re-installing or updating to the latest version
To update the Workbench CLI package, simply run the initial installation commands again.
Re-installing the Workbench CLI package will overwrite any existing installation, meaning that all JARs and scripts will be overwritten, but it will not modify your $PATH
. If you have added the location of the Workbench CLI to your $PATH
, you will therefore need to ensure its location is up to date in your $PATH
again after each install.
Using a specific version
To install a specific version, run this command before running the 'first installation' commands. Make sure to change the version number provided in the example to the specific version you want to install:
export TERRA_CLI_VERSION=0.418.0
Updating to the latest version in your cloud app
To update the Workbench CLI package in your app, you'll need to open a terminal and run these commands:
curl -L https://storage.googleapis.com/workbench-public/workbench-cli/download-install.sh | bash && export SUPPRESS_GCLOUD_CREDS_WARNING=true
# Optional: Move to somewhere in PATH.
mv wb $HOME/.local/bin
# Set the authentication mechanism to 'MANUAL' as your app doesn't have an internet browser.
wb config set browser MANUAL
# Re-authenticate, following the prompt.
wb auth login
# Provide a workspace to which to point the workpace context, which has been reset.
wb workspace set --id=<YOUR_WORKSPACE_ID>
Tool dependencies
Note
If you're runningwb utility
commands from anywhere other than an app on Workbench, it's necessary to install the tools listed below locally. You may skip this section if you're running wb utility
commands on a Workbench app.
The following installation instructions are for both MacOS and Linux.
gcloud
- Make sure you have Python installed, then download the .tar.gz archive file from the Google Cloud CLI installation page. Rungcloud version
to verify the installation.gsutil
- This is included in the Google Cloud CLI, or available separately here. Verify its installation withgsutil version
(also printed as part ofgcloud version
)bq
- This is included with the Google Cloud CLI. More details are available here. Similarly, verify its installation withbq version
.nextflow
- Install by downloading abash
script and running it locally. Create anextflow
directory somewhere convenient (e.g.,$HOME/nextflow
) and switch to it. Then runcurl -s https://get.nextflow.io | bash
. Finally, move thenextflow
executable script to a location on the$PATH
by runningsudo mv nextflow /usr/local/bin/
. Verify the installation withnextflow -version
.git
- Follow instruction here for installing Git on your platform.
Installing those packages will make the applications available in wb
by running, for example, wb gsutil ls
. When these tools are run through wb
, environment variables are set based on resources in the active workspace, and context such as the active Google Cloud project is set automatically.
Running
Usage
For a list of available commands, please see the List of Commands. You can find context-specific CLI usage examples in the CLI Usage Examples section.
Exit codes
The CLI sets the process exit code as follows.
- 0 = Successful program execution
- 1 = User-actionable error (e.g., missing parameter, workspace not defined in the current context)
- 2 = System or internal error (e.g., error response from the Workbench server)
- 3 = Unexpected error (e.g., Java exception)
Third-party application exit codes will be passed through to the caller. For example, if gcloud --malformedOption
returns exit code 2
, then wb gcloud --malformedOption
will also return exit code 2
.
Access requirements
Login (authentication)
If you are running the Workbench CLI from anywhere other than an app in Workbench, you must authenticate yourself.
The following command launches an OAuth flow that creates a new tab in your web browser window where you will complete the login process:
wb auth login
If the machine where you're running the CLI does not have a web browser available to it, run the following commands instead:
wb config set browser MANUAL
wb auth login
This will trigger the use of a manual login flow that does not involve the web browser.
Note
If you're using the CLI on an app in Workbench, you don't need to run any of those commands; you're already logged in by default when you open the app. You can verify this by runningwb auth status
.
Billing
In order to perform any operations that incur a cost on Workbench (e.g., creating a workspace and resources within it), you need access to a billing account via a spend profile. An administrator (user with admin permissions) can grant you access.
External data
In order to read data from or write data to a private external resource from Workbench, you must grant the appropriate data access permissions to your proxy group. Run wb auth status
to view the email address of your proxy group.
To learn more about sharing resources with other users, see Access control and sharing.
Troubleshooting
Clear context
Clear the context file and all credentials. This will require you to login and select a workspace again.
cd $HOME/.workbench
rm context.json
rm StoredCredential
Uninstalling
There is not yet an uninstaller. You can clear the entire context directory, which includes the context file, all credentials, and all JARs. This will then require a reinstall (see above).
rm -R $HOME/.workbench
Last Modified: 13 November 2024