Skip to content

Environment Validation

It is possible in UbiOps to create custom environments that specify the settings and dependencies of your environment. In the case of Python, you'll typically need the following 2 files:

  • requirements.txt to specify the Python packages that need to be installed
  • ubiops.yaml to specify OS-level dependencies

If you are not sure whether your have formatted these files correctly, you can use validation functions from both the UbiOps Python Client Library and the UbiOps CLI to check your Python environment files. This saves you the time of having to upload the environment files to UbiOps to see if the file structure is correct. This page gives a short overview of the validation functions.

Validate requirements file

To validate a requirements.txt file, both the UbiOps Python Client Library and the UbiOps CLI provide a method to check the file structure. Both methods are described below.

Client Library

To validate a requirements.txt file with the Client Library, use the ubiops.utils.validate_requirements_file function. This function takes the path to the requirements.txt file as input and returns a boolean indicating whether the file structure is valid or not.

Example

from ubiops import utils

# Validate the given requirements.txt
requirements_file_name = "requirements.txt"
return_value = utils.validate_requirements_file(file_path=requirements_file_name)
print("Return value of requirements validation: ", return_value)

CLI

To validate a requirements.txt file with the CLI, use the ubiops validate requirements command. This command takes the path to the requirements.txt file as argument and outputs in the terminal whether the file structure is valid or not.

Example

ubiops validate requirements requirements.txt

Validate ubiops.yaml file

To validate a ubiops.yaml file, both the UbiOps Python Client Library and the UbiOps CLI provide a method to check the file structure. Both methods are described below.

Client Library

To validate a ubiops.yaml file, use the ubiops.utils.validate_ubiops_yaml_file function. This function takes the path to the ubiops.yaml file as input and returns a boolean indicating whether the file structure is valid or not.

Example

from ubiops import utils

# Validate the given ubiops.yaml
file_path = "ubiops.yaml"
return_value = utils.validate_yaml_file(file_path=file_path)
print("Return value of yaml validation ", return_value)

CLI

To validate a ubiops.yaml file with the CLI, use the ubiops validate yaml command. This command takes the path to the ubiops.yaml file as argument and outputs in the terminal whether the file structure is valid or not.

Example

ubiops validate yaml ubiops.yaml

Disclaimer

The validation functions are provided as a convenience to help you check if you correctly formatted your environment files. However, they do not guarantee that your environment will work on UbiOps. The validation functions do not check the contents of the files, only the file structure. For more information on the validation functions, see the documentation for the UbiOps Python Client Library and the UbiOps CLI.