--- title: 'Developer guide' linkTitle: 'Developer guide' weight: 10 description: '' --- ## 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](/contributing/development-environment). ```bash mkdir -p cvat-sdk/schema/ && python manage.py spectacular --file cvat-sdk/schema/schema.yml ``` If you want to use docker instead: ```bash 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 `/api/docs`: ![Download server schema button image](/images/download_server_schema.png) 2. Install generator dependencies: ```bash pip install -r gen/requirements.txt ``` 3. Generate package code (call from the package root directory!): ```bash ./gen/generate.sh ``` 4. 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: ```bash 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: - [Generator implementation, available variables in templates](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen) - [Mustache syntax in the generator](https://github.com/OpenAPITools/openapi-generator/wiki/Mustache-Template-Variables) ## 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: ```bash pytest tests/python/rest_api tests/python/sdk ```