-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/ted 24 #35
Feature/ted 24 #35
Conversation
Codecov Report
@@ Coverage Diff @@
## main #35 +/- ##
==========================================
- Coverage 97.58% 97.28% -0.31%
==========================================
Files 33 29 -4
Lines 1078 956 -122
==========================================
- Hits 1052 930 -122
Misses 26 26
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Good approach and documentation.
Some modifications would take this code near to perfection.
""" | ||
|
||
_collection_name = "mapping_suite_collection" | ||
_database_name = "mapping_suite_db" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The database name should be moved into the project config. All repositories shall be in the SAME database.
_collection_name = "mapping_suite_collection" | ||
_database_name = "mapping_suite_db" | ||
|
||
def __init__(self, mongodb_client: MongoClient, database_name: str = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
database name shall not be injected but retrieved from config consistent at the project level.
""" | ||
mapping_suite_dict = mapping_suite.dict() | ||
mapping_suite_dict["_id"] = mapping_suite_dict["identifier"] | ||
self.collection.update_one({'_id': mapping_suite_dict["_id"]}, {"$set": mapping_suite_dict}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this fails if the _id does not exist in the DB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will not drop, it will not update anything, it will not insert anything
This method allows all records to be retrieved from the repository. | ||
:return: list of MappingSuites | ||
""" | ||
for result_dict in self.collection.find(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope .find()
returns a generator and not a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 👍
Returns an instance of
:class:~pymongo.cursor.Cursor
corresponding to this query.
:param package_path: | ||
:return: | ||
""" | ||
package_metadata_path = package_path / "metadata.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file name shall be a constant
""" | ||
with tempfile.TemporaryDirectory() as d: | ||
package_path = pathlib.Path(d) / self.mapping_suite.identifier | ||
self._inject_in_package_notice_xml_manifestation(package_path=package_path, notice=notice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THIS inject, btw, is not only an inject. The name is misleading. Rename it please.
|
||
@pytest.fixture | ||
def rml_test_package_path() -> pathlib.Path: | ||
return TEST_DATA_PATH / "notice_transformer" / "test_package" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new one shall follow.
... | ||
*.xml | ||
:param package_path: path to package | ||
:return: a string containing the result of the transformation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm, should the result be a path to a file? To be on the safe side.
def test_rml_mapper(rml_test_package_path): | ||
rml_mapper = RMLMapper(rml_mapper_path=config.RML_MAPPER_PATH) | ||
rdf_result = rml_mapper.execute(package_path=rml_test_package_path) | ||
assert rdf_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this result?
how do you know it is good?
I mean could there be none, but still the test to pass? Such as " an error from crashing RML mapper?
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the CLASS above, we should provide a function that takes a (notice_id, mapping_suite and a rml_mapper) as parameters and executes the transformation & the IO of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such a function is still useful
from ted_sws.domain.model.transform import MappingSuite, FileResource, TransformationRuleSet, SHACLTestSuite, \ | ||
SPARQLTestSuite, MetadataConstraints | ||
|
||
METADATA_FILE_NAME = "metadata.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More reliable constant usage.
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such a function is still useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good
No description provided.