EICSymAware scaffolding

Presentation

Ernesto Casablanca

Requirements

What characteristics will EICSymAware have?

  • Written in python
  • Easy to distribute
  • Independent development
  • Flexible and modular architecture
  • Easily interchangeable components

Written in python / Easy to distribute

The easiest way to distribute a python package is through PyPI.

With a properly configured pyproject.toml file and CI/CD pipeline, the whole process can be automated and triggered by pushing a new tag.

Installation just requires pip:

pip install eicsymaware

Independent development

Each module can be developed independently with its own repository and CI/CD pipeline.

There needs to be agreement on a common API and some coding standards should be enforced (e.g. code style, docstrings, etc.).

Modules should be deployed regularly to allow for integration testing.

eicsymAware-mpi # Module from mpi (repository)
└── src
    └── eicsymaware # namespace (no __init__.py)
        └── mpi # package (__init__.py)

eicsymAware-sisw # Module from sisw (repository)
└── src
    └── eicsymaware  # namespace (no __init__.py)
        └── sisw # package (__init__.py)

Flexible and modular architecture

Each component should be as independent as possible from the others.

Loading diagram...

Flexible and modular architecture

Each module will publish its own package.

An API foundation package would help enforce a common interface between components.

Everything will come together in a single package, the entrypoint of the project.

Loading diagram...

Easily interchangeable components

The components should be easily interchangeable, as long as they respect the common API.

Only the main package knows all the modules and how they communicate with each other     \implies it is possible to replace a each with a compatible one without affecting the others.

Adapting the Publisher-Subscriber design pattern makes it easier to decouple the components.

Loading diagram...

Event based communication

Working with events makes it easier to segregate the implementation of each component from the transmission of data.

Loading diagram...
Loading diagram...

Example

A simple example to show how the architecture could be built is currently available on GitLab.

It includes all the package configuration files, as well as ready to use testing, linting and documentation tools. All is integrated with a CI/CD pipeline.

Group

A group on GitLab is a collection of projects.

Module

Each module is a separate project.

Package

Each module publishes its own package using a CI/CD pipeline.

pip install testsimaware-mpi --index-url https://gitlab.com/api/v4/projects/52682823/packages/pypi/simple
pip install testsimaware-sisw --index-url https://gitlab.com/api/v4/projects/52755635/packages/pypi/simple

Agent

The agent will combine all the modules together and provide the entrypoint to the project.

from testsimaware.mpi import Perception
from testsimaware.sisw import SituationAwareness

class Agent:
    def __init__(self):
        self.perception = Perception()
        self.situation_awareness = SituationAwareness()
        self.perception.add("system_status", self.situation_awareness.update)
        self.situation_awareness.add("low_cpu", lambda _: self.stop)
        self.situation_awareness.add("low_memory", lambda _: self.stop)
        self.situation_awareness.add("low_disk", lambda _: self.stop)

    def start(self):
        self.perception.start()

    def stop(self):
        self.perception.stop()

agent = Agent()
agent.start()

Agent complete example

For a more complete example, check the agent.py file.

Questions

Any questions or comments?