Skip to main content

Process Mining Service WSGI for Auto-Twin

Project description

PyPI - License PyPI - Python Version PyPI - Version

Processing Mining Service (PMS) WSGI for Auto-Twin

The processing mining service (PMS) WSGI implements a RESTful API that invokes different system discovery modules to automatically create, update and delete graph models, Petri nets and automata in a system knowledge graph (SKG).

Installation

To facilitate installation, the PMS WSGI is released as a Python module, autotwin_pmswsgi, in the PyPI repository. autotwin_pmswsgi implicitly depends on pygraphviz. This dependency however cannot be resolved automatically by pip. As a preparation, you need to install pygraphviz manually, following instructions provided here. Whenever pygraphviz is available, the latest version of autotwin_pmswsgi can be easily installed with pip.

pip install autotwin_pmswsgi

Deployment

The PMS WSGI is almost ready to be deployed for production use once autotwin_pmswsgi is installed successfully. Four environment variables are additionally required to specify the Neo4j instance that holds the SKG of the system under consideration.

Name Description
NEO4J_URI URI of the Neo4j instance, e.g. neo4j://localhost:7687
NEO4J_USERNAME Username for the Neo4j instance, e.g. neo4j
NEO4J_PASSWORD Password for the Neo4j instance, e.g. 12345678
NEO4J_DATABASE Database where the SKG is stored, e.g. neo4j

After setting the above environment variables, you can start up the PMS WSGI on a Waitress server by executing

waitress-serve autotwin_pmswsgi:wsgi

Containerization

To enable containerization, the PMS WSGI is also released as a Docker image, ghcr.io/autotwineu/proc-mining-serv, in the GHCR registry. Suppose that a Docker engine is running on your machine. Deploying the PMS WSGI on a Docker container named proc-mining-serv can be done via a single command.

Windows:

docker run --detach ^
--env NEO4J_URI=<NEO4J_URI> ^
--env NEO4J_USERNAME=<NEO4J_USERNAME> ^
--env NEO4J_PASSWORD=<NEO4J_PASSWORD> ^
--env NEO4J_DATABASE=<NEO4J_DATABASE> ^
--volume <CLUSTERING_DIRECTORY>:/proc-mining-serv/clusterings ^
--name proc-mining-serv ^
--pull always ghcr.io/autotwineu/proc-mining-serv

Linux:

docker run --detach \
--env NEO4J_URI=<NEO4J_URI> \
--env NEO4J_USERNAME=<NEO4J_USERNAME> \
--env NEO4J_PASSWORD=<NEO4J_PASSWORD> \
--env NEO4J_DATABASE=<NEO4J_DATABASE> \
--volume <CLUSTERING_DIRECTORY>:/proc-mining-serv/clusterings \
--name proc-mining-serv \
--pull always ghcr.io/autotwineu/proc-mining-serv

<NEO4J_URI>, <NEO4J_USERNAME>, <NEO4J_PASSWORD> and <NEO4J_DATABASE> correspond to the values of the four environment variables required by the PMS WSGI (see Deployment). <CLUSTERING_DIRECTORY> is the host directory where clustering files are located.

RESTful API

The PMS WSGI listens HTTP requests on port 8080 and is accessible through a RESTful API that exposes the following endpoints for different types of models. The content types of the request and response for each API endpoint are both application/json.


API Endpoints for Graph Models

POST /graph-model (create a graph model in the SKG)

Parameters

None

Body

Content: application/json

Name Type Default Description
name string "System" Name of the system to be discovered
version string "" Version of the system to be discovered
data:clustering:path string ""* Name of the clustering file to be used
data:clustering:default string "" Cluster of parts absent from the clustering file
data:filters:interval array[number|string] [0.0, 0.0] Interval during which events are selected
data:filters:station array[string] [] Set of stations at which events are selected
data:filters:family array[string] [] Set of families for which events are selected
data:filters:type array[string] [] Set of types for which events are selected
data:usage number 0.5 Minimum data usage to be ensured
model:time_unit string "s" Unified time unit of algorithm and model parameters
model:operation:io_ratio number 1.5 Minimum ratio of input to output for an ATTACH/COMPOSE operation
model:operation:co_ratio number 0.5 Minimum ratio of cross to output for an ATTACH/ORDINARY operation
model:operation:oi_ratio number 1.5 Minimum ratio of output to input for a DETACH/DECOMPOSE operation
model:operation:ci_ratio number 0.5 Minimum ratio of cross to input for a DETACH/ORDINARY operation
model:formula:ratio number 0.0 Minimum ratio of a formula to the primary one
model:delays:seize number 0.0 Maximum delay in seizing a queued part
model:delays:release number 0.0 Maximum delay in releasing a blocked part
model:cdf:replace_pts boolean false Replace or drop invalid samples in a processing time CDF
model:cdf:points number 100 Maximum number of points in a CDF

