[![PyPI - License](https://img.shields.io/pypi/l/autotwin_pmswsgi)](https://github.com/AutotwinEU/proc-mining-serv/blob/main/LICENSE)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/autotwin_pmswsgi)](https://www.python.org/downloads/)
[![PyPI - Version](https://img.shields.io/pypi/v/autotwin_pmswsgi)](https://pypi.org/project/autotwin_pmswsgi/)
# 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](https://pygraphviz.github.io/documentation/stable/install.html).
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](https://github.com/neo4j/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](https://github.com/Pylons/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.
docker run --detach --env NEO4J_URI=<NEO4J_URI> --env NEO4J_USERNAME=<NEO4J_USERNAME> --env NEO4J_PASSWORD=<NEO4J_PASSWORD> --env NEO4J_DATABASE=<NEO4J_DATABASE> --name proc-mining-serv --publish 8080:8080 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](#deployment)).
## 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
<details>
<summary>
<code>POST</code>
<code><b>/graph-model</b></code>
<code>(create a graph model in the SKG)</code>
</summary>
<br/>
**Parameters**
> None
**Body**
> Definition
>
> | Name | Type | Description |
> |------------------------|-------------------------|----------------------------------------|
> | `name` | `string` | Name of the system to be discovered |
> | `version` | `string` | Version of the system to be discovered |
> | `neo4j:interval` | `array[number\|string]` | Interval of the event log to be used |
> | `model:delays:seize` | `number\|string` | Delay in seizing a queued part |
> | `model:delays:release` | `number\|string` | Delay in releasing a blocked part |
> Example
> ```json
> {
> "name": "Pizza Line",
> "version": "V3",
> "neo4j": {
> "interval": [0, 30000000]
> },
> "model": {
> "delays": {
> "seize": 0,
> "release": 0
> }
> }
> }
> ```
**Response**
> Code: 201
> Definition
>
> | Name | Type | Description |
> |------------|----------|---------------------------------|
> | `model_id` | `string` | ID of the generated graph model |
> Example
> ```json
> {
> "model_id": "4:1b90f766-3bae-49da-b38f-60f0d84b2d08:226294"
> }
> ```
</details>
--------------------------------------------------------------------------------
### API Endpoints for Petri Nets
<details>
<summary>
<code>POST</code>
<code><b>/petri-net</b></code>
<code>(create a Petri net in the SKG)</code>
</summary>
<br/>
**Parameters**
> None
**Body**
> None
**Response**
> Code: 501
> Definition
>
> | Name | Type | Description |
> |---------------|----------|-------------------------------|
> | `code` | `string` | Code of the HTTP error |
> | `name` | `string` | Name of the HTTP error |
> | `description` | `string` | Description of the HTTP error |
> Example
> ```json
> {
> "code": 501,
> "name": "Not Implemented",
> "description": "The server does not support the action requested by the browser."
> }
> ```
</details>
--------------------------------------------------------------------------------
### API Endpoints for Automata
<details>
<summary>
<code>POST</code>
<code><b>/automaton</b></code>
<code>(create an automaton in the SKG)</code>
</summary>
<br/>
**Parameters**
> None
**Body**
> None
**Response**
> Code: 501
> Definition
>
> | Name | Type | Description |
> |---------------|----------|-------------------------------|
> | `code` | `string` | Code of the HTTP error |
> | `name` | `string` | Name of the HTTP error |
> | `description` | `string` | Description of the HTTP error |
> Example
> ```json
> {
> "code": 501,
> "name": "Not Implemented",
> "description": "The server does not support the action requested by the browser."
> }
> ```
</details>
--------------------------------------------------------------------------------
Raw data
{
"_id": null,
"home_page": "https://github.com/AutotwinEU/proc-mining-serv",
"name": "autotwin_pmswsgi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "auto-twin,system discovery,restful service",
"author": "Lulai Zhu",
"author_email": "lulai.zhu@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6e/06/779755078f91566232a942afb1e8ea42f63e49807891ed8e21a5b602b1c7/autotwin_pmswsgi-0.0.3.tar.gz",
"platform": null,
"description": "[![PyPI - License](https://img.shields.io/pypi/l/autotwin_pmswsgi)](https://github.com/AutotwinEU/proc-mining-serv/blob/main/LICENSE)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/autotwin_pmswsgi)](https://www.python.org/downloads/)\n[![PyPI - Version](https://img.shields.io/pypi/v/autotwin_pmswsgi)](https://pypi.org/project/autotwin_pmswsgi/)\n\n# Processing Mining Service (PMS) WSGI for Auto-Twin\n\nThe processing mining service (PMS) WSGI implements a RESTful API that invokes\ndifferent system discovery modules to automatically create, update and delete\ngraph models, Petri nets and automata in a system knowledge graph (SKG).\n\n## Installation\nTo facilitate installation, the PMS WSGI is released as a Python module,\n`autotwin_pmswsgi`, in the PyPI repository. `autotwin_pmswsgi` implicitly\ndepends on `pygraphviz`. This dependency however cannot be resolved\nautomatically by `pip`. As a preparation, you need to install `pygraphviz`\nmanually, following instructions provided\n[here](https://pygraphviz.github.io/documentation/stable/install.html).\nWhenever `pygraphviz` is available, the latest version of `autotwin_pmswsgi`\ncan be easily installed with `pip`.\n\n pip install autotwin_pmswsgi\n\n## Deployment\nThe PMS WSGI is almost ready to be deployed for production use once\n`autotwin_pmswsgi` is installed successfully. Four environment variables are\nadditionally required to specify the [Neo4j](https://github.com/neo4j/neo4j)\ninstance that holds the SKG of the system under consideration.\n\n| Name | Description |\n|------------------|----------------------------------------------------------|\n| `NEO4J_URI` | URI of the Neo4j instance, e.g. `neo4j://localhost:7687` |\n| `NEO4J_USERNAME` | Username for the Neo4j instance, e.g. `neo4j` |\n| `NEO4J_PASSWORD` | Password for the Neo4j instance, e.g. `12345678` |\n| `NEO4J_DATABASE` | Database where the SKG is stored, e.g. `neo4j` |\n\nAfter setting the above environment variables, you can start up the PMS WSGI on\na [Waitress](https://github.com/Pylons/waitress) server by executing\n\n waitress-serve autotwin_pmswsgi:wsgi\n\n## Containerization\nTo enable containerization, the PMS WSGI is also released as a Docker image,\n`ghcr.io/autotwineu/proc-mining-serv`, in the GHCR registry. Suppose that a\nDocker engine is running on your machine. Deploying the PMS WSGI on a Docker\ncontainer named `proc-mining-serv` can be done via a single command.\n\n docker run --detach --env NEO4J_URI=<NEO4J_URI> --env NEO4J_USERNAME=<NEO4J_USERNAME> --env NEO4J_PASSWORD=<NEO4J_PASSWORD> --env NEO4J_DATABASE=<NEO4J_DATABASE> --name proc-mining-serv --publish 8080:8080 ghcr.io/autotwineu/proc-mining-serv\n\n`<NEO4J_URI>`, `<NEO4J_USERNAME>`, `<NEO4J_PASSWORD>` and `<NEO4J_DATABASE>`\ncorrespond to the values of the four environment variables required by the PMS\nWSGI (see [Deployment](#deployment)).\n\n## RESTful API\nThe PMS WSGI listens HTTP requests on port `8080` and is accessible through a\nRESTful API that exposes the following endpoints for different types of models.\nThe content types of the request and response for each API endpoint are both\n`application/json`.\n\n--------------------------------------------------------------------------------\n\n### API Endpoints for Graph Models\n\n<details>\n <summary>\n <code>POST</code>\n <code><b>/graph-model</b></code>\n <code>(create a graph model in the SKG)</code>\n </summary>\n <br/>\n\n**Parameters**\n> None\n\n**Body**\n> Definition\n>\n> | Name | Type | Description |\n> |------------------------|-------------------------|----------------------------------------|\n> | `name` | `string` | Name of the system to be discovered |\n> | `version` | `string` | Version of the system to be discovered |\n> | `neo4j:interval` | `array[number\\|string]` | Interval of the event log to be used |\n> | `model:delays:seize` | `number\\|string` | Delay in seizing a queued part |\n> | `model:delays:release` | `number\\|string` | Delay in releasing a blocked part |\n\n> Example\n> ```json\n> {\n> \"name\": \"Pizza Line\",\n> \"version\": \"V3\",\n> \"neo4j\": {\n> \"interval\": [0, 30000000]\n> },\n> \"model\": {\n> \"delays\": {\n> \"seize\": 0,\n> \"release\": 0\n> }\n> }\n> }\n> ```\n\n**Response**\n> Code: 201\n\n> Definition\n> \n> | Name | Type | Description |\n> |------------|----------|---------------------------------|\n> | `model_id` | `string` | ID of the generated graph model |\n\n> Example\n> ```json\n> {\n> \"model_id\": \"4:1b90f766-3bae-49da-b38f-60f0d84b2d08:226294\"\n> }\n> ```\n\n</details>\n\n--------------------------------------------------------------------------------\n\n### API Endpoints for Petri Nets\n\n<details>\n <summary>\n <code>POST</code>\n <code><b>/petri-net</b></code>\n <code>(create a Petri net in the SKG)</code>\n </summary>\n <br/>\n\n**Parameters**\n> None\n\n**Body**\n> None\n\n**Response**\n> Code: 501\n\n> Definition\n> \n> | Name | Type | Description |\n> |---------------|----------|-------------------------------|\n> | `code` | `string` | Code of the HTTP error |\n> | `name` | `string` | Name of the HTTP error |\n> | `description` | `string` | Description of the HTTP error |\n\n> Example\n> ```json\n> {\n> \"code\": 501,\n> \"name\": \"Not Implemented\",\n> \"description\": \"The server does not support the action requested by the browser.\"\n> }\n> ```\n\n</details>\n\n--------------------------------------------------------------------------------\n\n### API Endpoints for Automata\n\n<details>\n <summary>\n <code>POST</code>\n <code><b>/automaton</b></code>\n <code>(create an automaton in the SKG)</code>\n </summary>\n <br/>\n\n**Parameters**\n> None\n\n**Body**\n> None\n\n**Response**\n> Code: 501\n\n> Definition\n> \n> | Name | Type | Description |\n> |---------------|----------|-------------------------------|\n> | `code` | `string` | Code of the HTTP error |\n> | `name` | `string` | Name of the HTTP error |\n> | `description` | `string` | Description of the HTTP error |\n\n> Example\n> ```json\n> {\n> \"code\": 501,\n> \"name\": \"Not Implemented\",\n> \"description\": \"The server does not support the action requested by the browser.\"\n> }\n> ```\n\n</details>\n\n--------------------------------------------------------------------------------\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Process Mining Service WSGI for Auto-Twin",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/AutotwinEU/proc-mining-serv"
},
"split_keywords": [
"auto-twin",
"system discovery",
"restful service"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1246914d05861342a082466c1230a1af950ecad73c3cb6c87aa4545ad80df1aa",
"md5": "4b48987c36a9a7d3b9a83044681e5f97",
"sha256": "cdc8dbd68ccb60946f5088646eba80dd49d92c3a47519b20eadb0edc4649fd09"
},
"downloads": -1,
"filename": "autotwin_pmswsgi-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4b48987c36a9a7d3b9a83044681e5f97",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 5534,
"upload_time": "2024-03-12T22:37:57",
"upload_time_iso_8601": "2024-03-12T22:37:57.267107Z",
"url": "https://files.pythonhosted.org/packages/12/46/914d05861342a082466c1230a1af950ecad73c3cb6c87aa4545ad80df1aa/autotwin_pmswsgi-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6e06779755078f91566232a942afb1e8ea42f63e49807891ed8e21a5b602b1c7",
"md5": "747b30a3797e1d896a960b930717841e",
"sha256": "b5a7558699acfa10731a553e76416b9dae101892283ab394bc3e55966c69d1d0"
},
"downloads": -1,
"filename": "autotwin_pmswsgi-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "747b30a3797e1d896a960b930717841e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 5445,
"upload_time": "2024-03-12T22:37:58",
"upload_time_iso_8601": "2024-03-12T22:37:58.899536Z",
"url": "https://files.pythonhosted.org/packages/6e/06/779755078f91566232a942afb1e8ea42f63e49807891ed8e21a5b602b1c7/autotwin_pmswsgi-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-12 22:37:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AutotwinEU",
"github_project": "proc-mining-serv",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "autotwin_pmswsgi"
}