Skip to main content

Module that other Click-plugins can plug into

Project description

DHM Base Module

Basic module which uses software principles used in the repository "surfclass". Build status: CircleCI

This is a basis module, meant as a "mother" module for internal tasks in SDFE. Functionality with general purposes, including configuration files and settings can be implemented here. Specialised functionality is sought to be implemented in "plugins". Plugins can be developed in separate repositories with this module as dependency, how to do that will be explained in a later section. An example of a plugin that has this module as a dependency is described here:

The CLI module is based on Click


Conda Environment

git clone
cd dhm-module-base
conda env create -n dhm_module_base -f environment.yml
conda activate dhm_module_base
pip install .

The plugin can also be installed in developer or "editable" mode.

git clone
cd dhm-module-base
conda env create -n dhm_module_base -f environment-dev.yml
conda activate dhm_module_base
pip install -e .

Using the plugin

The module installs itself as a python module, which registers an entry point that can be called on the commandline. This module does not provide any commands itself, but allows plugins to register commands using a special entry point called plugins Calling the module from the commandline yields: dhm_module_base

Usage: dhm_module_base [OPTIONS] COMMAND [ARGS]...

  dhm_module_base command line interface.

  --version                       Show the version and exit.
                                  Set verbosity level
  --help                          Show this message and exit.


Note that the commands list is empty, as no plugins are registered.

Repository structure

┣ 📂.circleci
┃ ┗ 📜config.yml # CircleCI setup with status checks
┣ 📂.vscode
┃ ┗ 📜settings.json # .vscode settings, added to .gitignore
┣ 📂src
┃ ┣ 📂dhm_module_base # the module installed by
┃ ┃ ┣ 📜__init.py__ # marks the folder as a python module
┃ ┃ ┣ 📜 # Click commandline
┃ ┃ ┣ 📜 # Helping functions such as logging
┃ ┃ ┣ 📜 # Custom Click options
┃ ┃ ┣ 📜 # Configuration files and common settings importable by plugins
┣ 📂tests
┃ ┣ 📜 # Pytest configuration objects and fixtures
┃ ┗ 📜 # Example pytest that checks that the commandline works
┣ 📜.gitignore
┣ 📜environment-dev.yml
┣ 📜environment.yml
┣ 📜
┣ 📜setup.cfg # Contains repository specific rules regarding linting and docstrings
┗ 📜 # contains metadata and entry points for the module. is a special python file that describes how the module in src should be installed. Vi have told python that src\dhm_module_base is a module, since it has an file. The commandline is registered as an entrypoint using ENTRY_POINTS. Here we describe that this module has one entry point, which is dhm_module_base. This ensures we can call the module from the commandline, as an example: dhm_module_base --version


with_plugins register plugins

In we register a and then tell click that this groups should take plugins using the decorator @with_plugins.


iter_entry_points("dhm_module_base.plugins") is the entry point plugins register commands to in their Plugins now register their commands into the mother module by adding them to the ENTRY_POINTS section of their


If the plugin can be loaded without errors, they will be automatically added to the mother module, under commands


  --version                       Show the version and exit.
                                  Set verbosity level
  --help                          Show this message and exit.

  inout  Example command inout.
  pipe   Example of a custom options handler being used along with a...

inout and pipe are commands from a plugin using the [dhm_module_base.plugins] entry point to register itself to the click group in the mother module. See example:

Github and CircleCI setup for existing python projects

Existing python projects should use the same repository structure as this one, with one (or more) modules in src. Modules are registered if they have an file inside. Repositories should also include a tests folder and a file.



Pytest kan be used to write small or complex tests for internal classes and for the CLI itself. For examples of how to use Pytest see and It is advised to test every command at the CLI level as a minimum.

Pytest should be set to run in .circleci\config.yml after every commit.

Black formatting


Black is an automatic code formatter, that can be set up in Visual Studio Code or be called on the commandline. using black src. If the formatting is good, an output like this is shown:

$: black src

All done! ✨ � ✨
4 files left unchanged.

Black can be installed using pip install black and is also included in the conda environment for this project, and also in the circleCI check.


Pydocstyle is a docstring module that helps ensure all public methods are properly documented. In this repository docstrings are set to the google convention


CircleCI is setup in this repository with one job - lint_test_py37_conda which checks the source code for the following things:

  • Pylint,
  • Black formatting,
  • Pydocstyle,
  • Pytest - unittest

If any of these tasks fail, commits are not allowed to be pushed to the master branch. It is advised that the master branch is protected and that code can only be pushed to branches first, and then merged into master using a reviewer and code check. The CircleCI setup can be extended to also push modules to PyPi using releases or tagged commits.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dhm_module_base-0.0.1.tar.gz (8.4 kB view hashes)

Uploaded source

Built Distribution

dhm_module_base-0.0.1-py3-none-any.whl (9.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page