Skip to content

Commit dbdb5cb

Browse files
committed
upgraded libraries and tests fix WIP (pydantic 2)
1 parent 3a2bd74 commit dbdb5cb

18 files changed

Lines changed: 228 additions & 158 deletions

File tree

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[project]
2+
name = "ted-rdf-conversion-pipeline"
3+
version = "0.1.0"
4+
requires-python = ">=3.9"
5+
dependencies = [
6+
"agraph-python>=104.2.0",
7+
"allure-pytest-bdd>=2.14.0",
8+
"apache-airflow==2.10.5",
9+
"certifi==2025.1.31",
10+
"colorama==0.4.6",
11+
"coverage>=7.8.0",
12+
"decorator==5.1.1",
13+
"deepdiff>=8.4.2",
14+
"elasticsearch-dbapi>=0.2.11",
15+
"fastapi>=0.115.12",
16+
"hvac>=2.3.0",
17+
"jinja2~=3.1.5",
18+
"json2html>=1.3.0",
19+
"minio>=7.2.15",
20+
"mongomock>=4.3.0",
21+
"openpyxl>=3.1.5",
22+
"ordered-set~=4.1.0",
23+
"pandas==2.1.4",
24+
"paramiko>=3.5.1",
25+
"pendulum==3.0.0",
26+
"pycurl>=7.45.6",
27+
"pydantic==2.10.6",
28+
"pymongo>=4.12.0",
29+
"pyshacl>=0.30.1",
30+
"pytest>=8.3.5",
31+
"pytest-bdd>=8.1.0",
32+
"pytest-cov>=6.1.1",
33+
"pytest-subtests>=0.14.1",
34+
"python-dateutil==2.9.0.post0",
35+
"python-dotenv>=1.1.0",
36+
"rdflib>=7.1.4",
37+
"requests==2.32.3",
38+
"saxonche>=12.5.0",
39+
"semantic-version>=2.10.0",
40+
"shortuuid>=1.0.13",
41+
"sparqlwrapper>=2.0.0",
42+
"tox>=4.25.0",
43+
"tox-pytest-summary>=0.1.2",
44+
"urllib3==2.3.0",
45+
"uvicorn[standard]>=0.34.0",
46+
]

requirements.dev.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Development libraries
2-
coverage~=6.3.1
3-
pytest~=7.0.0
4-
pytest-bdd~=5.0.0
5-
pytest-cov~=3.0.0
6-
pytest-subtests~=0.6.0
7-
tox~=3.24.5
8-
tox-pytest-summary~=0.1.2
9-
mongomock==4.1.2
10-
uvicorn[standard]==0.24.0
11-
allure-pytest-bdd==2.10.0
12-
pycurl~=7.45.2
2+
coverage>=7.8.0
3+
pytest>=8.3.5
4+
pytest-bdd>=8.1.0
5+
pytest-cov>=6.1.1
6+
pytest-subtests>=0.14.1
7+
tox>=4.25.0
8+
tox-pytest-summary>=0.1.2
9+
mongomock>=4.3.0
10+
uvicorn[standard]>=0.34.0
11+
allure-pytest-bdd>=2.14.0
12+
pycurl>=7.45.6

requirements.txt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# Project dependecies
2-
pydantic~=1.9.0
3-
requests~=2.28.2
4-
deepdiff~=5.7.0
5-
jinja2~=3.1.2
6-
python-dotenv~=0.21.0
7-
pymongo~=4.0.1
8-
apache-airflow~=2.5.1
9-
hvac==0.11.2
10-
SPARQLWrapper==1.8.5
11-
pandas==1.5.2
12-
openpyxl==3.0.9
13-
colorama~=0.4
14-
fastapi~=0.77
15-
python-dateutil~=2.8.2
16-
rdflib~=6.1.1
17-
pyshacl~=0.19.0
18-
agraph-python==101.0.10
19-
decorator~=5.1.1
20-
urllib3[secure]
21-
semantic-version==2.10.0
22-
paramiko~=3.0.0
23-
ordered-set~=4.0.2
24-
json2html~=1.3.0
25-
minio~=7.1.1
26-
certifi~=2022.12.7
27-
shortuuid~=1.0.11
28-
pendulum~=2.1.2
29-
saxonche~=12.4
30-
elasticsearch-dbapi==0.2.11
1+
# Project dependencies
2+
pydantic==2.10.6
3+
requests==2.32.3
4+
deepdiff>=8.4.2
5+
jinja2~=3.1.5
6+
python-dotenv>=1.1.0
7+
pymongo>=4.12.0
8+
apache-airflow==2.10.5
9+
hvac>=2.3.0
10+
sparqlwrapper>=2.0.0
11+
pandas==2.1.4
12+
openpyxl>=3.1.5
13+
colorama==0.4.6
14+
fastapi>=0.115.12
15+
python-dateutil==2.9.0.post0
16+
rdflib>=7.1.4
17+
pyshacl>=0.30.1
18+
agraph-python>=104.2.0
19+
decorator==5.1.1
20+
urllib3==2.3.0
21+
semantic-version>=2.10.0
22+
paramiko>=3.5.1
23+
ordered-set~=4.1.0
24+
json2html>=1.3.0
25+
minio>=7.2.15
26+
certifi==2025.1.31
27+
shortuuid>=1.0.13
28+
pendulum==3.0.0
29+
saxonche>=12.5.0
30+
elasticsearch-dbapi>=0.2.11

