Skip to main contentIBM ST4SD

The stp command line tool

The stp command line tool provides a conversational-style interface that makes it simple for developers to create and manage virtual experiment packages.

You can always use the -h flag to see additional help for each of the commands mentioned here.

Prerequisites

  • You are familiar with ST4SD terminology such as Virtual Experiment, Parameterised Virtual Experiment Package (PVEP), and Virtual Experiment Instance. You read about it here.
  • Ensure you have correctly installed the ST4SD Runtime Core module (instructions here).

Overview

stp allows you to log in and interact with multiple ST4SD instances, simplifying many of the day-to-day tasks that virtual experiment developers perform. This includes downloading, pushing, importing, creating, updating, and syntax checking PVEPs.

Logging in to your ST4SD instance

To interact with ST4SD instances using stp, we need to log in first. The simplest method is to use the code snippet provided by the Registry UI. If you’re already logged into your OpenShift cluster, you can copy and paste the following command into your terminal to open the ST4SD Registry UI automatically:

open "https://$(oc get route st4sd-authentication -o jsonpath="{.spec.host}")/registry-ui/"

Here you will:

  1. Click on the Login on stp button
  2. Press the copy button in the information box that you’re presented with and paste the content of the information box in your terminal.
  3. Once prompted, type y and press Enter to continue to the authentication service.
  4. Authenticate if necessary and copy the token that is displayed.
  5. Paste the token in the terminal and press Enter. The login process should now be complete.
  • Play

Downloading PVEPs

The ST4SD Registry allows users to easily access and explore Parameterised Virtual Experiment Packages (PVEPs) through a user-friendly web interface. Through the interface, users can browse available experiments, view their details, logs, and the results of their runs. Additionally, users can download experiments by scrolling to the bottom of the page and clicking the “Download JSON” button. There may be instances, however, where they want to perform these actions programmatically. With stp this is trivial: let us imagine we want to download the band-gap-dft-gamess-us experiment that is available on our public registry.

We can simply copy the link and run:

stp package download https://registry.st4sd.res.ibm.com/registry-ui/experiment/band-gap-dft-gamess-us

For the experiment JSON to be downloaded to our currently active directory.

  • Play

Pushing PVEPs

We need to add experiments to our Registry instance before we can view or run them. To do this, we can either create a local PVEP definition from scratch or download it from another instance (e.g., by using the stp package download command). Once we have the definition, we can use stp to push it to our registry.

Assuming our local file is called nanopore-geometry-experiment.json and is in our current directory, we can run:

stp package push nanopore-geometry-experiment.json

And stp will add it to our Registry instance.

  • Play

Importing PVEPs

In the previous sections, we learned how to download PVEPs and add them to our Registry instance using the download and push commands. These commands are versatile and can be used in various scenarios. However, if our goal is simply to download a PVEP from an external instance and add it to our own, stp offers another command, import, that can accomplish this task efficiently.

Copy the link to the experiment you want to import and run:

stp package import https://registry.st4sd.res.ibm.com/registry-ui/experiment/band-gap-dft-gamess-us

To automatically add it to your Registry instance.

  • Play

Creating PVEPs

Parameterised Virtual Experiment Packages (PVEPs) are parameterisations of our experiments that need to be created before they can be added the Registry to be run or shared. stp can help getting started with this by generating a valid, high-level PVEP that the user can later add details to.

This feature requires for the experiment to be in a git repository.

As we need a virtual experiment to test this feature, we will use the nanopore-geometry-experiment experiment as our starting point. Let us start by cloning it and cd-ing into its directory:

git clone https://github.com/st4sd/nanopore-geometry-experiment
cd nanopore-geometry-experiment

To create the PVEP we then need to run:

stp package create --manifest manifest.yaml

The resulting PVEP can be pushed to the Registry using the stp package push command.

  • Play

Updating PVEP definitions

During the development phase of our virtual experiments, we will regularly commit changes to the git repository.

If we are following the set of best practices we have defined, the commit ID will be included in our PVEP, ensuring ST4SD executes the exact version of our experiment, improving results reproducibility. Provided is an example of how this might look like in your PVEP:

