You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.5 KiB

title linkTitle weight description
Developer guide Developer guide 10

Overview

This package contains manually written and generated files. We store only sources in the repository. To get the full package, one need to generate missing package files.

Package file layout

  • gen/ - generator files
  • cvat_sdk/ - Python package root
  • cvat_sdk/api_client - autogenerated low-level package code
  • cvat_sdk/core - high-level package code

How to generate package code

  1. Obtain the server API schema

If you have a local custom version of the server, run the following command in the terminal. You need to be able to execute django server. Server installation instructions are available here.

mkdir -p cvat-sdk/schema/ && python manage.py spectacular --file cvat-sdk/schema/schema.yml

If you want to use docker instead:

docker-compose -f docker-compose.yml -f docker-compose.dev.yml run \
    --no-deps --entrypoint '/usr/bin/env python' --rm -u "$(id -u)":"$(id -g)" -v "$PWD":"/local" \
    cvat_server \
    manage.py spectacular --file /local/cvat-sdk/schema/schema.yml

If you don't have access to the server sources, but have a working instance, you can also get schema from <yourserver>/api/docs:

Download server schema button image

  1. Install generator dependencies:
pip install -r gen/requirements.txt
  1. Generate package code (call from the package root directory!):
./gen/generate.sh
  1. To allow editing of the package, install it with pip install -e cvat-sdk/.

How to edit templates

If you want to edit templates, obtain them from the generator first:

docker run --rm -v $PWD:/local \
    openapitools/openapi-generator-cli author template \
        -o /local/generator_templates -g python

Then, you can copy the modified version of the template you need into the gen/templates/openapi-generator/ directory.

Relevant links:

How to test

API client tests are integrated into REST API tests in /tests/python/rest_api and SDK tests are placed next to them in /tests/python/sdk. To execute, run:

pytest tests/python/rest_api tests/python/sdk