Skip to main content

Provides an Acumos model runner for DCAE

Project description

Acumos DCAE Model Runner

The Acumos DCAE model runner enables Acumos models to be run as if they were DCAE components.

Each Acumos model method is mapped to a subscriber and publisher stream, with _subscriber and _publisher suffixes respectively. For example, a model with a transform method would have transform_subscriber and transform_publisher streams.

The model runner implements DCAE APIs such as health checks and configuration updates.

The acumos_dcae_model_runner Python package provides a command line utility that can be used to instantiate the model runner. See the tutorial for more information.

The acumos_dcae_model_runner package should be installed in the docker image that is ultimately on-boarded into DCAE. The model runner CLI utility should be the entry point of that Docker image, as shown in the Dockerfile provided in example/ directory in the root of the repository.

Installation

The acumos_dcae_model_runner package can be installed with pip like so:

pip install acumos_dcae_model_runner --process-dependency-links

Note: The --process-dependency-links flag is required because the required dcaeapplib dependency is not yet hosted on PyPI.

If you’d prefer, you can maintain a local directory of Python packages containing dcaeapplib, and use the --find-links option:

pip install acumos_dcae_model_runner --find-links path/to/pkgs/

Tutorial

CLI Usage

To execute the model runner, use the provided CLI:

$ acumos_dcae_model_runner --help
usage: acumos_dcae_model_runner [-h] [--timeout TIMEOUT] [--debug] model_dir

positional arguments:
  model_dir          Directory that contains either the dumped model.zip or
                     its unzipped contents.

optional arguments:
  -h, --help         show this help message and exit
  --timeout TIMEOUT  Timeout (ms) used when fetching.
  --debug            Sets the log level to DEBUG

DCAE Onboarding Example

The python-dcae-model-runner repository has an example/ directory that shows how an Acumos model can be onboarded as a DCAE component.

After executing the steps below, the directory should have this structure:

example/
├── Dockerfile
├── dcae-artifacts
   ├── component.json
   ├── number-out.json
   └── numbers-in.json
├── example-model
   ├── metadata.json
   ├── model.proto
   └── model.zip
├── example_model.py
└── requirements.txt

Note: For this example, the requirements.txt file should reflect the packages and versions listed in example-model/metadata.json.

Steps

1) Create the Acumos model

The example_model.py script defines a simple Acumos model that can add two integers together. The following will generate example-model/:

python example_model.py
2) Build the docker image
docker build -t acumos-python-model-test:0.1.0 .
3) Onboard the Acumos model to DCAE

The onboarding procedure involves adding the component and data format artifacts provided in example/dcae-artifacts to the DCAE catalog.

Refer to the official DCAE onboarding documentation for the full procedure.

Release Notes

v0.1

  • Initial release of the Acumos DCAE Python model runner

Contributing Guidelines

Testing

We use a combination of tox, pytest, and flake8 to test acumos. Code which is not PEP8 compliant (aside from E501) will be considered a failing test. You can use tools like autopep8 to “clean” your code as follows:

$ pip install autopep8
$ cd python-dcae-model-runner
$ autopep8 -r --in-place --ignore E501 acumos_dcae_model_runner/

Run tox directly:

$ cd python-dcae-model-runner
$ export WORKSPACE=$(pwd)  # env var normally provided by Jenkins
$ tox

You can also specify certain tox environments to test:

$ tox -e py34  # only test against Python 3.4
$ tox -e flake8  # only lint code

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

acumos_dcae_model_runner-0.1.1.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

acumos_dcae_model_runner-0.1.1-py2-none-any.whl (10.5 kB view hashes)

Uploaded Python 2

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