Skip to content

Get Started

The goal of this use case is to accompany you in understanding the mechanics of the platform with a simple and basic machine learning application.

The final goal of this get started will be to be able to generate predictions on the Craft AI platform. The model used to generate predictions will be the iris one, but you can use any Python code.

To achieve this goal, we will go through several parts:

Part 0 : Setup

This page is about the setup of the platform in your Python code and in the Craft AI platform UI.

There are 2 ways to access the platform:

  • With the Python SDK, in line of code
  • With the web interface, in a browser

Prerequisites

  • Python 3.8 or higher is required to be installed on your computer.
  • We strongly recommend the use of Google Chrome browser to use the UI of the platform.

setup3

We already have:

Set up the Python SDK

The Python SDK can be installed with pip from a terminal. And, for this use case, you also need NumPy.

pip install craft-ai-sdk numpy

Initialization of Python SDK

Copy and paste the following commands into a Python terminal or script to initialize the SDK:

from craft_ai_sdk import CraftAiSdk

sdk = CraftAiSdk(
    environment_url="MY_ENVIRONMENT_URL",
    sdk_token="MY_ACCESS_TOKEN"
)

Set the value of environment_url to your environment URL instead of MY_ENVIRONMENT_URL. You can find this URL on the Environments page in the UI. The Environment URL is NOT the address of the page in your browser.

Setup Step 6

Set the value of sdk_token to your access token instead of MY_ACCESS_TOKEN. On the UI, click on your name in the top right corner, then go to the “Parameters” page. There, you can generate and find your SDK token at the bottom. The SDK token is strictly personal. You must keep it confidential.

Setup Step 5

Finally, run your code.

[Recommended] Setup your credential with a .env file

A good practice would be to create a script that contains the setup of these 2 local environment variables. For example, you could create an .env file.

File tree
.
├── .env
├── my-sdk-script.py
  1. Create a .env file.

    .env
    CRAFT_AI_ENVIRONMENT_URL=MY_ENV_URL
    CRAFT_AI_SDK_TOKEN=MY_ACCESS_TOKEN
    
  2. Install dotenv lib in Python using pip

    pip install python-dotenv
    
  3. Execute the following Python code to set up SDK Python object.

    my-sdk-script.py
    import os
    from dotenv import load_dotenv
    from craft_ai_sdk import CraftAiSdk
    
    load_dotenv()
    
    sdk = CraftAiSdk(
        environment_url=os.getenv("CRAFT_AI_ENVIRONMENT_URL"),
        sdk_token=os.getenv("CRAFT_AI_ACCESS_TOKEN")
    )
    

Success

🎉 Well done! You’re ready to execute your first code on the platform!

What's next ?

Now that we have configured the platform, we can create our first objects and run a “Hello World” on the platform.

Next step: Part 1: Deploy a simple pipeline