Create Global Variables

from utils.rc.client.requests import Requests
from utils.rc.client.auth import AuthClient

from utils.rc.dtos.global_variable import GlobalVariable

import logging

logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
Requests.setRootHost("https://staging.dev.rapidcanvas.net/api/")
AuthClient.setToken() #you can find your token in RapidCanvas UI under tools/token

Add Global variables

Global variables are stored as key value pairs at the project level and the name of the variable can be referred to using the “@variable name” notion to pass the corresponding value.

Global variables can be called as part of your pipeline.

globalVariable = GlobalVariable(
    name="global_variable",
    project_id=project.id,
    type="string",
    value="value of the variable" #this value will fetched during pipeline execution
)
globalVariable.create()

Example code with data looks like below:

globalVariable = GlobalVariable(
    name="module_name",
    project_id='3f3e09a9-8081-41a1-aded-0616b87c92fa',
    type="string",
    value="model_output" #this value will fetched during pipeline execution
)
globalVariable.create()

Parameters

Parameters

Parameter name

Parameter description

Data type

Required

Example

name

This is the name of the key in the key value pair of the global variable.

String

Yes

model_name

project

The project ID to which you want to add the global variables.

String

No

‘3f3e09a9-8081-41a1-aded-0616b87c92fa’

type

The data type of the global variable. It is set to string.

String

Yes

string

value

The value assigned to the key. The value is used during the data pipeline execution to store models.

string

Yes

model_default