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 tutorial will be to be able to generate predictions on the Craft AI platform. The ML application will be the classification of iris petals.

To achieve this goal, there will be 4 parts.

Prerequisites

  • Python 3.9 or higher is required to be installed on your computer.
  • You also need some packages to complete this tutorial fully, you can use pip for this.
    pip install craft-ai-sdk numpy python-dotenv pandas scikit-learn pyarrow joblib
    
  • We strongly recommend the use of Google Chrome browser to use the UI of the platform.

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, with scripts/command line
  • With the web interface, in a browser

You can do different things with each method :

Action SDK UI
Create Project KO OK
Create Environment KO OK
Create Pipeline OK KO
Check Pipeline's informations OK OK
Deploy Pipeline OK OK

Project & Environment creation

First, you need to create a Project. In the UI, when you arrive on the main page, you have a button in the top right corner to create a "New Project".

gs-setup-create-project

You need to fill 4 main parameters to create a Project. Two of them are filled by default, Organization & Python version. You just need to choose a Project name and to select the folders the platform will access. Set it to / for now.

gs-create-project

Then, once inside the project, you can create an environment. Click on the "New environment" button on the top right corner.

gs-create-env

You need to fill :

  • Environment Name : your choice
  • Tag : Testing
  • Cloud Provider : Scaleway
  • Machine : CPU - CPU Size 1
  • Workers : 1
  • Vector database provider : No database

You can leave every other parameter as default for this tutorial.

gs-create-env-content

Once you click on "Create environment", you will see the environment being created. You can refresh the page to check the status. It takes around 5 minutes for the environment to be created and ready to use.

gs-env-creation

Initialization of Python SDK

To initialize the SDK, you need two informations :

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

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

Then, set the value of environment_url to your environment URL instead of MY_ENVIRONMENT_URL and sdk_token to your access token instead of MY_ACCESS_TOKEN in the following script:

from craft_ai_sdk import CraftAiSdk

sdk = CraftAiSdk(
    environment_url="MY_ENVIRONMENT_URL",
    sdk_token="MY_ACCESS_TOKEN"
)
Finally, run your code in a terminal/notebook.

[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. 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