Skip to content

Commit

Permalink
Merge pull request #18 from nasa/release/v1.6
Browse files Browse the repository at this point in the history
release v1.6
  • Loading branch information
teubert authored Oct 25, 2023
2 parents 2e2926f + 2e6bf47 commit bb1010c
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 56 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![GitHub License](https://img.shields.io/badge/License-NOSA-green)](https://github.com/nasa/prog_server/blob/master/license.pdf)
[![GitHub Releases](https://img.shields.io/github/release/nasa/prog_server.svg)](https://github.com/nasa/prog_server/releases)

The NASA Prognostics As-A-Service (PaaS) Sandbox is a simplified implementation of a Software Oriented Architecture (SOA) for performing prognostics (estimation of time until events and future system states) of engineering systems. The PaaS Sandbox is a wrapper around the [Prognostics Algorithms Package](https://nasa.github.io/progpy/prog_algs_guide.html) and [Prognostics Models Package](https://nasa.github.io/progpy/prog_models_guide.html), allowing one or more users to access the features of these packages through a REST API. The package is intended to be used as a research tool to prototype and benchmark Prognostics As-A-Service (PaaS) architectures and work on the challenges facing such architectures, including Generality, Communication, Security, Environmental Complexity, Utility, and Trust.
The NASA Prognostics As-A-Service (PaaS) Sandbox is a simplified implementation of a Software Oriented Architecture (SOA) for performing prognostics (estimation of time until events and future system states) of engineering systems. The PaaS Sandbox is a wrapper around the [Prognostics Python Package (ProgPy)](https://nasa.github.io/progpy/), allowing one or more users to access the features of these packages through a REST API. The package is intended to be used as a research tool to prototype and benchmark Prognostics As-A-Service (PaaS) architectures and work on the challenges facing such architectures, including Generality, Communication, Security, Environmental Complexity, Utility, and Trust.

This is designed to be used with the [Prognostics Algorithms Package](https://nasa.github.io/progpy/prog_algs_guide.html) and [Prognostics Models Package](https://nasa.github.io/progpy/prog_models_guide.html).
This is designed to be used with the [Prognostics Python Package (ProgPy)](https://nasa.github.io/progpy/).

## Installation
`pip install prog_server`
Expand All @@ -17,19 +17,19 @@ See documentation [here](https://nasa.github.io/progpy/prog_server_guide.html)
Use the following to cite this repository:

```
@misc{2023_nasa_prog_models,
@misc{2023_nasa_prog_server,
author = {Christopher Teubert and Jason Watkins and Katelyn Jarvis},
title = {Prognostics As-A-Service (PaaS) Sandbox},
month = May,
month = October,
year = 2023,
version = {1.5},
version = {1.6},
url = {https://github.com/nasa/prog_server}
}
```

The corresponding reference should look like this:

C. Teubert, J. Watkins, K. Jarvis, Prognostics As-A-Service (PaaS) Sandbox, v1.5, May 2023. URL https://github.com/nasa/prog_server.
C. Teubert, J. Watkins, K. Jarvis, Prognostics As-A-Service (PaaS) Sandbox, v1.6, Oct 2023. URL https://github.com/nasa/prog_server.

## Notices
Copyright © 2021 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='prog_server',
version='1.5.0-pre',
version='1.6.0-pre',
description='The NASA Prognostics As-A-Service (PaaS) Sandbox (a.k.a. prog_server) is a simplified Software Oriented Architecture (SOA) for performing prognostics of engineering systems. The PaaS Sandbox is a wrapper around the Prognostics Algorithms and Models Packages, allowing 1+ users to access these packages features through a REST API. The package is intended to be used as a research tool to prototype and benchmark Prognostics As-A-Service (PaaS) architectures and work on the challenges facing such architectures',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down Expand Up @@ -40,7 +40,7 @@
packages=find_packages(where='src'),
python_requires='>=3.7, <3.12',
install_requires=[
'prog_algs',
'progpy',
'requests',
'urllib3',
'flask'
Expand Down
18 changes: 9 additions & 9 deletions specs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
openapi: 3.0.2
info:
title: Prognostics As A Service (PaaS) Sandbox (prog_server)
description: The PaaS Sandbox (a.k.a., prog_server) exposes a REST API that enables prognostics using the NASA PCoE prog_models and prog_algs packages
description: The PaaS Sandbox (a.k.a., prog_server) exposes a REST API that enables prognostics using the NASA PCoE progpy and progpy packages
contact:
name: Chris Teubert
email: [email protected]
Expand Down Expand Up @@ -313,7 +313,7 @@ paths:
schema:
oneOf:
- type: object
description: bytestream of the pickled [prog_models.PrognosticsModel](https://nasa.github.io/progpy/api_ref/prog_models/PrognosticModel.html) object
description: bytestream of the pickled [progpy.PrognosticsModel](https://nasa.github.io/progpy/api_ref/progpy/PrognosticModel.html) object
- type: object
description: JSON representing configuration of model
example:
Expand Down Expand Up @@ -398,27 +398,27 @@ components:
"cov": [[0.15, 0.003], [-0.025, 0.27]]
}
- type: object
description: bytestream of the pickled [prog_models.uncertain_data.UncertainData](https://nasa.github.io/progpy/api_ref/prog_algs/UncertainData.html) object
description: bytestream of the pickled [progpy.uncertain_data.UncertainData](https://nasa.github.io/progpy/api_ref/progpy/UncertainData.html) object
SessionConfiguration:
type: object
required:
- model
properties:
model:
type: string
description: Name of the model (from prog_models.models) to use for the session.
description: Name of the model (from progpy.models) to use for the session.
model_cfg:
type: object
description: Configuration JSON for the model. Configuration parameters are specific to the model and can be found in the [prog_models.models documentation](https://nasa.github.io/progpy/api_ref/prog_models/IncludedModels.html).
description: Configuration JSON for the model. Configuration parameters are specific to the model and can be found in the [progpy.models documentation](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html).
state_est:
type: string
description: Name of the state estimator (from prog_algs.state_estimators) to use for the session.
description: Name of the state estimator (from progpy.state_estimators) to use for the session.
state_est_cfg:
type: object
description: Configuration JSON for the state estimator. Configuration parameters are specific to the state estimator.
pred:
type: string
description: Name of the predictor (from prog_algs.predictors) to use for the session.
description: Name of the predictor (from progpy.predictors) to use for the session.
pred_cfg:
type: object
description: Configuration JSON for the predictor. Configuration parameters are specific to the predictor.
Expand Down Expand Up @@ -475,10 +475,10 @@ components:
properties:
type:
type: string
description: Name of the model (from prog_models.models) to use for the session.
description: Name of the model (from progpy.models) to use for the session.
cfg:
type: object
description: Configuration JSON for the model. Configuration parameters are specific to the model and can be found in the [prog_models.models documentation](https://nasa.github.io/progpy/api_ref/prog_models/IncludedModels.html).
description: Configuration JSON for the model. Configuration parameters are specific to the model and can be found in the [progpy.models documentation](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html).

Sessions:
type: array
Expand Down
4 changes: 2 additions & 2 deletions src/prog_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from .session import Session
__version__ = '1.5.0-pre'
from prog_client.session import Session
__version__ = '1.6.0-pre'
14 changes: 7 additions & 7 deletions src/prog_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
import requests, json
import urllib3
import pickle
from prog_algs.uncertain_data import UncertainData
import prog_models
from progpy.uncertain_data import UncertainData
from progpy.utils import containers

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


class Session:
"""
Create a new Session in `prog_server`.
Create a new Session in `prog_server`
Args:
model (str): The model to use for this session (e.g., batt)
host (str, optional): Host address for PaaS Service. Defaults to '127.0.0.1'.
host (str, optional): Host address for PaaS Service. Defaults to '127.0.0.1'
port (int, optional): Port for PaaS Service. Defaults to 5000.
model_cfg (dict, optional): Configuration for ProgModel.
x0 (dict, optional): Initial state for ProgModel.
load_est (str, optional): Load estimator to use.
load_est_cfg (dict, optional): Configuration for load estimator.
state_est (str, optional): State Estimator to use (e.g., ParticleFilter). Class name for state estimator in `prog_algs.state_estimators`
state_est (str, optional): State Estimator to use (e.g., ParticleFilter). Class name for state estimator in `progpy.state_estimators`
state_est_cfg (dict, optional): Configuration for state estimator.
pred (str, optional): Prediction algorithm to use (e.g., MonteCarlo). Class name for prediction algorithm in `prog_algs.predictors`
pred (str, optional): Prediction algorithm to use (e.g., MonteCarlo). Class name for prediction algorithm in `progpy.predictors`
pred_cfg (dict, optional): Configuration for prediction algorithm.
Use:
Expand Down Expand Up @@ -103,7 +103,7 @@ def set_state(self, x):
if isinstance(x, UncertainData):
x = pickle.dumps(x)
input_format = 'uncertain_data'
elif isinstance(x, prog_models.utils.containers.DictLikeMatrixWrapper):
elif isinstance(x, containers.DictLikeMatrixWrapper):
x = pickle.dumps(x)
input_format = 'state_container'
elif isinstance(x, dict):
Expand Down
3 changes: 1 addition & 2 deletions src/prog_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# National Aeronautics and Space Administration. All Rights Reserved.

from .models.prog_server import server

__version__ = '1.5.0-pre'
__version__ = '1.6.0-pre'

def run(**kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/prog_server/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from .controllers import *
from prog_server.controllers import *
from flask import Flask

app = Flask("prog_server")
Expand Down
10 changes: 5 additions & 5 deletions src/prog_server/controllers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from .models.session import Session
from .models.load_ests import update_moving_avg
from prog_models.sim_result import SimResult, LazySimResult
from prog_algs.uncertain_data import UnweightedSamples
from prog_algs.predictors import Prediction, UnweightedSamplesPrediction
from prog_server.models.session import Session
from prog_server.models.load_ests import update_moving_avg
from progpy.sim_result import SimResult, LazySimResult
from progpy.uncertain_data import UnweightedSamples
from progpy.predictors import Prediction, UnweightedSamplesPrediction
from flask import request, abort, jsonify
from flask import current_app as app
import json
Expand Down
16 changes: 8 additions & 8 deletions src/prog_server/models/load_ests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from statistics import mean
from numpy.random import normal
from flask import abort
from functools import partial
from numpy.random import normal
from statistics import mean

def Variable(t, x = None, session = None, cfg = None):
def Variable(t, x=None, session=None, cfg=None):
"""Variable (i.e. piecewise) load estimator. The piecewise load function is defined in the load_est_cfg as ordered dictionary starting_time: load.
cfg: ordered dictionary starting_time: load. First key should always be 0
Expand All @@ -19,15 +19,15 @@ def Variable(t, x = None, session = None, cfg = None):
return cfg[time]
return cfg[keys[-1]]

def Const(t, x = None, session = None, cfg = None):
def Const(t, x=None, session=None, cfg=None):
"""Constant load estimator. Load is assumed to be constant over time.
cfg: dictionary with one key (load) where value is the constant load (dict)
e.g., {'load': {'u1': 0.1}}
"""
return cfg['load']

def MovingAverage(t, x=None, session = None, cfg = None):
def MovingAverage(t, x=None, session=None, cfg=None):
"""Moving average load estimator. Load is estimated as the mean of the last `window_size` samples. Noise can be added using the following optional configuration parameters:
* base_std: standard deviation of noise
Expand All @@ -40,7 +40,7 @@ def MovingAverage(t, x=None, session = None, cfg = None):
load = {key : mean(session.moving_avg_loads[key]) for key in session.model.inputs}
return {key : normal(load[key], std) for key in load.keys()}

def update_moving_avg(u, session = None, cfg = {}):
def update_moving_avg(u, session=None, cfg={}):
for key in session.model.inputs:
session.moving_avg_loads[key].append(u[key])
if len(session.moving_avg_loads[key]) > cfg.get('window_size', 10):
Expand All @@ -51,5 +51,5 @@ def build_load_est(name, cfg, session):
abort(400, f"{name} is not a valid load estimation method")
load_est_fcn = globals()[name]
return partial(load_est_fcn,
cfg = cfg,
session = session)
cfg=cfg,
session=session)
2 changes: 1 addition & 1 deletion src/prog_server/models/prediction_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# National Aeronautics and Space Administration. All Rights Reserved.

from concurrent.futures import ThreadPoolExecutor as PoolExecutor
from copy import deepcopy
from datetime import datetime
from flask import current_app as app
from copy import deepcopy

pool = PoolExecutor(max_workers=5)

Expand Down
4 changes: 3 additions & 1 deletion src/prog_server/models/prog_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from ..app import app
from prog_server.app import app

from multiprocessing import Process
import requests


class ProgServer():
"""
This class is a wrapper for the flask server.
Expand Down
8 changes: 3 additions & 5 deletions src/prog_server/models/session.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Copyright © 2021 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.

from .load_ests import build_load_est
from .prediction_handler import add_to_predict_queue
from prog_server.models.load_ests import build_load_est
from prog_server.models.prediction_handler import add_to_predict_queue

from flask import current_app as app
from flask import abort

from prog_models import models
from prog_algs import state_estimators, predictors
from progpy import models, state_estimators, predictors
from threading import Lock

class Session():
Expand Down
5 changes: 2 additions & 3 deletions tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import unittest
import time
import prog_client, prog_server
from progpy.uncertain_data import MultivariateNormalDist
from progpy.models import ThrownObject

TIMEOUT = 10 # Server startup timeout in seconds

Expand All @@ -20,7 +22,6 @@ def setUpClass(cls):
raise Exception("Server startup timeout")

def test_integration(self):
from prog_models.models import ThrownObject
noise = {'x': 0.1, 'v': 0.1}
if 'max_x' in ThrownObject.states:
# max_x was removed in the dev branch
Expand All @@ -40,7 +41,6 @@ def test_integration(self):
for key, value in x.mean.items():
self.assertAlmostEqual(value, x2[key])

from prog_algs.uncertain_data import MultivariateNormalDist
mean = {'x': 2, 'v': 40}
cov = [[0.1, 0], [0, 0.1]]
x3 = MultivariateNormalDist(mean.keys(), list(mean.values()), cov)
Expand Down Expand Up @@ -167,7 +167,6 @@ def test_error_in_init(self):

# Extra state
x0 = {'x': 1.2, 'v': 2.3, 'max_y': 4.5}
from prog_models.models import ThrownObject
if 'max_x' in ThrownObject.states:
# max_x was removed in recent version
x0['max_x'] = 1.2
Expand Down

0 comments on commit bb1010c

Please sign in to comment.