Run a Sample Workload in JupyterLab Using Teradata AI Unlimited
|This product is in preview and is subject to change. If you’re interested in learning more about this offering, contact Teradata Support.|
This document walks you through a simple workflow where you can use JupyterLab to:
Deploy on-demand, scalable compute
Connect to your external data source
Run the workload
Suspend the compute
Deploy and configure Teradata AI Unlimited Workspaces and JupyterLab. See Deploy and Setup Teradata AI Unlimited Workspace Service Using Docker and Deploy a Teradata AI Unlimited Interface Using Docker.
Copy and retain the following:
CSP environment variables from your Console. See Environment Variables.
API Key from workspace service.
%help <command> for details on any magic command. See Teradata AI Unlimited JupyterLab Magic Command Reference for more details.
Connect to JupyterLab using the URL: http://localhost:8888 and enter the token when prompted.
Connect to the workspace service using the API Key.
%workspaces_config host=<ip_or_hostname>, apikey=<API_Key>, withtls=F
Create a new project.
Currently, Teradata AI Unlimited supports AWS and Azure.
%project_create project=<Project_Name>, env=<CSP>, team=<Project_Team>
[Optional] Create an authorization object to store the CSP credentials.
REGIONwith your values.
%project_auth_create name=<Auth_Name>, project=<Project_Name>, key=<ACCESS_KEY_ID>, secret=<SECRET_ACCESS_KEy>, region=<REGION>
Deploy an engine for the project.
Replace the <Project_Name> to a name of your choice. The size parameter value can be small, medium, large, or extralarge. The default size is small.
%project_engine_deploy name=<Project_Name>, size=<Size_of_Engine>
The deployment process takes a few minutes to complete. On successful deployment, a password is generated.
Establish a connection to your project.
When a connection is established, the interface prompts you for a password. Enter the password generated in the previous step.
Run the sample workload.
Make sure that you do not have tables named SalesCenter or SalesDemo in the selected database.
Create a table to store the sales center data.
First, drop the table if it already exists. The command fails if the table does not exist.
DROP TABLE SalesCenter; CREATE MULTISET TABLE SalesCenter ,NO FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT, DEFAULT MERGEBLOCKRATIO ( Sales_Center_id INTEGER NOT NULL, Sales_Center_Name VARCHAR(255) CHARACTER SET LATIN NOT CASESPECIFIC) NO PRIMARY INDEX ;
Load data into the SalesCenter table using the
%dataload DATABASE=<Project_Name>, TABLE=SalesCenter, FILEPATH=notebooks/sql/data/salescenter.csv
Unable to locate the salescenter.csv file? Download the file from GitHub Demo: Charting and Visualization Data.
Verify that the data was inserted.
SELECT * FROM SalesCenter ORDER BY 1
Create a table with the sales demo data.
DROP TABLE SalesDemo; CREATE MULTISET TABLE SalesDemo ,NO FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT, DEFAULT MERGEBLOCKRATIO ( Sales_Center_ID INTEGER NOT NULL, UNITS DECIMAL(15,4), SALES DECIMAL(15,2), COST DECIMAL(15,2)) NO PRIMARY INDEX ;
Load data into the SalesDemo table using the
%dataload DATABASE=<Project_Name>, TABLE=SalesDemo, FILEPATH=notebooks/sql/data/salesdemo.csv
Unable to locate the salesdemo.csv file? Download the file from GitHub Demo: Charting and Visualization Data.
Verify that the sales demo data was inserted successfully.
SELECT * FROM SalesDemo ORDER BY sales
Open the Navigator for your connection and verify that the tables were created. Run a row count on the tables to verify that the data was loaded.
Use charting magic to visualize the result.
Provide X and Y axes for your chart.
%chart sales_center_name, sales, title=Sales Data
Drop the tables.
DROP TABLE SalesCenter; DROP TABLE SalesDemo;
Back up your project metadata and object definitions in your GitHub repository.
Suspend the engine.
Congrats! You’ve successfully run your first use case in JupyterLab.
Interested in exploring advanced use cases? Coming soon! Keep watching this space for the GitHub link.
Learn about the magic commands available in JupyterLab. See Teradata AI Unlimited JupyterLab Magic Command Reference.
|If you have any questions or need further assistance, please visit our community forum where you can get support and interact with other community members.|