Python SDK

INFO

This SDK tool is under active development For any bug found or featur request, feel free to open any issue regarding this SDK tool in our in our community repo

#Requirements

  • Python 3.8+
  • Pip | Poetry

#Installation

Install it directly into an activated virtual environment:

pip
poetry
Copy

pip install instill-sdk

WARNING

If your host machine is on arm64 architecture (including Apple silicon machines, equipped with m1/m2 processors), there are some issues when installing grpcio within conda environment. You will have to manually build and install it like below. Read more about this issue here.


GRPC_PYTHON_LDFLAGS=" -framework CoreFoundation" pip install grpcio --no-binary :all:

#Check Import

After installation, you can check if it has been installed correctly:


python
>>> import instill
>>> instill.__version__

#Config Instill Core or Instill Cloud Instance

Before we can start using this SDK, you will need to properly config your target instance. We support two ways to setup the configs, which are

#Config file

create a config file under this path ${HOME}/.config/instill/sdk/python/config.yml, and within the file you will need to fill in some basic parameters for your desired host.1

Within the config file, you can define multiple instances with the alias of your liking, later in the SDK you can refer to this alias to switch between instances.2


hosts:
alias1:
url: str
secure: bool
token: str
alias2:
url: str
secure: bool
token: str
...
...

Example:


hosts:
default:
url: localhost:8080
secure: false
token: instill_sk***
cloud:
url: api.instill.tech
secure: true
token: instill_sk***

#At runtime

If you do not like the idea of having to create a config file, you can also setup your target instance by doing the following at the very beginning of your script.


from instill.configuration import global_config
global_config.set_default(
url="api.instill.tech",
token="instill_sk***",
secure=True,
)

#Usage

INFO

Python SDK is currently under some refactoring jobs, the section will be populated soon.

#Footnotes

  1. You can obtain an api_token, by simply going to Settings > API Tokens page from the console, no matter it is Instill Core or Instill Cloud.

  2. SDK will look for alias default first. If it is not found, it will load the config for the first alias in the config file.

Last updated: 4/30/2024, 7:31:30 AM