|
1 | 1 | The Aspect Model Loader as part of the Python SDK provided by the [*Eclipse Semantic Modeling Framework*]( |
2 | 2 | https://projects.eclipse.org/projects/dt.esmf). |
3 | 3 |
|
4 | | -<!-- TOC --> |
5 | | -* [An Aspect of the Meta Model](#an-aspect-of-the-meta-model) |
6 | | - * [Set Up SAMM Aspect Meta Model](#set-up-samm-aspect-meta-model) |
7 | | - * [Install poetry](#install-poetry) |
8 | | - * [Install project dependencies](#install-project-dependencies) |
9 | | - * [Download SAMM files](#download-samm-files) |
10 | | - * [Download SAMM release](#download-samm-release) |
11 | | - * [Download SAMM branch](#download-samm-branch) |
12 | | - * [Input data handler usage](#input-data-handler-usage) |
13 | | - * [Aspect Meta Model Loader usage](#aspect-meta-model-loader-usage) |
14 | | - * [Samm Units](#samm-units) |
15 | | - * [SAMM CLI wrapper class](#samm-cli-wrapper-class) |
16 | | -* [Scripts](#scripts) |
17 | | -* [Automation Tasks](#automation-tasks) |
18 | | - * [tox](#tox) |
19 | | - * [GitHub actions](#github-actions) |
20 | | - * [Check New Pull Request](#check-new-pull-request) |
21 | | - * [Build release](#build-release) |
22 | | -<!-- TOC --> |
23 | | - |
24 | 4 | # An Aspect of the Meta Model |
25 | 5 |
|
26 | 6 | The `esmf-aspect-model-loader` package provides the Python implementation for the SAMM Aspect Meta Model, or SAMM. |
27 | 7 | Each Meta Model element and each Characteristic class is represented by an interface with a corresponding |
28 | 8 | implementation. |
29 | 9 |
|
| 10 | +## Documentation |
| 11 | + |
| 12 | +* Check the [developer documentation](https://eclipse-esmf.github.io) |
| 13 | +* Check the SAMM [specification](https://eclipse-esmf.github.io/samm-specification/snapshot/index.html) |
| 14 | +* Having issues with the ESMF SDK Python Aspect Model Loader? Open a [GitHub issue](https://github.com/eclipse-esmf/esmf-sdk-py-aspect-model-loader/issues). |
| 15 | + |
30 | 16 | ## Set Up SAMM Aspect Meta Model |
31 | 17 |
|
32 | 18 | Before getting started to use the `esmf-aspect-model-loader` library you need to apply some set up actions: |
@@ -85,55 +71,42 @@ poetry run download-samm-branch |
85 | 71 | ``` |
86 | 72 | Link to all branches: [SAMM Releases](https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/branches) |
87 | 73 |
|
88 | | -## Input data handler usage |
89 | | - |
90 | | -The InputHandler is a general-purpose class designed for loading input data into an RDF graph. |
91 | | -It easily accommodates different input sources such as local files (.ttl) or direct data strings containing |
92 | | -RDF formatted data. |
| 74 | +## SAMMGraph usage |
93 | 75 |
|
| 76 | +SAMMGraph is a class that allows you to load and interact with the Semantic Data Aspect Meta Model graph. |
| 77 | +Below is an example of how to use SAMMGraph in your Python code: |
94 | 78 | ```python |
95 | | -from esmf_aspect_meta_model_python.resolver.handler import InputHandler |
| 79 | +from esmf_aspect_meta_model_python import SAMMGraph |
96 | 80 |
|
97 | | -# Instantiating the Handler |
98 | | -# The InputHandler requires a path or data string upon instantiation, which defines the source of RDF data |
99 | | -# local file |
100 | | -model_path = "path/to/local/file/AspectName.ttl" |
101 | | -handler = InputHandler(model_path) |
102 | | -graph, aspect_urn = handler.get_rdf_graph() |
| 81 | +# Define the path to your Turtle file |
| 82 | +model_path = "absolute/path/to/turtle.ttl" |
103 | 83 |
|
104 | | -# returns a tuple containing the RDF graph and the aspect URN derived from the provided data source |
105 | | -``` |
| 84 | +# Create an instance of SAMMGraph |
| 85 | +samm_graph = SAMMGraph() |
106 | 86 |
|
107 | | -```python |
108 | | -from esmf_aspect_meta_model_python.resolver.handler import InputHandler |
| 87 | +# Parse the Turtle file to load the graph |
| 88 | +samm_graph.parse(model_path) |
109 | 89 |
|
110 | | -# Alternatively, if you have RDF data in a string format, you can directly pass it as follows: |
111 | | -rdf_data_string = "your RDF data string here" |
112 | | -handler = InputHandler(rdf_data_string) |
113 | | -graph, aspect_urn = handler.get_rdf_graph() |
| 90 | +# Load the aspect model from the graph |
| 91 | +aspect = samm_graph.load_aspect_model() |
114 | 92 | ``` |
115 | 93 |
|
116 | | -## Aspect Meta Model Loader usage |
117 | | - |
118 | | -An Aspect of the Meta Model can be loaded as follows: |
| 94 | +The `load_model_elements` method in the SAMMGraph class creates Python objects to represent all nodes from the Aspect |
| 95 | +model graph. It retrieves all SAMM elements from the RDF graph and converts them into structured Python objects. |
119 | 96 | ```python |
120 | | -from esmf_aspect_meta_model_python import AspectLoader |
121 | | -from esmf_aspect_meta_model_python.resolver.handler import InputHandler |
| 97 | +from esmf_aspect_meta_model_python import SAMMGraph |
122 | 98 |
|
| 99 | +# Define the path to your Turtle file |
123 | 100 | model_path = "absolute/path/to/turtle.ttl" |
124 | | -handler = InputHandler(model_path) |
125 | | -graph, aspect_urn = handler.get_rdf_graph() |
126 | 101 |
|
127 | | -loader = AspectLoader() |
128 | | -model_elements = loader.load_aspect_model(graph, aspect_urn) |
129 | | -aspect = model_elements[0] |
| 102 | +# Create an instance of SAMMGraph |
| 103 | +samm_graph = SAMMGraph() |
130 | 104 |
|
131 | | -# or you can provide an Aspect URN |
| 105 | +# Parse the Turtle file to load the graph |
| 106 | +samm_graph.parse(model_path) |
132 | 107 |
|
133 | | -loader = AspectLoader() |
134 | | -aspect_urn = "urn:samm:org.eclipse.esmf.samm:aspect.model:0.0.1#AspectName" |
135 | | -model_elements = loader.load_aspect_model("absolute/path/to/turtle.ttl", aspect_urn) |
136 | | -aspect = model_elements[0] |
| 108 | +# Load all model elements from the graph |
| 109 | +model_elements = samm_graph.load_model_elements() |
137 | 110 | ``` |
138 | 111 |
|
139 | 112 | ## Samm Units |
@@ -200,7 +173,7 @@ Provided scripts: |
200 | 173 | All scripts run like a poetry command. The poetry is available from the folder where [pyproject.toml](pyproject.toml) |
201 | 174 | is located. |
202 | 175 |
|
203 | | -# Automation Tasks |
| 176 | +# Tests running |
204 | 177 | ## tox |
205 | 178 |
|
206 | 179 | `tox` is used for the tests automation purpose. There are two environments with different purposes and tests can |
|
0 commit comments