{
"name": "nanopore-geometry-experiment",
"source": {
"git": {
"location": {
"url": "https://github.com/st4sd/nanopore-geometry-experiment",
"commit": "85244f5c84d6c0e02aa7a2e1685b004cd0b3cdd2"
}
}

Additionally, we might want to give a specific experiment version an easy-to-remember name by means of a tag. stp makes updating the commit ID and metadata tags of our PVEP as painless as possible by providing the update-definition command. In the nanopore-geometry-experiment folder from the previous example we can run:

stp package update-definition --path nanopore-geometry-experiment.json \
--use-latest-commit \
--tag hello

The PVEP definition may now look similar to the following:

{
"base": {
"packages": [
{
"name": "nanopore-geometry-experiment",
"source": {
"git": {
"location": {
"url": "https://github.com/st4sd/nanopore-geometry-experiment",
  • Play

Checking PVEP syntax

When we manually edit our PVEPs, we risk making mistakes. Fortunately, stp includes a syntax checker that can help us identify and fix our errors. Let’s intentionally introduce a mistake into our nanopore-geometry-experiment PVEP, which we obtained earlier in this tutorial, by adding a nonexistent field to the metadata section.

Here’s how the updated section now looks:

"metadata": {
"package": {
"name": "nanopore-geometry-experiment",
"tags": [],
"license": "",
"maintainer": "",
"description": "",
"nonexistent": true,
"keywords": []

stp will point us to the error when we run stp package test, as such:

stp package test nanopore-geometry-experiment.json
Validation error in instance['metadata']['package']:
Additional properties are not allowed ('nonexistent' was unexpected)
  • Play

Managing multiple ST4SD instances

With stp it is possible to log in to multiple ST4SD instances - which we refer to as contexts - and quickly switch between them.

Getting the currently active context

To see what the currently active context - meaning the ST4SD instance that stp will run commands against - is, you can use the stp context show command. By default, it will only print the name of the context, but an option is provided to also print out the URL of the ST4SD instance for the context.

  • Play

Listing the available contexts

To see what instances you have logged in to, you can use the stp context list command. By default, the results will be printed as a table but this can be disabled with the --simple flag.

  • Play

Changing the active context

In case you need your commands to target a different stp context from the one currently active (as shown by stp context show), you can use the stp context activate command.

  • Play

Renaming a context

If you created a context without specifying the --context-name flag, you might have ended up with a context whose name is the full URL of the instance. You can change this with stp context rename.

  • Play

Deleting a context

If you no longer need one of the existing contexts, you can remove it with stp context delete.

  • Play

Advanced usage

stp offers some additional commands for more advanced useDebugValue, such as interacting with stack-wide settings.

Listing available pull secrets

Not all images are available publicly, some may be private and require authentication. When importing or pushing a package with stp package import or stp package push, stp will check for you if an image pull secret is available for the registries referenced by your PVEP and emit a warning if that isn’t the case. To see what image pull secrets are available to use in ST4SD, you can use the stp stack pull-secrets list command.

Play

Adding an image pull secret

If you are working with a private image registry, you will need to ensure ST4SD has credentials to pull the images. To do so, you can use the stp stack pull-secrets add command: set a name for the secret with the --name flag, pass one or more registries URLs with the --registry flag, and the username with --username. For the password/access token you have two options: either passing it directly via the -t flag, or by writing it in a file and using the --token-file flag (this will prevent leaking the credential in your shell history).

Play

Learn more

Exploring the Registry UI

Learn about all the features of our web interface for browsing and examining virtual experiments packages and runs. You can visit the ST4SD Global Registry for a first look.

No Code, No Fuss creation of Experiments

Use an interactive Build Canvas and a Graph Library to create and modify experiments straight from your browser.

Use the APIs

Learn how to use the ST4SD python client API to run, query, and interact with virtual experiments. The APIs also offer access to a trove of experiment metadata and files such as logs and outputs. You can find more examples in our Jupyter Notebooks example repository.