5. Installing the SDK

This article describes the SDK installation process. It contains the following sections:

How to Acquire a Copy of the SDK

At present, consult with your Sight Machine Engagement Team on how to acquire a copy of the Sight Machine SDK.

Checking Python Version Compatibility

The SDK is compatible with Python versions 2.7, 3.5, and 3.6. If you intend to develop analytics to live in the Sight Machine platform, Python 3.7 is recommended.

Installing the SDK

The installation process involves two steps:

  1. Setting up the SDK (installing from either the source or a package).
  2. Confirming that you installed the SDK and its dependencies properly.
Step Command
Setup

Installing the SDK from source:

pip install -r requirements.txt
python setup.py install
			

Installing the SDK from a package:

pip install <filename>.whl
			

Confirmation

import sightmachinesdk as sm
			

Authenticating

Contact your Sight Machine Engagement Team to request credentials.

To authenticate:

  1. Initialize a Client:
  2. cli = sm.Client('<tenantname>', auto_login=False)
    	
  3. Log in using the method provided by Sight Machine:
  4. cli.login('basic', email='<user@domain.com>', password='<password>')
    
    cli.login('apikey', key='<apikey>')
    	

NOTE: An up-to-date SSL client, such as OpenSSL, must be installed locally on the machine that is running the SDK. Otherwise, an SSL error will likely occur when authenticating with the SDK Client.

Hello World Example

This minimal example allows you to confirm that you installed the SDK and dependencies correctly. It produces a visualization for a simple dataframe.

import sightmachinesdk as sm
import pandas as pd
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)

cli = sm.Client('<tenantname>', auto_login=False)

df = pd.DataFrame({
   'a': [0, 0, 1, 2, 1, 3, 2, 3, 4, 4],
   'b': [2, 1, 0, 0, 1, 1, 2, 3, 2, 1],
   'c': ['q', 'r', 'q', 'q', 'r', 'q', 'r', 'r', 'r', 'q']
})

plt = cli.get_plot('line', df)
iplot(plt.plot())

If you run into any errors, see Reference Information for more details.