* An empty string disables the import of clustering information.
† An empty string ignores parts not belonging to any clusters.
‡ An empty array refers to the universe of stations/families/types.

Example:

{
    "name": "Pizza Line",
    "version": "V4",
    "data": {
        "filters": {
            "interval": [
                0,
                500000000
            ],
            "station": [],
            "family": [],
            "type": []
        },
        "usage": 0.5
    },
    "model": {
        "time_unit": "ms",
        "operation": {
            "io_ratio": 1.5,
            "co_ratio": 0.5,
            "oi_ratio": 1.5,
            "ci_ratio": 0.5
        },
        "formula": {
            "ratio": 0.06
        },
        "delays": {
            "seize": 30000,
            "release": 0
        },
        "cdf": {
            "replace_pts": false,
            "points": 100
        }
    }
}

Response

Code: 201

Content: application/json

Name Type Description
model_id string ID of the generated graph model

Example:

{
    "model_id": "4:31f61bae-dad6-4cda-bb63-d4700847dea5:620887"
}

API Endpoints for Petri Nets

POST /petri-net (create a Petri net in the SKG)

Parameters

None

Body

Content: application/json

Name Type Default Description
name string "System" Name of the system to be discovered
version string "" Version of the system to be discovered
data:filters:interval array[number|string] [0.0, 0.0] Interval during which events are selected
data:filters:station array[string] []* Set of stations at which events are selected
data:filters:family array[string] []* Set of families for which events are selected
data:filters:type array[string] []* Set of types for which events are selected
data:usage number 0.5 Minimum data usage to be ensured
model:operation:io_ratio number 1.5 Minimum ratio of input to output for an ATTACH/COMPOSE operation
model:operation:co_ratio number 0.5 Minimum ratio of cross to output for an ATTACH/ORDINARY operation
model:operation:oi_ratio number 1.5 Minimum ratio of output to input for a DETACH/DECOMPOSE operation
model:operation:ci_ratio number 0.5 Minimum ratio of cross to input for a DETACH/ORDINARY operation
model:formula:ratio number 0.0 Minimum ratio of a formula to the primary one

* An empty array refers to the universe of stations/families/types.

Example:

{
    "name": "Pizza Line",
    "version": "V4",
    "data": {
        "filters": {
            "interval": [
                0,
                500000000
            ],
            "station": [],
            "family": [],
            "type": []
        },
        "usage": 0.5
    },
    "model": {
        "operation": {
            "io_ratio": 1.5,
            "co_ratio": 0.5,
            "oi_ratio": 1.5,
            "ci_ratio": 0.5
        },
        "formula": {
            "ratio": 0.06
        }
    }
}

Response

Code: 201

Content: application/json

Name Type Description
model_id string ID of the generated Petri net

Example:

{
    "model_id": "4:31f61bae-dad6-4cda-bb63-d4700847dea5:620887"
}

API Endpoints for Automata

POST /automaton (create an automaton in the SKG)

Parameters

None

Body

Content: application/json

Name Type Default Description
name string "System" Name of the system to be discovered
version string "" Version of the system to be discovered
data:filters:interval array[number|string] [0.0, 0.0] Interval during which events are selected
model:pov string "item" Point of view to be focused on

Example:

{
    "name": "Pizza Line",
    "version": "V4",
    "data": {
        "filters": {
            "interval": [
                0,
                500000000
            ]
        }
    },
    "model": {
        "pov": "item"
    }
}

Response

Code: 201

Content: application/json

Name Type Description
model_id string ID of the generated automaton

Example:

{
    "model_id": "4:31f61bae-dad6-4cda-bb63-d4700847dea5:620887"
}

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

autotwin_pmswsgi-0.1.15.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autotwin_pmswsgi-0.1.15-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file autotwin_pmswsgi-0.1.15.tar.gz.

File metadata

  • Download URL: autotwin_pmswsgi-0.1.15.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for autotwin_pmswsgi-0.1.15.tar.gz
Algorithm Hash digest
SHA256 02080df147c74b63e3ab94d858d3f0af55e993726583fb1dffe36681bba0309e
MD5 a9fcbd12567c9971d65534fe0933e319
BLAKE2b-256 8776feb9a363fd2f742d847875faf967649ffdfb3913c4dbd49cd8159933839c

See more details on using hashes here.

File details

Details for the file autotwin_pmswsgi-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: autotwin_pmswsgi-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for autotwin_pmswsgi-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 550f3e79c0874460500d4fb2b02bc69985d844e75c8026f4715a1110737d5a8d
MD5 06fdfa528c0f36b6aa30afea583d940f
BLAKE2b-256 5efc25e57cabd6718bbb44507f34ddabb1d5c5eed7a214dde0f6a39de755d179

See more details on using hashes here.

Supported by

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