ted_sws/core/model/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ class PropertyBaseModel(BaseModel):
2222
https://github.com/samuelcolvin/pydantic/issues/935
2323
is solved
2424
"""
25-
26-
@classmethod
27-
def get_properties(cls):
28-
return [
29-
prop for prop in dir(cls)
30-
if isinstance(getattr(cls, prop), property) and prop not in ("__values__", "fields")
31-
]
32-
33-
def dict(self, *args, **kwargs) -> 'DictStrAny':
34-
self.__dict__.update({prop: getattr(self, prop) for prop in self.get_properties()})
35-
36-
return super().dict(*args, **kwargs)
25+
#TODO : remove this code, because this implementation is not necessary anymore in pydantic 2
26+
# @classmethod
27+
# def get_properties(cls):
28+
# return [
29+
# prop for prop in dir(cls)
30+
# if isinstance(getattr(cls, prop), property) and prop not in ("__values__", "fields")
31+
# ]
32+
#TODO : remove this code, because this implementation is not necessary anymore in pydantic 2
33+
# def dict(self, *args, **kwargs) -> 'DictStrAny':
34+
# self.__dict__.update({prop: getattr(self, prop) for prop in self.get_properties()})
35+
#
36+
# return super().dict(*args, **kwargs)
3737

3838
def __eq__(self, other) -> bool:
3939
if not isinstance(other, self.__class__) or not other:
4040
return False
4141
# raise ValueError(f"Must compare objects of the same class {self.__class__}")
42-
difference = DeepDiff(self.dict(), other.dict())
42+
difference = DeepDiff(self.model_dump(), other.model_dump())
4343
return not difference
4444

4545
def __ne__(self, other):

ted_sws/core/model/manifestation.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class XPATHCoverageSummaryResult(PropertyBaseModel):
6868

6969

7070
class XPATHCoverageSummaryReport(PropertyBaseModel):
71-
mapping_suite_identifier: Optional[str]
71+
mapping_suite_identifier: Optional[str] = None
7272
validation_result: Optional[XPATHCoverageSummaryResult] = XPATHCoverageSummaryResult()
7373

7474

@@ -85,8 +85,8 @@ class SPARQLSummaryCountReport(PropertyBaseModel):
8585

8686

8787
class SPARQLSummaryResult(PropertyBaseModel):
88-
test_suite_identifier: Optional[str]
89-
mapping_suite_identifier: Optional[str]
88+
test_suite_identifier: Optional[str] = None
89+
mapping_suite_identifier: Optional[str] = None
9090
aggregate: Optional[SPARQLSummaryCountReport] = SPARQLSummaryCountReport()
9191

9292

@@ -106,8 +106,8 @@ class SHACLSummaryResultSeverityReport(PropertyBaseModel):
106106

107107

108108
class SHACLSummaryResult(PropertyBaseModel):
109-
test_suite_identifier: Optional[str]
110-
mapping_suite_identifier: Optional[str]
109+
test_suite_identifier: Optional[str] = None
110+
mapping_suite_identifier: Optional[str] = None
111111
result_severity: Optional[SHACLSummaryResultSeverityReport] = SHACLSummaryResultSeverityReport()
112112

113113

@@ -140,11 +140,11 @@ class XPATHCoverageValidationAssertion(PropertyBaseModel):
140140
"""
141141
142142
"""
143-
form_field: Optional[str]
144-
xpath: Optional[str]
145-
count: Optional[int]
146-
notice_hit: Optional[Dict[str, int]]
147-
query_result: Optional[bool]
143+
form_field: Optional[str] = None
144+
xpath: Optional[str] = None
145+
count: Optional[int] = None
146+
notice_hit: Optional[Dict[str, int]] = None
147+
query_result: Optional[bool] = None
148148

149149

150150
class XPATHCoverageValidationResultBase(PropertyBaseModel):
@@ -159,22 +159,22 @@ class XPATHCoverageValidationResult(XPATHCoverageValidationResultBase):
159159
"""
160160
XPATHCoverageValidationResult for Notice
161161
"""
162-
notices: Optional[List[ReportNoticeData]]
162+
notices: Optional[List[ReportNoticeData]] = None
163163

164164

165165
class XPATHCoverageValidationReport(XMLValidationManifestation):
166166
"""
167167
This is the model structure for Notice(s) XPATHs Coverage Report
168168
"""
169169

170-
validation_result: Optional[XPATHCoverageValidationResult]
170+
validation_result: Optional[XPATHCoverageValidationResult] = None
171171

172172

173173
class XMLManifestation(Manifestation):
174174
"""
175175
Original XML Notice manifestation as published on the TED website.
176176
"""
177-
xpath_coverage_validation: XPATHCoverageValidationReport = None
177+
xpath_coverage_validation: Optional[XPATHCoverageValidationReport] = None
178178

179179
def add_validation(self, validation: Union[XPATHCoverageValidationReport]):
180180
if type(validation) == XPATHCoverageValidationReport:
@@ -200,15 +200,15 @@ class RDFValidationManifestation(ValidationManifestation):
200200
201201
"""
202202
mapping_suite_identifier: str
203-
test_suite_identifier: Optional[str]
203+
test_suite_identifier: Optional[str] = None
204204

