Choosing environment though valohai-cli

Let’s assume we have something similar to the following set up in Valohai YAML:

- step:
  name: show-variables
  image: python:3.6
  command: printenv

And you have a local project linked to Valohai, then you can run the step with the following.

vh exec run show-variables

This will run the execution in the default environment, which is a Microsoft Azure NC6 instance on the Ireland region for the most projects.

But how to change which hardware or cloud provider to use for a specific execution?


Environment means kind of the same as “compute target” or “instance type” in other similar services. It specifies the cloud provider, server type, and in which region to run your code.

If you have Valohai command-line client already setup, you can run vh environments to get the list of available environments.

vh environments
Name           | Slug                          | Description             | USD$/h | Quota |  Queue
AWS t2.xlarge  | aws-eu-west-1-t2xlarge-no-gpu | EU, Ireland (eu-west-1) | 0.220  |    10 |     11
AWS g2.2xlarge | aws-eu-west-1-g22xlarge       | EU, Ireland (eu-west-1) | 0.740  |    10 |      4
Azure NC12     | azure-westeurope-nc12         | EU, Netherlands         | 1.800  |    10 |      5
# ...

Note that the available set of environments depend on the current user and project.

You can specify which environment to use with the -e parameter of the vh exec run command. Just copy the environment “slug” from the table generated by vh environments.

vh exec run -e aws-eu-west-1-t2xlarge-no-gpu show-variables
Success! Execution created.

Changing the default environment for the project

The -e parameter will change the environment only for that single execution.

To change the default environment of the project go to the Valohai web application and change the Default Environment under Project->Settings->General.


You should ideally select an environment that is in the same data center as your data store, meaning cloud provider and region, to increase download and upload performance.