Python API: Managing Vitis IDE Components - 2024.1 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2024-05-30
Version
2024.1 English

The Vitis Unified IDE supports Python APIs to automate the management of Vitis IDE components. The Vitis IDE contains a Python Interpreter and script building logger. The Python interpreter supports Python APIs and executes the APIs in the Vitis tool. The script building logger converts the Vitis tool GUI user actions (create and build Vitis IDE components such as AI Engine component) into equivalent Python APIs. The Python file generated by the script building logger can be used to create and build components using the Python interpreter. The Vitis Unified IDE works on the server-client architecture. To execute Python APIs, you need to first establish the connection between the server and the client. Python APIs can be executed in command line mode or as a Python script. The AMD Vitis™ Unified IDE supports two methods to run Python APIs:

  1. Run Python API in CLI (Command-Line Interface) mode: Executing the Python API in CLI mode is supported in interactive mode only. More details on interactive mode can be found at Vitis Interactive Python Shell.
  2. Run Python API in a Python Script: The Vitis Unified IDE supports the execution of Python script in batch mode as well as in an interactive mode.
    In batch mode:
    $ vitis -s <.py>
    In Interactive mode:
    vitis [1]: run <.py>

Before running the script, you must set up the environment variables for the Vitis Unified IDE. Refer to Setting Up the Vitis Tool Environment to set up the Vitis Unified IDE environment. The Vitis IDE supports Python APIs for project flow management, creation and building of the following Vitis components:

  • AI Engine Component
  • HLS Component
  • Platform Component
  • Application Component
  • System Project

The script building logger logs actions from the GUI and saves the file as builder.py. To access builder.py, follow the steps below:

  1. Navigate to ViewExplorer in the Menu bar or press Ctrl+Shit+E.
    Figure 1. View → Explorer menu

  2. In the Explorer window, go to logs: builder.py. The Python interpreter creates builder.py, which logs the equivalent Python APIs for the commands used in the Vitis IDE. You can run builder.py later to automate the process.
    Figure 2. logs → builder.py

Some Python APIs are helpful in managing client life cycles, create Vitis workspaces and manage Vitis project flows. These APIs are described in the following table. Refer the Vitis API CLI documentation for more details.

Table 1. Python APIs: Manage client
Python API Description Example
create_client Creates a client instance. client=vitis.create.client()
dispose Closes all client connections and terminates the connection to the server. client.dispose()
exit Closes the session. exit()

For more details on all the Python APIs supported by Vitis, refer to <vitis_installation_path>/cli/api_docs/build/html/vitis.html or in the Vitis Unified IDE, go to Help → Vitis CLI Documentation.

Python examples are provided with the installation for reference: <vitis_installation_path>/cli/examples

After creating and building the components and system project, the workspace can be directly opened in the Vitis IDE using the command below:
vitis -w <workspace_path>

Components and system projects are opened in the Vitis IDE with build and created status=done, if they are created and build through Python APIs.

The Python APIs used for component creation and build are explained in the following sections.