Skip to content

Commit 372ee55

Browse files
committed
fix/minor_fixes
- Update the BM ontology both in the file and README.md - Changed the way BM appear in the docs from swagger, but not the endpoint address generation - Added description information for the BM endpoint by getting the rdfs:comment from the ontology BM concept - Fix with pathing issues in Linux/Mac in the UNQLITEConnection.py
1 parent da0636e commit 372ee55

8 files changed

Lines changed: 26 additions & 41 deletions

File tree

CHANGELOG.txt

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
11
Change Log
22
===============
3-
VERSION="0.0.17"
4-
LAST_UPDATE="18/11/2025"
3+
VERSION="0.0.18"
4+
LAST_UPDATE="24/11/2025"
55
------------------
6-
- Readme updates, added a full example of using the package.
7-
- Fixed the required database driver packages in the setup file.
8-
- Improved the query handling for unqlite databases, to maintain a query style compatible with mongodb databases:
9-
For instance, queries like the following are now supported in unqlite as well.
10-
- collection.find({field: 1, id: 0}), will return documents like:
11-
[
12-
{field_name: <value>},
13-
{field_name: <value>},
14-
...
15-
]
16-
- collection.find({field: 1}), will return documents like:
17-
[
18-
{<doc_id>: <value>},
19-
{<doc_id>: <value>},
20-
...
21-
]
22-
This provides a more consistent experience across different noSQL databases into handle projections similar to mongoDB.
23-
- Corrections in the Ontology module prefixes and in the sparkQL queries to match the new ontology prefixes.
24-
- Changed the default named args from metadata and parameters from "FromMetadata" and "FromParameters" to "metadata" and "params" respectively.
25-
- Changed the data object sent to the BM function from a dictionary to a simple object with attributes, now data inside a BM is accessible by using:
26-
data.metadata instead of data['metadata']
27-
data.params instead of data['params']
6+
- Update the BM ontology both in the file and README.md
7+
- Added description information for the BM endpoint by getting the rdfs:comment from the ontology BM concept
8+
- Fix with pathing issues in Linux/Mac in the UNQLITEConnection.py
289
------------------

OntologyToAPI/core/APIGenerator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def generate_api_routes(self) -> FastAPI:
9393
path=f"/{name[0]}/{name[1]}/run",
9494
endpoint=handler,
9595
methods=["POST"],
96-
name=f"This endpoint executes the {bm_dt.name} business model, and retrieve it`s results.",
97-
tags=[f"Business Model ({bm_dt.name})"],
96+
name=bm_dt.desc,
97+
tags=[f"Business Model ({name[0]})"],
9898
)
9999
logging.info(f'Added {bm_name} running API route...')
100100
return self.app

OntologyToAPI/core/Connectors/Stateless/UNQLITEConnection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ def __init__(self, args: Dict[str, str]):
1515
if parsed.scheme not in ("unqlite+asyncio",):
1616
raise ValueError(f"Unsupported scheme: {parsed.scheme}. Use 'unqlite+asyncio'.")
1717

18-
path = unquote(parsed.netloc or "")
18+
path = raw.split(":")[-1][2:]
1919
if not path:
2020
raise ValueError(f"Empty database path in connection string.")
2121
if path == "/:memory:":
2222
db_path = ":memory:"
2323
else:
2424
db_path = path
25-
2625
try:
2726
self._db = UnQLite(db_path)
2827
except Exception as e:

OntologyToAPI/core/DTO/BusinessModel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class BusinessModel(BaseModel):
88
name: str
9+
desc: str
910
requiresMetadata: Optional[List[Metadata]]
1011
requiresParameters: Optional[dict]
1112
externalCode: Optional[ExternalCode]

