Peak SDK

PyPI Status Python Version License phase pre-commit Black Docs

Overview

This is the official Python SDK for the entire Peak platform, and is currently in the stable state. All users are encouraged to participate in the development process by providing feedbacks, submitting issues and pull requests. 🙏

Setting up a Virtual Environment

To ensure a smooth development experience with Peak SDK, we highly recommend creating a Python virtual environment. A virtual environment helps to isolate the dependencies required by your project and prevents conflicts with other projects or the system’s global Python environment.

Follow these steps to create a virtual environment using Python’s built-in venv module:

  1. Open a terminal.

  2. Navigate to your project’s root directory (where you plan to work with the Peak SDK).

  3. Create a new virtual environment with the following command:

    python3 -m venv <venv_name>
    
  4. Activate the virtual environment by running:

    source < venv_name > /bin/activate
    
  5. You will now be working within the virtual environment, and you can install dependencies and run the project without affecting other projects on your system’s Python environment.

  6. When you’re finished working on your project, you can deactivate the virtual environment using the following command:

    deactivate
    

Installation

You can install Peak SDK via pip from PyPI or from source, the only requirement is Python 3.8+:

  • Installation from a source branch or tag

    pip install "peak-sdk @ git+https://github.com/PeakBI/peak-sdk.git@{branch-name-or-tag}"
    
  • Installation from PyPI

    pip install peak-sdk
    

    Or if you want to install a specific version

    pip install peak-sdk==<version>
    
  • To upgrade the SDK to the latest version, run the following command

    pip install --upgrade peak-sdk
    
  • The Peak SDK ships with the CLI as well. Once CLI is installed, you can enable auto-completion for your shell by running peak --install-completion ${shell-name} command, where shell can be one of [bash|zsh|fish|powershell|pwsh].

  • Once this has run, we need to add compinit to the shell configuration file (like - .zshrc, .bashrc, etc). To do so, you can the following command

    echo "compinit" >> ~/.zshrc # replace .zshrc with your shell's configuration file
    

Peak Auth Token

To start using the SDK and CLI, you’ll need to export API key or Personal Access Token (PAT). If you don’t have one yet, sign up for an account on our platform to obtain your API key or PAT. To export it, run the following command in your terminal and replace <peak_auth_token> with your actual API key or PAT:

export PEAK_AUTH_TOKEN=<peak_auth_token>

Note: If you were exporting API_KEY environment variable to access Peak SDK and CLI, this will soon be deprecated. It is recommended to use PEAK_AUTH_TOKEN instead.

Platform Support

Support across Python versions on major 64-bit platforms
Python Version Linux MacOS Windows
3.8 🟢 🟡 🟤
3.9 🟢 🟡 🟤
3.10 🟢 🟡 🟤
3.11 🟢 🟡 🟤
Legend
Key Status Description
🟢 Supported regularly tested, and fully supported
🟡 Limited Support not explicitly tested but should work, and supported on a best-effort basis
🟤 Not Tested should work, but no guarantees and/or support

Documentation

You can access the documentation for the SDK and CLI at https://docs.peak.ai/sdk/. Here are some quick links to help you navigate easily:

Running the documentation locally

You can access the documentation by running them locally as well, just run the following commands and the documentation will be available at 127.0.0.1:8000

poetry install --no-interaction --no-ansi --with docs,jupyter
poetry run nox --session=autodocs

To create multiversion document we need to run the following command

poetry run nox --session=docs-build

If browsing on github you can check out the docs online and browse the raw markdown files.

Usage

Please see the usage documentation for details.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the Apache 2.0 license, Peak SDK is free and open source software.