Skip to content

Invoke

Invoke Tool

InvenTree uses the invoke tool to manage various system administration tasks. Invoke is a powerful python-based task execution tool, which allows for the creation of custom tasks and command-line utilities.

Installation

InvenTree setup and administration requires that the invoke tool is installed. This is usually installed automatically as part of the InvenTree installation process - however (if you are configuring InvenTree from source) you may need to install it manually.

To install the invoke tool, run the following command:

pip install -U invoke

Minimum Version

The minimum required version of the invoke tool is 2.0.0.

To determine the version of invoke you have installed, run either:

invoke --version
python -m invoke --version

If you are running an older version of invoke, ensure it is updated to the latest version:

pip install -U invoke

Running from Command Line

To run the invoke tool from the command line, you must be in the top-level InvenTree source directory. This is the directory that contains the tasks.py file.

Running in Docker Mode

If you have installed InvenTree via docker, then you need to ensure that the invoke commands are called from within the docker container context.

For example, to run the update task, you might use the following command to run the invoke command - using the docker compose tool.

docker compose run --rm inventree-server invoke update

Docker Compose Directory

The docker compose command should be run from the directory where the docker-compose.yml file is located.

Alternatively, to manually run the command within the environment of the running docker container:

docker exec -it inventree-server invoke update

Container Name

The container name may be different depending on how you have configured the docker environment.

Running in Installer Mode

If you have installed InvenTree using the package installer, then you need to prefix all invoke commands with inventree run.

For example, to run the update task, use:

inventree run invoke update

Available Tasks

To display a list of the available InvenTree administration actions, run the following commands from the top level source directory:

invoke --list

This provides a list of the available invoke commands - also displayed below:

Available tasks:

  backup                            Backup the database and media files.
  export-records                    Export all database records to a file.
  frontend-download                 Download a pre-build frontend from GitHub
                                    if you dont want to install nodejs on your
                                    machine.
  import-records                    Import database records from a file.
  install                           Installs required python packages.
  migrate                           Performs database migrations.
  plugins                           Installs all plugins as specified in
                                    'plugins.txt'.
  remove-mfa                        Remove MFA for a user.
  restore                           Restore the database and media files.
  static                            Copies required static files to the
                                    STATIC_ROOT directory, as per Django
                                    requirements.
  superuser                         Create a superuser/admin account for the
                                    database.
  update                            Update InvenTree installation.
  version                           Show the current version of InvenTree.
  wait                              Wait until the database connection is
                                    ready.
  worker                            Run the InvenTree background worker
                                    process.
  dev.delete-data                   Delete all database records!
  dev.docs-server                   Start a local mkdocs server to view the
                                    documentation.
  dev.frontend-server               Start frontend development server.
  dev.gunicorn                      Launch a gunicorn webserver.
  dev.import-fixtures               Import fixture data into the database.
  dev.schema                        Export current API schema.
  dev.server                        Launch a (development) server using
                                    Django's in-built webserver.
  dev.setup-dev                     Sets up everything needed for the dev
                                    environment.
  dev.setup-test                    Setup a testing environment.
  dev.test                          Run unit-tests for InvenTree codebase.
  dev.test-translations             Add a fictional language to test if each
                                    component is ready for translations.
  dev.translate                     Rebuild translation source files. Advanced
                                    use only!
  int.clean-settings                Clean the setting tables of old settings.
  int.clear-generated               Clear generated files from `invoke update`.
  int.export-settings-definitions   Export settings definition to a JSON file.
  int.frontend-build                Build frontend.
  int.frontend-check                Check if frontend is available.
  int.frontend-compile              Generate react frontend.
  int.frontend-install              Install frontend requirements.
  int.frontend-trans                Compile frontend translations.
  int.rebuild-models                Rebuild database models with MPTT
                                    structures.
  int.rebuild-thumbnails            Rebuild missing image thumbnails.
  int.render-js-files               Render templated javascript files (used for
                                    static testing).
  int.showmigrations                Show the migration status of the database.
  int.translate-stats               Collect translation stats.

Default task: version

Task Information

Each task has a brief description of its purpose, which is displayed when running the invoke --list command. To find more detailed information about a specific task, run the command with the --help flag.

For example, to find more information about the update task, run:

invoke update --help

Internal Tasks

Tasks with the int. prefix are internal tasks, and are not intended for general use. These are called by other tasks, and should generally not be called directly.

Developer Tasks

Tasks with the dev. prefix are tasks intended for InvenTree developers, and are also not intended for general use.

Common Issues

Below are some common issues that users may encounter when using the invoke tool, and how to resolve them.

Command 'invoke' not found

If the invoke command does not work, it means that the invoke tool has not been installed correctly.

Invoke Version

If the installed version of invoke is too old, users may see error messages during the installation procedure, such as:

  • 'update' did not receive all required positional arguments!
  • Function has keyword-only arguments or annotations

Ensure that the installed version of invoke is up to date.

Can't find any collection named 'tasks'

It means that the invoke tool is not able to locate the InvenTree task collection.

  • If running in docker, ensure that you are running the invoke command from within the docker container
  • If running in installer mode, ensure that you are running the invoke command with the correct prefix
  • If running via command line, ensure that you are running the invoke command from the correct directory