OntologyToAPI/core/Ontology.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ def serialize_business_models(self):
7474
if not func_path.exists() or not func_path.is_file():
7575
raise FileNotFoundError(f'The external code file for the {bm_name} business model could not be found at "{func_path}"')
7676
BMs[bm_name] = BusinessModel(name=bm_name.split(":")[-1],
77-
requiresMetadata=required_metadata,
78-
requiresParameters={str(l): t for _, l, t in required_parameters},
79-
externalCode=ExternalCode(
80-
pythonFile=str(func_path),
81-
function=str(ec[4]),
82-
requiresLib=str(ec[3]).split(",")))
77+
desc=str(ec[6]) if ec[6] is not None else f"Business Model for the {bm_name} business model",
78+
requiresMetadata=required_metadata,
79+
requiresParameters={str(l): t for _, l, t in required_parameters},
80+
externalCode=ExternalCode(
81+
pythonFile=str(func_path),
82+
function=str(ec[4]),
83+
requiresLib=str(ec[3]).split(",")))
8384
logging.info(f'{bm_name} BUSINESS MODEL serialized successfully;')
8485
self.bms = BMs

OntologyToAPI/core/Queries.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@
4141
FILTER (?bm = <"""
4242

4343
GET_EXTERNAL_CODE_FOR_BM_QUERY = """
44-
SELECT ?bm ?ec ?pf ?rl ?hf
44+
SELECT ?bm ?ec ?pf ?rl ?hf ?bmt ?desc
4545
WHERE {
4646
?bm <http://www.cedri.com/OntologyToAPI-BusinessModel#hasExternalCode> ?ec .
4747
?ec <http://www.cedri.com/OntologyToAPI-ExternalCode#hasPythonFile> ?pf .
4848
?ec <http://www.cedri.com/OntologyToAPI-ExternalCode#requiresLib> ?rl .
4949
?ec <http://www.cedri.com/OntologyToAPI-ExternalCode#hasFunction> ?hf .
50+
?bm rdf:type ?bmt .
51+
?bmt rdfs:comment ?desc .
52+
FILTER(?bmt != owl:NamedIndividual)
5053
}
5154
"""

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ex:Relative_Humidity_MD rdf:type owl:NamedIndividual ,
103103
104104
# Class Definitions
105105
106-
ex:CelsiusToFahrenheit rdf:type owl:Class ;
106+
ex:CelsiusToFahrenheitBM rdf:type owl:Class ;
107107
rdfs:subClassOf bm:BusinessModel ;
108108
rdfs:comment "This business model allows the convertion from Celsius to Fahrenheit." .
109109
@@ -120,8 +120,8 @@ ex:Temperature_P rdf:type owl:NamedIndividual ,
120120
bm:hasParameterLabel "temperature_c" ;
121121
bm:hasParameterType "float" .
122122
123-
ex:CelsiusToFahrenheit_I rdf:type owl:NamedIndividual ,
124-
ex:CelsiusToFahrenheit ;
123+
ex:CelsiusToFahrenheit rdf:type owl:NamedIndividual ,
124+
ex:CelsiusToFahrenheitBM ;
125125
bm:requiresMetadata ex:Temperature_C_MD;
126126
bm:hasExternalCode ex:CelsiusToFahrenheit.py ;
127127
bm:hasParameter ex:Temperature_P .

example/bm_example.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Class Definitions
1313

14-
ex:CelsiusToFahrenheit rdf:type owl:Class ;
14+
ex:CelsiusToFahrenheitBM rdf:type owl:Class ;
1515
rdfs:subClassOf bm:BusinessModel ;
1616
rdfs:comment "This business model allows the convertion from Celsius to Fahrenheit." .
1717

@@ -28,8 +28,8 @@ ex:Temperature_P rdf:type owl:NamedIndividual ,
2828
bm:hasParameterLabel "temperature_c" ;
2929
bm:hasParameterType "float" .
3030

31-
ex:CelsiusToFahrenheit_I rdf:type owl:NamedIndividual ,
32-
ex:CelsiusToFahrenheit ;
31+
ex:CelsiusToFahrenheit rdf:type owl:NamedIndividual ,
32+
ex:CelsiusToFahrenheitBM ;
3333
bm:requiresMetadata ex:Temperature_C_MD;
3434
bm:hasExternalCode ex:CelsiusToFahrenheit.py ;
3535
bm:hasParameter ex:Temperature_P .

0 commit comments

Comments
 (0)