Name | fabric_fim JSON |
Version |
1.7.2
JSON |
| download |
home_page | None |
Summary | FABRIC Information Model library and utilities |
upload_time | 2024-10-02 18:22:04 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
neo4j
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![PyPI](https://img.shields.io/pypi/v/fabric-fim?style=plastic)](https://pypi.org/project/fabric-fim/)
# Information Model
## Basic Graph Abstractions
FABRIC Information Model library, containing class definitions and methods for operating
on different types of information model representations (sliver and slice).
The implementation covers the following models and model transformations:
- ARM (Aggregate Resource Models) - generated by aggregate owner, may contain multiple resource delegations intended
for different brokers
- ADM (Aggregate Delegation Model) - a single ARM may be partitioned into one or more ADMs intended for different
brokers
- CBM (Combined Broker Model) - multiple ADMs sent to a broker from different aggregates are merged into a single CBM.
If needed ADMs can be 'unmerged' from a CBM (when e.g. an aggregate goes off-line)
- BQM (Broker Query Model) - multiple types of BQMs can be produced by a broker in response to `listResources`-like
queries from the information contained in CBM and live allocation information stored by the Broker.
The returned models can contain different levels of details of resources. BQMs can be used by user tools,
portals or other entities which need to inspect available testbed resources
- ASM (Abstract Slice Mode) - model generated by user tools, passed to the Orchestrator, which describes a slice
topology. This model can be annotated by Orchestrator and Aggregate Managers with details of the provisioned (vs.
requested) infrastructure and returned back to the user. ASMs encompass what is commonly referred to as Slice Request
and Slice Manifest.
These models are based on a common framework of Abstract Property Graph class `fim.graph.abc_property_graph.py`, which are
then subclassed into a NetworkX-based implementation and a Neo4j-based implementation of abstract functionalities.
Further types of models are built on top of these two implementations, thus allowing for easy interchange of the
underlying graph implementation - in-memory (via NetworkX) or persistent (via Neo4j).
There is a generic graph validation framework built-in - validation is stronger/more thorough when operating on Neo4j
implementations due to stronger expressivity of Neo4j Cypher query language. Graph validation rules can be found under
`fim.graph.data`.
ARM, ADM, CBM definitions and implementations can be found under `fim.graph.resources`, ASM - under `fim.graph.slices`.
Abstract definitions of BQM are found under `fim.graph.resources`, however multiple subtypes of BQM (with different
levels of topology details presented to the requestor). Generation of different types of BQMs is done via broker plugins
intended to be external to FIM (perhaps inside the Control Framework). See `fim.pluggable.py` for more details on
plugins.
## Higher-level Abstractions
On top of basic property graph models described above, FIM offers additional more convenient abstractions that
interchangeably use the property graph implementations (NetworkX or Neo4j) underneath to allow for easier manipulation,
inspection of data.
The main set of abstractions is implemented under `fim.user` package, which provides
[additional documentation](fim/user/README.md).
Supporting intermediate models are implemented under `fim.sliver`, however these models are largely internal to FIM and
Control Framework, and generally are not exposed to end-users.
## Structure of the code
This figure reflects the overall structure of the code:
![Code structure](figs/fim-structure.png)
Follow this link into [fim/README.md](fim/README.md) to explore.
## Development environment
The recommended way is to set up your development environment using `virtualenvwrapper` after checking
out the code:
```bash
$ git clone git@github.com:fabric-testbed/InformationModel.git
$ cd InformationModel
$ mkvirtualenv -r requirements.txt infomodel
$ workon infomodel
(infomodel) $
```
You can also use the built-in `venv` tool that comes with newer versions of Python as follows:
```
$ git clone git@github.com:fabric-testbed/InformationModel.git
$ cd InformationModel
$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install --upgrade pip setuptools
(venv) $
```
Depending on which parts of FIM you are developing you may need to have
[Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc) running.
Working on any models whose names start with `Neo4j` generally requires using the Neo4j Docker.
Models which start with `NetworkX` operate on in-memory models using NetworkX toolkit and don't require the Neo4j Docker.
Higher-level abstractions under `fim.user` can all be debugged and tested with in-memory NetworkX models, although they
operate on both types of models, depending on the situation.
Follow the instructions with the container to start it.
## Installation
Multiple installation options possible. For CF development the recommended method is to
[install from GitHub MASTER branch](https://codeinthehole.com/tips/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/):
```bash
$ pip install git+https://github.com/fabric-testbed/InformationModel.git
```
For developing and testing the FIM code itself use editable install (from top-level directory) and
install flit and pytest:
```bash
(infomodel) $ pip install -e .
(infomodel) $ pip install flit
(infomodel) $ pip install pytest
```
For inclusion in tools, etc, use PyPi
```bash
$ pip install fabric-fim
```
### Compatibility with Neo4j
Below is the compatibility matrix showing which major versions of FIM support which versions of Neo4j
(tested with the corresponding versions of [Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc))
| FIM Major version | Neo4j-APOC docker version |
|--------------------|---------------------------|
| 1.0-1.2 | 4.0.3 |
| 1.3-1.4 | 4.1.6 |
| 1.5 | 5.3.0 |
## Test Graphs
### Original Test Graphs
Original test graphs are located under [tests/models](tests/models). All graphs were created using
[yEd](https://www.yworks.com/products/yed)
desktop graph editor (note that on-line version does not provide the same flexibility for creating custom node
and link properties).
### Generating New Test Graphs
Depending on the type of graph, many test graphs can be generated using higher-level abstraction libraries.
For example ASMs can be generated starting from `fim.user.topology.ExperimentTopology` object, while ARMs can be
generated using `fim.user.topology.SubstrateTopology`. Other models are generally derived from these types of models,
as described in the overview.
Test graphs are generated by unit tests:
- ASMs are generated in `test/slice_topology_test.py`
- ARMs are generated in `test/substrate_topology_test.py`
- ARM-ADM-CBM operations are tested in `test/zz_neo4j_pg_test.py` based on serializations produced in
`test/substrate_topology_test.py`.
## Testing and building
In order to run tests, you will need to use [pytest](https://pypi.org/project/pytest/).
Also, in order to support tests of Neo4j-implemented models, Neo4j-APOC should be running in a Docker container:
```console
$ docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/password \
-v $(pwd)/neo4j/data:/data -v $(pwd)/neo4j/imports:/imports \
fabrictestbed/neo4j-apoc
```
Note that the directories `neo4j/data` and `neo4j/imports` must exist for the above command to work as expected.
Wait for neo4j-apoc Docker container to start up, and then run pytest:
```console
$ pytest [-s] test
```
This will produce substrate ARM models and save them into file in project root folder.
To build and publish run
```console
$ flit build
$ flit publish
```
or just (assuming your .pypirc is setup with the token to access PyPi)
```console
$ flit publish
```
## Graph validation
All graphs loaded into Neo4j (whether from files or being passed in as part of query or delegation)
must conform to a set of rules expressed as Cypher queries. The basic set of rules for all
types of graphs are located in [fim/graph/graph_validation_rules.json](fim/graph/data/graph_validation_rules.json).
Prior to ingestion graphs are also tested on general syntax validity of JSON-formatted fields.
Additional rule files specific to model types may govern the validity of specific models.
NetworkX-based graphs also undergo validation, but more limited in scope due to lack of tools.
## Using fim_util utility
The utility supports a number of operations on GraphML files - enumerating nodes (for graphs)
coming out of yEd, loading into an instance of Neo4j, deleting graphs from Neo4j.
Start the appropriate version of [Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc)
Create fim_config.yaml with the following structure under `util/`:
```
# default fim_config configuration file for FIM utilities
neo4j:
url: neo4j://0.0.0.0:7687
user: neo4j
pass: password
import_host_dir: /host/directory/seen/by/neo4j/docker/as/imports
import_dir: /imports
```
Parameters `password` and `import_host_dir` depend on how the Docker container is started in
the procedure above. Other parameters should remain unchanged from what is shown.
Run the utility for detailed help for the various operations:
```
(infomodel) $ fim_util -h
```
Generally the utility is good for e.g. loading a graph file: `fim_util -l -f -r <graphml file>` or
merging multiple advertisements: `fim_util -m -f <file1> -f <file2>`. Most options take multiple `-f`
and related options so can e.g. load multiple files at once.
When testing large graphs, note that by default Neo4j visualizes the first 300 nodes in a browser. If you
want to see a full graph, increase this limit (at neo4j prompt):
```
:config initialNodeDisplay: 5000
```
## Neo4j Performance Considerations
For performance reasons it is critical that every instance of Neo4j has appropriate indexes created.
Neo4j label `GraphNode` is hard-coded within FIM - every graph node has this label and another label is created
from the Class property and is meaningful to FIM.
This is done for performance reasons to make it easier to create indexes and query models using those indexes.
The following indexes are required (indexes are created automatically by Neo4jGraphImporter whenever it is used):
```
CREATE INDEX graphid FOR (n:GraphNode) ON (n.GraphID)
CREATE INDEX graphid_nodeid FOR (n:GraphNode) ON (n.GraphID, n.NodeID)
CREATE INDEX graphid_nodeid_type FOR (n:GraphNode) ON (n.GraphID, n.NodeID, n.Type)
CREATE INDEX graphid_type FOR (n:GraphNode) ON (n.GraphID, n.Type)
```
Available indexes can be checked via console by using the `:schema` command.
An index can be dropped using the following command (substitute appropriate index name):
```
DROP INDEX graphid
```
See [additional documentation](https://neo4j.com/docs/cypher-manual/current/administration/indexes-for-search-performance/).
Raw data
{
"_id": null,
"home_page": null,
"name": "fabric_fim",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Neo4j",
"author": null,
"author_email": "Ilya Baldin <ibaldin@renci.org>",
"download_url": "https://files.pythonhosted.org/packages/8a/ae/e70b75643ece917a97a54dac49f89439cf3357fe6f59f6bab71efb960afb/fabric_fim-1.7.2.tar.gz",
"platform": null,
"description": "[![PyPI](https://img.shields.io/pypi/v/fabric-fim?style=plastic)](https://pypi.org/project/fabric-fim/)\n\n# Information Model\n\n## Basic Graph Abstractions\n\nFABRIC Information Model library, containing class definitions and methods for operating\non different types of information model representations (sliver and slice). \n\nThe implementation covers the following models and model transformations: \n- ARM (Aggregate Resource Models) - generated by aggregate owner, may contain multiple resource delegations intended\n for different brokers\n- ADM (Aggregate Delegation Model) - a single ARM may be partitioned into one or more ADMs intended for different \n brokers\n- CBM (Combined Broker Model) - multiple ADMs sent to a broker from different aggregates are merged into a single CBM.\nIf needed ADMs can be 'unmerged' from a CBM (when e.g. an aggregate goes off-line)\n- BQM (Broker Query Model) - multiple types of BQMs can be produced by a broker in response to `listResources`-like \nqueries from the information contained in CBM and live allocation information stored by the Broker. \nThe returned models can contain different levels of details of resources. BQMs can be used by user tools, \n portals or other entities which need to inspect available testbed resources\n- ASM (Abstract Slice Mode) - model generated by user tools, passed to the Orchestrator, which describes a slice \n topology. This model can be annotated by Orchestrator and Aggregate Managers with details of the provisioned (vs.\n requested) infrastructure and returned back to the user. ASMs encompass what is commonly referred to as Slice Request\n and Slice Manifest. \n \nThese models are based on a common framework of Abstract Property Graph class `fim.graph.abc_property_graph.py`, which are\nthen subclassed into a NetworkX-based implementation and a Neo4j-based implementation of abstract functionalities. \nFurther types of models are built on top of these two implementations, thus allowing for easy interchange of the \nunderlying graph implementation - in-memory (via NetworkX) or persistent (via Neo4j). \n\nThere is a generic graph validation framework built-in - validation is stronger/more thorough when operating on Neo4j \nimplementations due to stronger expressivity of Neo4j Cypher query language. Graph validation rules can be found under\n`fim.graph.data`. \n\nARM, ADM, CBM definitions and implementations can be found under `fim.graph.resources`, ASM - under `fim.graph.slices`.\nAbstract definitions of BQM are found under `fim.graph.resources`, however multiple subtypes of BQM (with different\nlevels of topology details presented to the requestor). Generation of different types of BQMs is done via broker plugins\nintended to be external to FIM (perhaps inside the Control Framework). See `fim.pluggable.py` for more details on \nplugins.\n\n## Higher-level Abstractions\n\nOn top of basic property graph models described above, FIM offers additional more convenient abstractions that \ninterchangeably use the property graph implementations (NetworkX or Neo4j) underneath to allow for easier manipulation,\ninspection of data. \n\nThe main set of abstractions is implemented under `fim.user` package, which provides \n[additional documentation](fim/user/README.md).\n\nSupporting intermediate models are implemented under `fim.sliver`, however these models are largely internal to FIM and\nControl Framework, and generally are not exposed to end-users. \n\n## Structure of the code\n\nThis figure reflects the overall structure of the code:\n\n![Code structure](figs/fim-structure.png)\n\nFollow this link into [fim/README.md](fim/README.md) to explore.\n\n## Development environment\n\nThe recommended way is to set up your development environment using `virtualenvwrapper` after checking\nout the code:\n```bash\n$ git clone git@github.com:fabric-testbed/InformationModel.git\n$ cd InformationModel\n$ mkvirtualenv -r requirements.txt infomodel\n$ workon infomodel\n(infomodel) $\n```\n\nYou can also use the built-in `venv` tool that comes with newer versions of Python as follows:\n```\n$ git clone git@github.com:fabric-testbed/InformationModel.git\n$ cd InformationModel\n$ python3 -m venv venv\n$ source ./venv/bin/activate\n$ pip install --upgrade pip setuptools\n(venv) $\n``` \n\nDepending on which parts of FIM you are developing you may need to have \n[Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc) running.\nWorking on any models whose names start with `Neo4j` generally requires using the Neo4j Docker. \n\nModels which start with `NetworkX` operate on in-memory models using NetworkX toolkit and don't require the Neo4j Docker.\nHigher-level abstractions under `fim.user` can all be debugged and tested with in-memory NetworkX models, although they\noperate on both types of models, depending on the situation.\n\nFollow the instructions with the container to start it. \n\n## Installation\n\nMultiple installation options possible. For CF development the recommended method is to\n[install from GitHub MASTER branch](https://codeinthehole.com/tips/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/):\n```bash\n$ pip install git+https://github.com/fabric-testbed/InformationModel.git\n```\n\nFor developing and testing the FIM code itself use editable install (from top-level directory) and\ninstall flit and pytest:\n```bash\n(infomodel) $ pip install -e .\n(infomodel) $ pip install flit\n(infomodel) $ pip install pytest\n```\n\nFor inclusion in tools, etc, use PyPi \n```bash\n$ pip install fabric-fim\n```\n\n### Compatibility with Neo4j\n\nBelow is the compatibility matrix showing which major versions of FIM support which versions of Neo4j\n(tested with the corresponding versions of [Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc))\n\n| FIM Major version | Neo4j-APOC docker version |\n|--------------------|---------------------------|\n | 1.0-1.2 | 4.0.3 |\n | 1.3-1.4 | 4.1.6 |\n | 1.5 | 5.3.0 |\n\n## Test Graphs\n\n### Original Test Graphs\n\nOriginal test graphs are located under [tests/models](tests/models). All graphs were created using \n[yEd](https://www.yworks.com/products/yed)\ndesktop graph editor (note that on-line version does not provide the same flexibility for creating custom node\nand link properties).\n\n### Generating New Test Graphs\n\nDepending on the type of graph, many test graphs can be generated using higher-level abstraction libraries. \n\nFor example ASMs can be generated starting from `fim.user.topology.ExperimentTopology` object, while ARMs can be\ngenerated using `fim.user.topology.SubstrateTopology`. Other models are generally derived from these types of models,\nas described in the overview. \n\nTest graphs are generated by unit tests:\n- ASMs are generated in `test/slice_topology_test.py`\n- ARMs are generated in `test/substrate_topology_test.py`\n- ARM-ADM-CBM operations are tested in `test/zz_neo4j_pg_test.py` based on serializations produced in \n `test/substrate_topology_test.py`.\n\n## Testing and building\n\nIn order to run tests, you will need to use [pytest](https://pypi.org/project/pytest/).\nAlso, in order to support tests of Neo4j-implemented models, Neo4j-APOC should be running in a Docker container:\n\n```console\n$ docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/password \\\n -v $(pwd)/neo4j/data:/data -v $(pwd)/neo4j/imports:/imports \\\n fabrictestbed/neo4j-apoc\n```\n\nNote that the directories `neo4j/data` and `neo4j/imports` must exist for the above command to work as expected.\n\nWait for neo4j-apoc Docker container to start up, and then run pytest:\n\n```console\n$ pytest [-s] test\n```\n\nThis will produce substrate ARM models and save them into file in project root folder.\n\nTo build and publish run \n```console\n$ flit build\n$ flit publish\n```\nor just (assuming your .pypirc is setup with the token to access PyPi)\n```console\n$ flit publish\n```\n\n## Graph validation\n\nAll graphs loaded into Neo4j (whether from files or being passed in as part of query or delegation) \nmust conform to a set of rules expressed as Cypher queries. The basic set of rules for all \ntypes of graphs are located in [fim/graph/graph_validation_rules.json](fim/graph/data/graph_validation_rules.json).\n\nPrior to ingestion graphs are also tested on general syntax validity of JSON-formatted fields. \n\nAdditional rule files specific to model types may govern the validity of specific models.\n\nNetworkX-based graphs also undergo validation, but more limited in scope due to lack of tools.\n\n## Using fim_util utility\n\nThe utility supports a number of operations on GraphML files - enumerating nodes (for graphs)\ncoming out of yEd, loading into an instance of Neo4j, deleting graphs from Neo4j.\n\nStart the appropriate version of [Neo4j-APOC docker container](https://github.com/fabric-testbed/fabric-docker-images/tree/master/neo4j-apoc)\n\nCreate fim_config.yaml with the following structure under `util/`:\n```\n# default fim_config configuration file for FIM utilities\nneo4j:\n url: neo4j://0.0.0.0:7687\n user: neo4j\n pass: password\n import_host_dir: /host/directory/seen/by/neo4j/docker/as/imports\n import_dir: /imports\n```\nParameters `password` and `import_host_dir` depend on how the Docker container is started in\nthe procedure above. Other parameters should remain unchanged from what is shown. \n\nRun the utility for detailed help for the various operations:\n```\n(infomodel) $ fim_util -h\n```\n\nGenerally the utility is good for e.g. loading a graph file: `fim_util -l -f -r <graphml file>` or\nmerging multiple advertisements: `fim_util -m -f <file1> -f <file2>`. Most options take multiple `-f`\nand related options so can e.g. load multiple files at once.\n\nWhen testing large graphs, note that by default Neo4j visualizes the first 300 nodes in a browser. If you\nwant to see a full graph, increase this limit (at neo4j prompt):\n```\n:config initialNodeDisplay: 5000\n```\n\n## Neo4j Performance Considerations\nFor performance reasons it is critical that every instance of Neo4j has appropriate indexes created. \nNeo4j label `GraphNode` is hard-coded within FIM - every graph node has this label and another label is created\nfrom the Class property and is meaningful to FIM. \nThis is done for performance reasons to make it easier to create indexes and query models using those indexes.\n\nThe following indexes are required (indexes are created automatically by Neo4jGraphImporter whenever it is used):\n```\nCREATE INDEX graphid FOR (n:GraphNode) ON (n.GraphID)\nCREATE INDEX graphid_nodeid FOR (n:GraphNode) ON (n.GraphID, n.NodeID)\nCREATE INDEX graphid_nodeid_type FOR (n:GraphNode) ON (n.GraphID, n.NodeID, n.Type)\nCREATE INDEX graphid_type FOR (n:GraphNode) ON (n.GraphID, n.Type)\n```\nAvailable indexes can be checked via console by using the `:schema` command. \n\nAn index can be dropped using the following command (substitute appropriate index name):\n```\nDROP INDEX graphid\n```\n\nSee [additional documentation](https://neo4j.com/docs/cypher-manual/current/administration/indexes-for-search-performance/).\n",
"bugtrack_url": null,
"license": null,
"summary": "FABRIC Information Model library and utilities",
"version": "1.7.2",
"project_urls": {
"Home": "https://github.com/fabric-testbed/InformationModel"
},
"split_keywords": [
"neo4j"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c481f0e8ebbd2269d14565bad91c7a97630c864f63978ed3d55deac0b7a2cc42",
"md5": "e9ad1ff117f7a19a9e86b3a31576b197",
"sha256": "356a5320722f3ec4db3330824d142838d7ec564a0de9aa4d4b07acc4d5a327fa"
},
"downloads": -1,
"filename": "fabric_fim-1.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e9ad1ff117f7a19a9e86b3a31576b197",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 195551,
"upload_time": "2024-10-02T18:22:02",
"upload_time_iso_8601": "2024-10-02T18:22:02.900300Z",
"url": "https://files.pythonhosted.org/packages/c4/81/f0e8ebbd2269d14565bad91c7a97630c864f63978ed3d55deac0b7a2cc42/fabric_fim-1.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8aaee70b75643ece917a97a54dac49f89439cf3357fe6f59f6bab71efb960afb",
"md5": "1273a2abdced6719ef4680ac624798b1",
"sha256": "3ed55d48dbcc7c18394bcc783f5a68ad095ccce1d63fddcf8dcdefdde9d167d1"
},
"downloads": -1,
"filename": "fabric_fim-1.7.2.tar.gz",
"has_sig": false,
"md5_digest": "1273a2abdced6719ef4680ac624798b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 218827,
"upload_time": "2024-10-02T18:22:04",
"upload_time_iso_8601": "2024-10-02T18:22:04.820944Z",
"url": "https://files.pythonhosted.org/packages/8a/ae/e70b75643ece917a97a54dac49f89439cf3357fe6f59f6bab71efb960afb/fabric_fim-1.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-02 18:22:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fabric-testbed",
"github_project": "InformationModel",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fabric_fim"
}