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

*Pipelines have one step for the moment. Multi-step pipelines will be available soon.

We’ve already created for you :

  • A project
  • A repository GitHub linked to the project
  • An environment setup in the project with datastore and workers

Set up the Python SDK

The Python SDK can be installed with pip from a terminal.

pip install craft-ai-sdk

For this use case, you also need NumPy if you don’t have already installed it on your machine.

pip install numpy

Initialization of Python SDK

Run the following commands in a Python terminal to initialize the SDK:

  1. Set the value of CRAFT_AI_ENVIRONMENT_URL into a local environment variable with your environment URL (you should get it from the Environment page on the UI. Environnement URL is NOT the HTML address of the UI).

    Set the value of CRAFT_AI_SDK_TOKEN into a local environment variable (On the UI, click on your name in the top right corner and 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 to yourself.)

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

    #!/bin/bash
    
    export CRAFT_AI_ENVIRONMENT_URL="*your-env-URL*"
    export CRAFT_AI_ACCESS_TOKEN="*your-token-acces*"
    
  2. Here, we use the source command to define the values of the variables written to the file.

    source .env-test-platform-craft-ai
    
  3. Execute the following Python code to set up SDK Python object.

    import os
    from craft_ai_sdk import CraftAiSdk
    
    sdk = CraftAiSdk(
        environment_url=os.environ.get("CRAFT_AI_ENVIRONMENT_URL"),
        sdk_token=os.environ.get("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