Create the Environment/Kernel

1. Install Anaconda 

This first step is needed to give you the conda command. For example, on Ubuntu Linux:

# check https://repo.anaconda.com/archive for the latest install script and UPDATE this variable if necessary.


condash=Anaconda3-2020.02-Linux-x86_64.sh
cd /tmp
curl -O https://repo.anaconda.com/archive/$condash
 
sha256sum $condash
 
bash $condash

2. Create Python Environment

Use conda to create a python environment containing all needed python modules along with Jupyter Notebook (if needed). For example:

conda create -p ./<path_to_env> python=3.6 pandas matplotlib jupyter tensorflow

3. Install c3python Helper Module

This module contains the get_c3 function which will be used to connect to C3 AI Suite. For example:

conda activate ./<path_to_environment>
pip install git+https://github.com/c3aidti/c3python
# (use your GitHub email address and password at the prompts)

4. Activate the Environment and Load c3 thick Connector

4.1 Source your environment

conda activate ./<path_to_environment>

4.2 Launch Jupyter

To start Jupyter and connect via browser, or launch your python session:

jupyter notebook

If the launch did not automatically open Jupyter in your browser window, note any URL and/or Token printed in your shell output and open Jupyter in your browser: http://localhost:8080/jupyter

Note: You will only be able to access notebooks in the current shell directory and below, so cd to an appropriate top-level directory before launching.

4.3 Open a Notebook

In Jupyter navigate to a .ipynb notebook you wish to open. Once open, change the kernel to the name of your conda environment. For example: py-pythonEnv_venv.

Note: Once changed it should show in the upper right as the active kernel.

4.4 Import c3 Object

To import the c3 object with the get_c3 helper function, add the following code in your Jupyter notebook:

from c3python import get_c3
c3 = get_c3('http://<vanity_url>', '<tenant>', '<tag>')

For example, assuming you are running the docker container on your local machine, you would have the following for a "test/c4" tenant and tag:

from c3python import get_c3
c3 = get_c3('http://0.0.0.0:8080', 'test', 'c4', 'thick')
## some report using localhost instead of 0.0.0.0 in the URL worked for them too.

Note: The above loads the 'thick' connector, which is now the officially supported version. You can load the thin connector by replacing thick with thin in the get_c3 function call.

4.5 Enter Credentials

If successful the above code should prompt you for a username and password when run in the Jupyter cell:

The username and password are the BA / BA used to access the C3 AI static console.


  • No labels