Skip to main content

A utility for managing mosaik's entity identifiers.

Project description

Mosaik EID

Mosaik EID supports creating Mosaik scenarios by managing the identifiers of the entities.

Status

pipeline status coverage report libraries status license badge PyPI version Python Versions

Motivation

Traditionally, mosaik entities are created with hard coded names. Mosaik EID intends to be easier to use and less error-prone than to hard coding values. The clean and pythonic API encourages creating scenarios in a DRY fashion.

Design

The package contains a parser, generator, data model and exceptions around creating such names. The data model is based upon an Enum. Building upon that is a manager which issues entity identifiers based on the entity type and a serial number. The entity manager implements the borg pattern and can thus be instantiated at will without losing state. There are some basic entity types predefined, but they can be extended by registering additional types.

Compatibility

It is allowed to register entity names with arbitrary capitalization, for example CHP, BioGas or wind or lv_bat_liion_3_5_10. All components are tested with 100 % test coverage and hopefully many corner cases caught. There are extensive unit, integration and functional tests. Tests are integrated into tox to ensure compatibility across some python implementations. These are: CPython 2.7, Python 3.6, CPython 3.7, PyPy2v6 and PyPy3v6

Limitations

  • Thread safety is not yet implemented because it seems to have little value.

  • Entity types need to be valid Python identifiers.

  • PyPy3 does not currently work under Windows 10 because of an unresolved a bug in pypy.

Tests

This package uses unittest for writing tests, nose for test discovery and tox for running them on multiple python versions.

Cloning the Source

git clone https://eprojects.offis.de/mosaik-eid/git/mosaik-eid.git

Creating the Virtual Environment

Under Linux:

virtualenv -p python3.8 venv

Under Windows:

virtualenv -p "C:\Program Files\Python38\python.exe" venv

Installing the Requirements

python -m pip install --upgrade -r requirements.d/venv.txt

Running the Tests

tox --parallel all

Testing the Coverage

python -m coverage html mosaik_eid/*.py

Under Linux

xdg-open htmlcov/index.html

Under Windows

start htmlcov/index.html

Using the Library

>>> from mosaik_eid.eid_registry import EidRegistry
>>> e_type = EntityTypeRegistry.register(e_type='biogas')
>>> for _ in range(3):
...     next(EidManager(e_type=e_type))
...
'biogas-0'
'biogas-1'
'biogas-2'

See tests/functional for more practical examples of intended use.

Developing the Library

For development purposes, use one of the virtual environment under .tox your choice.

Freezing the Virtual Environment Requirements

Under Linux

 venv/bin/python -m pip freeze --all --exclude-editable > requirements.d/venv.txt
 # And remove line beginning with package name

Under Windows

 venv\Scripts\python.exe -m pip freeze --all --exclude-editable > requirements.d/venv.txt
# And remove line beginning with package name

Freezing the Tox Requirements

Under Linux

.tox/py38/bin/python -m pip freeze --all --exclude-editable > requirements.d/base.txt
# And remove line beginning with package name

Under Windows

.tox\py37\Scripts\python -m pip freeze --all --exclude-editable > requirements.d/base.txt
# And remove line beginning with package name

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mosaik.EId-0.1.0rc20221002000538-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file mosaik.EId-0.1.0rc20221002000538-py3-none-any.whl.

File metadata

  • Download URL: mosaik.EId-0.1.0rc20221002000538-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.13.0 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.8.8

File hashes

Hashes for mosaik.EId-0.1.0rc20221002000538-py3-none-any.whl
Algorithm Hash digest
SHA256 05b99cd7fc24bcff22df00152f3defcd4b577c97cdcf160e11ea793057b7a01a
MD5 8cc778667618d58f8605e2d3cae302ad
BLAKE2b-256 ccde0b0aed12534856c83bf6bd8f36e4c599b08ce63d3e7bfa534365b91128a9

See more details on using hashes here.

Supported by

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