Create a new project

import sys

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

from utils.rc.dtos.project import Project

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

Note: If you are opening the Notebook editor from the UI, you do not have to pass any token.

Project creation

Project creation needs to have an associated environment. Ensure to create an environment before creating a project because you have to pass the env.id in which you want to execute this project.

project = Project.create(
    name='Employee',
    description='Employee_promotion',
    createEmpty=True,
    envId=env.id
)
project.id

If you want to run the project in an environment, create an environment and use its ID in the project. For more information to create an environment, see creating an environment.

Parameters

Parameters

Parameter name

Parameter description

Data type

Required

Example

name

The name of the project.

String

Yes

Employee

description

The description for the project.

String

No

Employee_promotion

createEmpty

Indicates if a new project should be created deleting the existing project with the same name

Boolean

Yes

True or False

envId

The environment in which you want to execute the project. For this, you have to provide the ID of the environment.

string

Yes

‘4dae540d-1717-4b87-8c1e-e60357c7f7f4’

Deleting a project

The following codeblock must be used to delete a project.

project.deleteProject(project.id)

Sample code block for deleting a project:

project.deleteProject('617fea9f-b7d6-40d8-9237-a9c19ac6c386'))

Fetching all projects in a tenant

Use this code block to get the list of projects in a tenant.

project.getAllProjects()

Example response:

{'featureselection': <utils.rc.dtos.project.Project at 0x7f779ad889a0>,
 'dropduplicates': <utils.rc.dtos.project.Project at 0x7f779ad882b0>,
 'onehotencoding': <utils.rc.dtos.project.Project at 0x7f779ad88a90>,
 'tsfresh': <utils.rc.dtos.project.Project at 0x7f77a03d9540>,
 'Timetoevent': <utils.rc.dtos.project.Project at 0x7f77a03d83a0>,
 'forwardfill': <utils.rc.dtos.project.Project at 0x7f77a03d9180>,
 'project1test': <utils.rc.dtos.project.Project at 0x7f779acb7b20>,
 'newproject1': <utils.rc.dtos.project.Project at 0x7f779acb7c10>,
 'test': <utils.rc.dtos.project.Project at 0x7f779acb7d30>,
 'newtimeseries': <utils.rc.dtos.project.Project at 0x7f779acb7ca0>,
 'Employee': <utils.rc.dtos.project.Project at 0x7f779acb7cd0>,
 'Employeepromotion': <utils.rc.dtos.project.Project at 0x7f779acb7be0>}

Fetching all datasets in a project

Use this code block to get all the datasets in a project.

project.getAllDatasets()

Example response:

{'view_Recipe': <utils.rc.dtos.dataset.Dataset at 0x7f779ab0d3f0>,
 'output_duplicate ': <utils.rc.dtos.dataset.Dataset at 0x7f779ab308b0>,
 'dataset_new1': <utils.rc.dtos.dataset.Dataset at 0x7f779ab31db0>,
 'output_duplicates': <utils.rc.dtos.dataset.Dataset at 0x7f779ab31a20>,
 'raw_w_drop_bad_cols': <utils.rc.dtos.dataset.Dataset at 0x7f779ab32d40>}

Fetching all scenarios in a project

Use this code block to fetch all scenarios in a project.

project.get_all_scenarios()
[Scenario(name='DEFAULT', project_id='011d76b2-9dfb-43a8-8ea8-fe9ab36ffdd6', _id='50a6a293-cfa9-4941-ab7a-c0b2538ebb5d', description='Default scenario without segments', variables=[], shared_variables={}, segment_ids=[])]

Fetching all recipes in a project

Use this code block to fetch all recipes in a project.

project.getAllRecipes()

Example response:

{'dataset_new1 Recipe 2': <utils.rc.dtos.recipe.Recipe at 0x7f5f0c644a90>,
 'Recipe': <utils.rc.dtos.recipe.Recipe at 0x7f5f0c6454b0>,
 'dataset_new1 Recipe': <utils.rc.dtos.recipe.Recipe at 0x7f5f0c645570>}

Fetching all variables in a project

Use this code block to fetch all variables in a project.

project.get_all_variables()

Example response:

[Scenario.Variable(variable_name='input_dataset', variable_value='dataset_new1', recipe_name='dataset_new1 Recipe 2', transform_name='Drop Duplicates'),
 Scenario.Variable(variable_name='output_dataset', variable_value='output_duplicate ', recipe_name='dataset_new1 Recipe 2', transform_name='Drop Duplicates'),
 Scenario.Variable(variable_name='inputDataset', variable_value='output_duplicate ', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='dropConstantCols', variable_value='Yes', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='dropIDLikeCols', variable_value='Yes', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='dropMissingCols', variable_value='Yes', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='dropHighlyCorrCols', variable_value='No', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='targetCol', variable_value='price', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='OutputDataset', variable_value='raw_w_drop_bad_cols', recipe_name='Recipe', transform_name='Drop Bad Columns Regression'),
 Scenario.Variable(variable_name='input_dataset', variable_value='dataset_new1', recipe_name='dataset_new1 Recipe', transform_name='Drop Duplicates'),
 Scenario.Variable(variable_name='output_dataset', variable_value='output_duplicates', recipe_name='dataset_new1 Recipe', transform_name='Drop Duplicates')]

Adding a dataset in Jupyter Notebook to a project

Use this code block to add a dataset to a project.

employee = project.addDataset(
dataset_name='employee',
dataset_description='Employee Promotion Dataset',
dataset_file_path='Car_Price.csv' #path as per your folder structure in Jypyter
)

Example response:

INFO:Creating new dataset by name:employee1
INFO:Uploading file Car_Price.csv ....
INFO:Uploading Done

Parameters

The following table describes about each parameter you must pass in the code block to add a dataset to a project.

Parameters

Parameter name

Parameter description

Data type

Required

Example

dataset_name

The name of the dataset.

String

Yes

employee

dataset_description

The description for the dataset.

String

No

Employee Promotion Dataset

dataset_file_path

The path of the file. This should be as per the folder structure in Jypyter.

Yes

Car_Price.csv

Deleting a dataset in a project

Use this code block to delete a dataset from the project.

project.deleteDataset('id')

Sample code:

project.deleteDataset('c4bef95e-c16f-42f8-a82c-1262d14d7d69')

Example response:

INFO:Dataset deleted

Fetching all datasets in a project

Use this code block to fetch all input and output datasets in a project.

project.getAllDatasets()

Example response:

{'view_Recipe': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c2b00>,
 'employee1': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c1c00>,
 'output_duplicate ': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c3490>,
 'dataset_new1': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c0e80>,
 'output_duplicates': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c3b80>,
 'raw_w_drop_bad_cols': <utils.rc.dtos.dataset.Dataset at 0x7fe7a55c1c30>,
 'employee': <utils.rc.dtos.dataset.Dataset at 0x7fe7e85dc4c0>}