## Before you start

Please make sure that you have access to a UQCloud endpoint.

To do so, navigate to the "Profile" section and below the section "UQCloud access", note the endpoint URL and your personal access Token.

Those are necessary for UQ[py]Lab to successfully perform UQ computations on the cloud.

## Installation

During this beta testing phase, the UQ[py]Lab package is hosted on a private PyPi server.

To install the package in your local Python environment, execute the following command:

xxxxxxxxxxpip install --index-url https://pypi.uq-cloud.io uqpylab

Notes:

• UQ[py]Lab requires Python version >= 3.7
• It is highly recommended to install UQ[py]Lab in a new Python environment

## Quick start example

The following minimal example can be used to quickly test UQ[py]Lab after installation.

Create a new python script, say draw_samples.py and add the following contents:

xxxxxxxxxxfrom uqpylab import sessions​myToken = 'your token here' # The user's token to access the UQCloud APIUQCloud_instance = 'https://XXXX.uq-cloud.io' # The UQCloud instance to use​# Start the sessionmySession = sessions.cloud(host=UQCloud_instance, token=myToken)# (Optional) Get a convenient handle to the command line interfaceuq = mySession.cli# Reset the sessionmySession.reset()​# Specify the options for a bivariate normal random vectorInputOpts = {    'Marginals': [        {            'Type': 'Gaussian',            'Parameters': [0,1]        },        {            'Type': 'Gaussian',            'Parameters': [0,1]        }    ]}​# Create the bivariate normal random vectormyInput = uq.createInput(InputOpts)​# Draw 10 samples from the bivariate normal distributiontheSamples = uq.getSample(myInput, 10)

## Storing your UQCloud credentials

Notice that in the quick start example one has to explicitly specify the UQCloud endpoint URL and their token in order to gain access to the UQCloud API. You can follow the steps below to store your credentials locally and simplify the UQCloud session starting process in your python scripts.

• Start an interactive python session

xxxxxxxxxxpython -i
• Import sessions from the uqpylab package:

xxxxxxxxxxfrom uqpylab import sessions
• Start a new UQCloud session using the standard procedure:

xxxxxxxxxxmySession = sessions.cloud(host="the instance URL", token="your token")
• Make sure that your session has successfully started, i.e. your credentials are correct. Then execute the following command to store your credentials locally:

xxxxxxxxxxmySession.save_config()

You are all set! From now on, you can start a new UQCloud session in any of your scripts by simply executing:

xxxxxxxxxxmySession = sessions.cloud()

Your credentials will be stored within a directory in your user's home that depends on your operating system. The actual path that they are stored is reported after calling the save_config() function.

## Already a UQLab user?

In the following short video we showcase how a simple UQLab workflow can be translated into a UQ[py]Lab one.

## Known issues

### Server certificate error

Some users may experience the following error when they try to start a new session:

xxxxxxxxxxURLError: verify failed: certificate has expired (_ssl.c:1123)

The underlying cause is rather operating system related and this error is typically appearing and disappearing as the operating system updates. The following workaround can be used to bypass this error:

xxxxxxxxxxfrom uqpylab import sessions​myToken = 'your token here' # The user's token to access the UQCloud APIUQCloud_instance = 'https://XXXX.uq-cloud.io' # The UQCloud instance to use​# Start the sessionmySession = sessions.cloud(host=UQCloud_instance, token=myToken, strict_ssl=False)

Notice that the difference compared to the standard way of starting a new session is that we set the flag strict_ssl to False . This will bypass the SSL certificate validation steps that are taking place during connection. This is done by disabling the host's SSL certificate check while using the urllib.request library, which is handling all calls to the UQCloud API.

Note: Please make sure that you understand the potential risks of resorting to this workaround before using it!