MO2.2.4 Developer tools: backend - openimis-be_py

MO2.2.4 Developer tools: backend - openimis-be_py

Developer tools

To create backend module skeleton in single command

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py create_openimis_module <module_name> <author> <author_email> [--template <template>]

  • <author> and <author_email> params are required because they are necessary during creating setup.py file

  • --template param allow to specify a template adding additional files, depending on module type provided: - business template provides the module with services.py file containing example service, tests for that service, and apps.py containing module config. - calculation template is an alias to create_calcrule_module command explained in To create calculation backend module skeleton in single command section

  • this command executes every steps described in "To create a new openIMIS module (e.g. openimis-be-mymodule)"

  • file templates for setup, readme, license, manifest and urls can be found in developer_tools/skeletons directory

  • files to be added through that command based on provided templates:

  • setup.py

  • README.md

  • LICENSE.md

  • MANIFEST.md

  • <module_name>/urls.py

  • as the option could be added --github. This allows to add gitignore file and workflows files to execute CI on every pull request (this option will execute this command python manage.py add_github_files_to_module <module_name>)

  • example with using --github option: python manage.py create_openimis_module <module_name> <author> <author_email> --github

  • from here on, your local openIMIS has a new module called openimis-be-<module_name>_py, directly loaded from your directory by using single command.

To add GitHub files like workflows, gitignore etc

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py add_github_files_to_module <module_name>

  • this command allows to add to the existing module github files like gitignore, workflows etc

  • files to be added through that command based on provided templates:

  • openmis-module-test.yml

  • python-publish.yml

  • .gitignore

To fetch a module and install it from local directory

  • first install all modules as in "Developers setup"

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py install_module_locally <module_name> [--url <url>] [--branch <branch>] [--path <path>]. This command will execute all steps required steps to first uninstall currently installed version of the module, clone the module repository and install it as an editable library.

  • The --url parameter allows you to specify the git repository url (By default it will use openimis.json)

  • The --branch parameter allows to specify the branch that will be cloned, develop by default

  • The --path allows you to specify the directory the repository will be cloned to. By default, the repository will be saved next to openimis-be_py directory.

To fetch all modules and install them from local directories

  • first install all modules as in "Developers setup"

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py install_module_locally all. This command will execute all steps required steps to fetch all modules present in openimis.json from the git repositories and install them as editable libraries.

To install modules from PyPI

  • first install all modules as in "Developers setup"

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py install_module_pypi <module_name> [--target-version <version>] [--library-name <library_name>] [--check-only]. This command will execute all steps required steps to first uninstall currently installed version of the module, check the newest version of the library and install it from PyPI.

  • The --target-version parameter allows you to specify the version that will be used to install the module

  • The --library-name parameter allows you to override the library name. By default, the library name is derived from module name, following this scheme: openimis-be-<module_name>

  • The --check-only flag allows to check the newest version without installing the library or modifying openimis.json file. This parameter can be also used to check availability of a specific version when used with --target-version

To install all modules from PyPI

  • first install all modules as in "Developers setup"

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py install_module_locally all. This command will execute all steps required steps to install most recent versions of all modules present in openimis.json from PyPI.

To create calculation backend module skeleton in single command

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py create_calcrule_module <module_name> <author> <author_email>

  • <author> and <author_email> params are required because they are necessary during creating setup.py file

  • file templates for apps.py, config.py and calculation_rule.py can be found in developer_tools/skeletons directory

  • another files necessary to launch module such as setup.py etc are also added by this command.

  • files to be added through that command based on provided templates:

  • setup.py

  • README.md

  • LICENSE.md

  • MANIFEST.md

  • <module_name>/urls.py

  • <module_name>/apps.py

  • <module_name>/config.py

  • <module_name>/calculation_rule.py

  • as the option could be added --github. This allows to add gitignore file and workflows files so as to execute CI on every pull request (this option will execute this command python manage.py add_github_files_to_module <module_name>)

  • example with using --github option: python manage.py create_calcrule_module <module_name> <author> <author_email> --github

  • from here on, your local openIMIS has a new module called openimis-be-calcrule-<module_name>_py, directly loaded from your directory by using single command.

To create release branches for all backend/frontend modules presented in openimis.json

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py create_release_branch <version> <from_branch: by default 'develop'>. This command will execute all steps required to create release branches of all modules present in openimis.json (frontend json and backend json).

To extract all translations from frontend modules

  • from /openimis-be_py/openIMIS:

  • run this command: python manage.py extract_translations. This command will execute all steps required to extract frontend translations of all modules present in openimis.json.

  • those translations will be copied into 'extracted_translations_fe' folder in assembly backend module

Did you encounter a problem or do you have a suggestion?

Please contact our Service Desk



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/