Skip to main content

Aito Python SDK

Info:

Check Github for the latest source code and documentation for more information.

Maintainer:

Aito <admin@aito.ai>

PyPI PyPI version

About

The Aito Python SDK is an open-source library that helps you to integrate your Python application to Aito quicker and more efficiently.

The SDK also includes the Aito Command Line Interface (CLI) that enables you to interact with Aito using commands in your command-line shell, e.g: infer a table schema from a file or upload a file to Aito.

API versions

Each Aito API version has its own package, whose meaning never changes:

from aito.v2 import Client      # the v2 API  (`from aito.v1 import Client` for v1)

# the public read-only sandbox; use your own instance URL and key in production
client = Client('https://shared.aito.ai/db/aito-demo',
                'yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi', env='v2')
prediction = client.predict(
    from_table='invoices', where={'Description': 'cloud services'}, predict='GLCode')
print(prediction.first.value, prediction.first.probability)   # E002 0.83...

aito.Client is the default version, and moves only on a major release of this package: since aitoai 1.0 it is the v2 client (0.x: v1). Quickstarts can use it; production code should import the version it means, aito.v1 or aito.v2, so an upgrade cannot change the API underneath it. To stay on v1: from aito.v1 import Client, or pin aitoai<1.

The pre-0.7 paths (aito.client, aito.client.v2, aito.api) were removed in 1.0; importing one raises an ImportError naming its replacement. The command-line tool still talks to the v1 API in 1.x: v2 support arrives as an opt-in in a 1.x minor release, and the CLI’s default moves to v2 only in 2.0. The design is written up in docs/versioned-namespaces.md.

pip install aitoai installs the API clients. The command-line tool, schema inference and file conversion need the dataframe toolchain: pip install 'aitoai[cli]'.

examples/v2_quickstart.py is a runnable end-to-end example that creates a collection, loads it, predicts, explains, evaluates and drops it again.

Support / Feedback

For issues with, questions about, or feedback, please join our support channels.

Installation

Aito Python SDK can be installed with pip

$ pip install aitoai

Check our installation guide for more information

Documentation

You will need sphinx installed to generate the documentation.

$ pip install sphinx $ pip install sphinx_rtd_theme

Documentation can be generated by:

$ cd docs
$ make clean html

Generated documentation can be found in the docs/build/html/* directory.

Dependencies:

The Python SDK SQL integration and the tests depend on the ODBC db drivers and the postgres and mysql functionality.

The main drivers can be installed in Debian based Linuxes with:

` sudo apt install unixodbc-dev odbc-postgresql postgresql-client default-mysql-client pip install pyodbc `

You can find more information about installing the MySQL ODBC drivers [here](https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-installation.html)

Also note: that the database integration tests require local postgres / mySQL servers.

Environment:

To run the test, you need to have the following environment variables defined:

  • AITO_GROCERY_DEMO_INSTANCE_URL

  • AITO_GROCERY_DEMO_API_KEY

  • AITO_INSTANCE_URL

  • AITO_API_KEY

Testing

Install the required packages:

$ pip install -r requirements/build.txt
$ pip install -r requirements/test.txt

You can use our test cli to run tests:

$ python -m tests -h

There are multiple test suites:

  1. CLI suite:

$ python -m tests -v suite cli
  1. SDK suite:

$ python -m tests -v suite sdk
  1. SQL functions tests:

  • Test against Postgres:

    $ python -m tests -v case sql_functions.test_connection.TestPostgresConnection
    $ python -m tests -v case sql_functions.test_cli_sql_functions.TestPostgresFunctions
  • Test against MySQL:

    $ python -m tests -v case sql_functions.test_connection.TestMySQLConnection
    $ python -m tests -v case sql_functions.test_cli_sql_functions.TestMySQLFunctions
  1. Build and test built package:

  • To build the package:

    $ pip install -r requirements/deploy.txt
    $ ./scripts/deploy test.pypi --no-publish -b dev

    WARNING: This will update the version in ‘aito/__init__’ file. DO NOT commit this to Git!

  • The built wheel should be at `dist/`. To install:

    $ pip install dist/aitoai-<version>.whl
  • To test the built package, create an environment variable `TEST_BUILT_PACKAGE` and run the above tests

  1. Test the documentation:

  • To test the inline documentation:

    $ python -m tests -v suite inline_docs
  • To test the code blocks in rst files:

    $ cd docs
    $ curl -o reddit_sample.csv https://raw.githubusercontent.com/AitoDotAI/kickstart/master/reddit_sample.csv
    $ export SPHINX_DISABLE_MOCK_REQUIREMENTS=TRUE
    $ make doctest

Contributing

  1. Making changes

  2. Add unittest to the appropriate test suite (e.g: test case for Aito Schema: tests/sdk/test_aito_schema.py) or create a new test suite inside the tests folder

  3. Add documentation:

  • Inline documentation if applicable

  • Update .rst file in docs/source folder (e.g: Add a new Client function to docs/source/sdk.rst)

  1. Add inline doc test if applicable (e.g: inline doc test for Aito Client: tests/inline_docs/test_client_inline_docs.py)

  1. Update the version in aito/__init__ to e.g. ‘1.2.3rc1’ and write release notes in docs/changelog.rst

  2. Check CircleCI and issue a PR

  3. Deploy to production (scripts/deploy) with the appropriate version after the PR is reviewed

Release files for aitoai 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aitoai 1.0.0
File Size Uploaded
aitoai-1.0.0.tar.gz 76.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aitoai 1.0.0
File Interpreter ABI Platform
aitoai-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 164.7 kB

Release files / aitoai-1.0.0.tar.gz

Download URL aitoai-1.0.0.tar.gz
Size 76.7 kB
Tags Source
SHA-256 checksum
How to use checksums
75a253625959b948ac99344fdb971bf813e4c7f0f3350074c8a4e441d69e6453
BLAKE2b-256 checksum
How to use checksums
f31ebcea39ea39e7308a6a2cd934c445b8dbfa5d9a6618eee4cbd86ce8bb8000
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.16

Release files / aitoai-1.0.0-py3-none-any.whl

Download URL aitoai-1.0.0-py3-none-any.whl
Size 88.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e8265d06903a705f579d3849ad5a224108ae9470b1ffb6e1913524402964f9d
BLAKE2b-256 checksum
How to use checksums
389471f04b58bcea365bc66148016d6857f5b48edbb95b50696ec50b3eb76f7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.16
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page