205205

206206
class SPARQLQuery(PropertyBaseModel):
207207
"""
208208
Stores SPARQL query details
209209
"""
210-
title: Optional[str]
211-
description: Optional[str]
210+
title: Optional[str] = None
211+
description: Optional[str] = None
212212
xpath: Optional[List[str]] = []
213213
query: str
214214

@@ -218,13 +218,13 @@ class SPARQLQueryResult(PropertyBaseModel):
218218
Stores SPARQL query execution result
219219
"""
220220
query: SPARQLQuery
221-
result: Optional[SPARQLQueryRefinedResultType]
222-
query_result: Optional[str]
221+
result: Optional[SPARQLQueryRefinedResultType] = None
222+
query_result: Optional[str] = None
223223
fields_covered: Optional[bool] = True
224224
missing_fields: Optional[List[str]] = []
225-
error: Optional[str]
226-
message: Optional[str]
227-
identifier: Optional[str]
225+
error: Optional[str] = None
226+
message: Optional[str] = None
227+
identifier: Optional[str] = None
228228

229229
class Config:
230230
use_enum_values = True
@@ -242,10 +242,10 @@ class QueriedSHACLShapeValidationResult(PropertyBaseModel):
242242
Queried SHACL Validation Report which contains the following variables
243243
?focusNode ?message ?resultPath ?resultSeverity ?sourceConstraintComponent ?sourceShape ?value
244244
"""
245-
conforms: Optional[str]
246-
results_dict: Optional[dict]
247-
error: Optional[str]
248-
identifier: Optional[str]
245+
conforms: Optional[str] = None
246+
results_dict: Optional[dict] = None
247+
error: Optional[str] = None
248+
identifier: Optional[str] = None
249249

250250

251251
class SHACLTestSuiteValidationReport(RDFValidationManifestation):
@@ -256,7 +256,7 @@ class SHACLTestSuiteValidationReport(RDFValidationManifestation):
256256

257257

258258
class EntityDeduplicationReport(Manifestation):
259-
object_data: Optional[str]
259+
object_data: Optional[str] = None
260260
number_of_duplicates: int
261261
number_of_cets: int
262262
uries: List[str]
@@ -266,10 +266,10 @@ class RDFManifestation(Manifestation):
266266
"""
267267
Transformed manifestation in RDF format
268268
"""
269-
mapping_suite_id = "unknown_mapping_suite_id"
269+
mapping_suite_id: str = "unknown_mapping_suite_id"
270270
shacl_validations: List[SHACLTestSuiteValidationReport] = []
271271
sparql_validations: List[SPARQLTestSuiteValidationReport] = []
272-
deduplication_report: Optional[EntityDeduplicationReport]
272+
deduplication_report: Optional[EntityDeduplicationReport] = None
273273

274274
def validation_exists(self, validation, validations):
275275
"""

0 commit comments

Comments
 (0)