Skip to content
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

Merged
merged 35 commits into from
Mar 28, 2022
Merged

Feature/ted 24 #35

merged 35 commits into from
Mar 28, 2022

Conversation

CaptainOfHacks
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Mar 20, 2022

Codecov Report

Merging #35 (8572ea4) into main (5b84964) will decrease coverage by 0.30%.
The diff coverage is 97.23%.

❗ Current head 8572ea4 differs from pull request most recent head 9ef3999. Consider uploading reports for the commit 9ef3999 to get more accurate results

@@            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              
Impacted Files Coverage Δ
ted_sws/notice_transformer/adapters/rml_mapper.py 69.23% <69.23%> (ø)
ted_sws/__init__.py 91.66% <80.00%> (+4.56%) ⬆️
.../data_manager/adapters/mapping_suite_repository.py 99.25% <99.25%> (ø)
ted_sws/domain/adapters/repository_abc.py 100.00% <100.00%> (ø)
ted_sws/domain/model/transform.py 100.00% <100.00%> (+100.00%) ⬆️
.../notice_transformer/services/notice_transformer.py 100.00% <100.00%> (ø)
ted_sws/notice_packager/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
...etadata_normaliser/services/metadata_normalizer.py 76.92% <0.00%> (-23.08%) ⬇️
ted_sws/domain/model/metadata.py 100.00% <0.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6ab400...9ef3999. Read the comment docs.

Copy link
Collaborator

@costezki costezki left a 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"
Copy link
Collaborator

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):
Copy link
Collaborator

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})
Copy link
Collaborator

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

Copy link
Collaborator Author

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():
Copy link
Collaborator

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.

Copy link
Collaborator Author

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"
Copy link
Collaborator

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)
Copy link
Collaborator

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"
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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?





Copy link
Collaborator

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.

Copy link
Collaborator

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More reliable constant usage.





Copy link
Collaborator

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

Copy link
Collaborator

@costezki costezki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

@costezki costezki merged commit bfd665d into main Mar 28, 2022
@costezki costezki deleted the feature/TED-24 branch March 28, 2022 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants