evolver-ng

Next gen eVolver controller for bioreactor project - wip

https://github.com/ssec-jhu/evolver-ng

Science Score: 75.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
    Organization ssec-jhu has institutional domain (ai.jhu.edu)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.4%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Next gen eVolver controller for bioreactor project - wip

Basic Info
  • Host: GitHub
  • Owner: ssec-jhu
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Size: 526 KB
Statistics
  • Stars: 3
  • Watchers: 5
  • Forks: 2
  • Open Issues: 62
  • Releases: 1
Created about 2 years ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Citation Codeowners Zenodo

README.md

SSEC-JHU evolver-ng

CI codecov Security DOI Documentation Status

SSEC-JHU Logo

About

The next generation of software control for eVolver. This package provides a modular bioreactor controller framework and REST api focused on extensibility in hardware and experiment control. The REST api enables decoupling of the core control from the user interaction and aims to enable support for configuration of new hardware without explicit UI componentry being required.

References: * eVolver wiki: https://khalil-lab.gitbook.io/evolver * original code base: https://github.com/FYNCH-BIO

🚧 ❗ This project is under active early development - some of the information below may be out of date ❗ 🚧

Extensibility

The system is designed to be easily extensible both by a user operating a box under their desired experimental conditions, and also by a hardware developer needing a software driver for their on-chip sensors. All extension points will be easily shareable via pip installations or by sharing configuration files.

❗❗ NOTE: The information in this section does not represent instructions, but rather design goals. We will update with real instructions when the necessary hook-ups have been added to make use of these goals. To test and run an example app see Build instructions below ❗❗

Configuration

Config file

Configuration of the eVolver system including provisioned hardware and experiments must be expressed in a single yaml.

By default the config file is named evolver.yml and is stored in the project root directory file. This filename and path is determined by evolver.settings.AppSettings.CONFIG_FILE and can be customized.

for example:

yaml enable_react: true # run the experiment controllers interval: 20 # how often in seconds to loop hardware: temp: driver: evolver.hardware.default.TempSensorDriver od90: driver: evolver.hardware.default.OD90SensorDriver config: key: val pump: driver: evolver.hardware.default.PumpEffectorDriver controllers: - driver: evolver.controllers.default.ChemostatExperimentController config: start_od: 0 start_time: 0

This enables both sharing of the eVolver setup and experiment with others, and also the ability to easily resume the experiment on hardware failure.

Bootstrapping the evolver.yml config file

By default evolver-ng requires an evolver.yml (file name can be configured at settings.app_settings.CONFIG_FILE) file to exist in the project's root directory for it to start.

However, sometimes you want to start evolver-ng before evolver.yml exists. For example the very first time you run the app.

For this reason there is an escape hatch that allows evolver-ng to start without evolver.yml using the following environment variable.

EVOLVER_LOAD_FROM_CONFIG_ON_STARTUP=false

For example, if you run evolver-ng for local development or testing, without evolver.yml existing you must pass this flag:

shellscript EVOLVER_LOAD_FROM_CONFIG_ON_STARTUP=false tox -e test exec -- python -m evolver.app.main

Creating a valid config file

There are a few distinct ways to create a valid evolver config.

  • If you passed the EVOLVER_LOAD_FROM_CONFIG_ON_STARTUP=false flag. The evolver will be given an in-memory config with default values. The / endpoint will available on the evolver-ng HTTP API, this endpoint accepts POST requests with a config payload, if you attempt to submit an invalid config to this endpoint it will respond with detailed validation errors. If you submit a valid config to the / endpoint the evolver.yml file will be created so the flag needn't be passed the next time you run the app. The evolver-ui package provides a webapp that can be used to interact with the / endpoint and update the config.

  • Or, a valid config file can also be created programmatically using the Evolver SDK

```python

from evolver.device import Evolver

Evolver.Config().save(settings.appsettings.CONFIGFILE)

```

  • Or, A valid config can be copied from another evolver instance.

Web api

The web api will expose all configuration options also available in the config file so configuration can be done in a user-friendly manner via a web browser.

Experiment control

In the default mode, the eVolver application will run a loop every 20 seconds which:

  • reads the sensor values into a device object which can later be read from
  • evaluates the experiment controllers in order. The code in the controllers can access sensor data and set effector values.
  • progresses the experiment by sending the updates from controllers to the underlying hardware device (e.g. set pump flow rate or start stirring)

Hardware device extensions

Once an on-board device is created and attached to the serial bus, a new hardware driver can be created by implementing the get, set, read and/or commit methods of a hardware driver. For example (not real code, interface subject to change):

```py class MyNewHardware(Sensor): def read(self): # send the serial command specific for this device, which can handle # the particular output it creates data = self.evolver.serial.communicate(SerialData(self.addr, databytes, kind='r')) self.loadeddata = self.convert_serial(data)

def get(self):
  return Output(self.loaded_data)  # output converted from raw serial to real data

```

Experiment controller extensions

Experiment controllers simply need to implement the control method, which will be called in the evaluate phase mentioned above. These can read values from the eVolver devices and set commands to others for changing the environment. A simple example might look like (not real code, interface subject to change):

```py class MyCoolExperiment(Controller): class Config(VialConfigBaseModel): odsensor: str = 'OD90' flowrate_factor: int = 10

def control(self): # read values from a particular sensor od90 = self.evolver.get(self.config.odsensor) # set an effector based on this value pumpflowrate = od90 / self.config.flowratefactor self.evolver.set('PUMP', pumpflow_rate) ```

There will also likely be a generic "development" controller that can take a blob of python code to execute, so for example a user can write code in the webUI which will get evaluated during each loop. This will enable rapid development, while also making it simple to "freeze" that code into a module (that can be committed and shared more easily) since the body can simply be copied to Controller classes control method as above!

Installation, Build, & Run instructions

Prerequisite

Build, testing and examples use the tox utility to set up virtual environments, the only perquisite on the development system is python and tox (represented in requirements/dev.txt):

pip install -r requirements/dev.txt

Test

Run tox within the repo base path to run an end-to-end test and packaging:

tox

or to run just the unit tests (for example):

tox -e test

Example run

We can leverage the tox environment, which contains all required dependencies, to run the application locally for evaluation and development:

Running without evolver.yml configuration file

sh EVOLVER_LOAD_FROM_CONFIG_ON_STARTUP=false tox -e dev

Running with evolver.yml configuration file

sh tox -e dev

You should then be able to visit the automatically generated API documentation in your local browser at https://localhost:8080/docs (or https://localhost:8080/redoc). From there you can experiment with sending data and reading from various endpoints (which will eventually be hooked up to a web user interface).

Generate openapi schema as a JSON

To generate openapi.json in the project root run:

tox -e generate_openapi

Owner

  • Name: Scientific Software Engineering Center at JHU
  • Login: ssec-jhu
  • Kind: organization
  • Email: ssec@jhu.edu
  • Location: United States of America

Accelerating Software Development for Science Research

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software in your work, please cite it using the following metadata."
authors:
- family-names: "Hunter"
  given-names: "Edward"
  orcid: "https://orcid.org/0000-0002-6876-001X"
- family-names: "Noss"
  given-names: "James"
  orcid: "https://orcid.org/0000-0002-0922-5770"
- family-names: "Kluzner"
  given-names: "Vladimir"
  orcid: "https://orcid.org/0009-0000-5844-661X"
- family-names: "Lemson"
  given-names: "Gerard"
  orcid: "https://orcid.org/0000-0001-5041-2458"
- family-names: "Mitschang"
  given-names: "Arik"
  orcid: "https://orcid.org/0000-0001-9239-012X"
- family-names: "Chen"
  given-names: "Xiang"
  orcid: "https://orcid.org/0009-0003-6402-9822"
- family-names: "Abbasinejad"
  given-names: "Fatemeh"
  orcid: "https://orcid.org/0009-0006-3239-7112"
title: "evolver-ng"
version: 0.1.0
doi: "12532759"
date-released: 2023-01-01
url: "https://github.com/ssec-jhu/evolver-ng"

GitHub Events

Total
  • Issues event: 75
  • Delete event: 67
  • Member event: 1
  • Issue comment event: 183
  • Push event: 266
  • Pull request review comment event: 271
  • Pull request review event: 351
  • Pull request event: 144
  • Fork event: 1
  • Create event: 75
Last Year
  • Issues event: 75
  • Delete event: 67
  • Member event: 1
  • Issue comment event: 183
  • Push event: 266
  • Pull request review comment event: 271
  • Pull request review event: 351
  • Pull request event: 144
  • Fork event: 1
  • Create event: 75

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 94
  • Total pull requests: 167
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 4
  • Total pull request authors: 5
  • Average comments per issue: 0.69
  • Average comments per pull request: 0.99
  • Merged pull requests: 98
  • Bot issues: 0
  • Bot pull requests: 45
Past Year
  • Issues: 40
  • Pull requests: 103
  • Average time to close issues: 16 days
  • Average time to close pull requests: 5 days
  • Issue authors: 4
  • Pull request authors: 4
  • Average comments per issue: 0.8
  • Average comments per pull request: 0.99
  • Merged pull requests: 65
  • Bot issues: 0
  • Bot pull requests: 26
Top Authors
Issue Authors
  • jamienoss (42)
  • amitschang (29)
  • imaitland (19)
  • ezirayw (4)
Pull Request Authors
  • amitschang (52)
  • dependabot[bot] (45)
  • jamienoss (37)
  • imaitland (32)
  • ryanhausen (1)
Top Labels
Issue Labels
enhancement (19) calibration (15) app (10) refactor (10) question (8) bug (8) LOC epic (7) UI (5) history (5) LOC task (4) new feature (4) config (4) fix (4) hardware (3) experiment control (3) task (3) documentation (3) extension (3) evolver manager (3) logging (2) ci (1) wontfix (1) triage (1) dependencies (1)
Pull Request Labels
dependencies (46) python (20) refactor (12) bug (12) fix (11) new feature (11) enhancement (10) app (6) calibration (6) hardware (4) config (3) question (3) evolver manager (2) history (2) LOC epic (2) UI (2) ci (2) documentation (2) wontfix (1) extension (1) experiment control (1) logging (1)

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • docker/build-push-action f2a1d5e99d037542a71f64918e516c093c6f3fc4 composite
  • docker/login-action 65b78e6e13532edd9afa3aa52ac7964289d1a9c1 composite
  • docker/metadata-action 9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 composite
.github/workflows/dist.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/security.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
Dockerfile docker
  • python 3.11-slim build
pyproject.toml pypi
  • fastapi [all]
  • pydantic *
  • pydantic-settings *
  • pyserial *
  • uvicorn *
requirements/all.txt pypi
requirements/build.txt pypi
  • build ==1.2.1
  • setuptools ==69.0.3
  • setuptools_scm ==8.0.4
requirements/dev.txt pypi
  • tox ==4.13.0 development
requirements/docs.txt pypi
  • nbsphinx ==0.9.3
  • sphinx ==6.2.1
  • sphinx-automodapi ==0.17.0
  • sphinx-issues ==4.0.0
  • sphinx_book_theme ==1.1.0
  • sphinx_rtd_theme ==2.0.0
requirements/prd.txt pypi
  • fastapi ==0.110.0
  • pydantic ==2.7.0
  • pydantic-settings ==2.2.1
  • pyserial ==3.5
  • uvicorn ==0.29.0
requirements/test.txt pypi
  • bandit ==1.7.8 test
  • httpx ==0.27.0 test
  • pytest ==8.2.0 test
  • pytest-cov ==4.1.0 test
  • ruff ==0.3.4 test