Skip to main content

Smart Meter Data Collector Configurator

Project description

Smart Meter Data Collector Configurator Backend

Introduction

The backend is written with Python3 and bases on the following frameworks and libraries:

  • Uvicorn: ASGI server implementation, using uvloop and httptools.
  • Starlette: ASGI framework/toolkit
  • Pydantic: Data validation and settings management using Python type hinting.

For managing dependency packages and virtualenv pipenv is used.

Development

Requirements

  • Python >= 3.8
  • pipenv
  • Optional software packages (Debian / Ubuntu)
    • python3-all
    • debhelper
    • dh-python

Project Setup

With

pipenv install --dev

a new virtualenv is set up and the listed (inclusive dev) dependencies in the Pipfile are installed.

pipenv shell

activates the created virtualenv and opens a shell inside.

You can also run a command directly with:

pipenv run <command>

Running during development

Inside the virtualenv run:

python -m smartmeter_datacollector_configurator [-c <config_path>] [-s <static_path>] [-d]

Now, the backend is running on port 8000 listening to 127.0.0.1. With the option -d hot-reloading and debug logs are enabled.

For development purposes it is possible to create an empty static folder inside the backend directory and start the application without the -s option. At the same time you start the frontend (npm run serve) in a separate shell. The API calls of the frontend, during development, are directed to a local backend to port 8000.

Command line arguments

The following command line arguments are supported:

  • -h, --help: Shows the help output of smartmeter-datacollector-configurator.
  • -c, --config PATH: Directory path where the configuration files are read and deployed (default: Current directory ./).
  • -s,--static PATH: Directory path where the static frontend files are located. If left empty the app check if a static directory exists in the package location and falls back to the current directory ./static.
  • --host: Listening host IP (default: 127.0.0.1).
  • --port: Listening port number (default: 8000).
  • -d, --dev: Enable development mode which provides debug logging and hot reloading.

Custom commands & workflows

smartmeter-datacollector-configurator offers a few custom pipenv run commands to simplify certain development workflows:

  • build_check uses twine to check if the built Python package will be accepted by PiPI.
  • build_deb builds a Debian package for the current development plattform.
  • build_srcdeb builds a Debian source package which can be used to build a Debian (binary) package for any platform (e.g. using pbuilder)
  • build builds a Python package which can be uploaded to PyPI using twine.
  • debianize creates a debian/ directory used to build Debian source / binary packages.
  • format_check checks if the code follows the autopep8 code formatting rules.
  • format automatically adjusts the code to follow the autopep8 code formatting rules.
  • isort_check checks if the order of the import statements is correct using isort.
  • isort automatically re-orders the import statements using isort.
  • lint_check checks if the code follows the pylint rules defined in pyproject.toml.
  • lint automatically adjust the code to follow the pylint rules defined in pyproject.toml.
  • setup_check checks whether the dependencies defined in Pipfile / Pipfile.lock are in sync with setup.py.
  • setup synchronizes the dependencies defined in Pipfile / Pipfile.lock with setup.py.

Make sure to run format_check / format, isort_check / isort, lint_check / lint, license, setup_check / setup before committing changes to the repository to avoid unnecessary development cycles. smartmeter-datacollector-configurator uses GitHub Actions to check if these rules apply.

Visit Wiki - Creating a Release for further documentation about contributing.

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

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page