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 175 #46

Merged
merged 24 commits into from
Apr 6, 2022
Merged

Feature/ted 175 #46

merged 24 commits into from
Apr 6, 2022

Conversation

kaleanych
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Apr 1, 2022

Codecov Report

Merging #46 (48b8a45) into main (78a6092) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   98.60%   98.71%   +0.10%     
==========================================
  Files          42       43       +1     
  Lines        1576     1630      +54     
==========================================
+ Hits         1554     1609      +55     
+ Misses         22       21       -1     
Impacted Files Coverage Δ
.../data_manager/adapters/mapping_suite_repository.py 99.31% <100.00%> (+<0.01%) ⬆️
ted_sws/notice_transformer/adapters/rml_mapper.py 100.00% <100.00%> (ø)
...ormer/entrypoints/cmd_mapping_suite_transformer.py 100.00% <100.00%> (ø)
...rmaliser/entrypoints/generate_mapping_resources.py 100.00% <0.00%> (+5.88%) ⬆️

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 78a6092...48b8a45. Read the comment docs.

@kaleanych
Copy link
Contributor Author

kaleanych commented Apr 1, 2022

SETUP:

  1. pip install https://github.com/meaningfy-ws/ted-sws/archive/main.zip
  2. Usage:
    # transformer --help

@kaleanych kaleanych requested review from costezki and removed request for Dragos0000 and costezki April 1, 2022 12:36
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!

Please see the comments below.

@@ -0,0 +1,3 @@
[report]
exclude_lines =
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting, what else could be added to such a file and what would be useful to us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines are not interpreted by by python when running coverage.
Will help to not be frustrated by (<100%) coverage for command line tools

sys.path = list(set(sys.path))
import os

os.chdir("/opt/airflow/")
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this "hack" permanent? Or can we have something done at the "system" level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understood from Stefan, this is a requirement for DAG to run smooth in airflow environment

@@ -70,6 +70,7 @@ def open_local(paths, mode="r", encoding="utf8"):
entry_points={
"console_scripts": [
# "rdfpipe = rdflib.tools.rdfpipe:main", # inspired form rdflib, replace as needed
"transformer = ted_sws.notice_transformer.entrypoints.cmd_mapping_suite_transformer:main"
Copy link
Collaborator

Choose a reason for hiding this comment

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

very well

import os
import sys

module_path = os.path.dirname(os.path.realpath(__file__)) + '/../../../'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks very dangerous and easy to break.
One shall rather use pkg_resources following the example from metadata_normaliser.

try:
    import importlib.resources as pkg_resources
except ImportError:
    # Try backported to PY<37 `importlib_resources`.
    import importlib_resources as pkg_resources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added to be run without python package manager (to get used faster by semantic team). It will be updated, so it runs as a package command

# make install && make local-dotenv-file
(.env file must already be created)
4) Go to ted-sws-artefacts directory.
5) Create a symlink in ted-sws-artefacts project's root directory:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Certainly, the symlink is not the right way to do this.
Rather, this shall be facilitated through pip install of the ted-sws repository configured through setup.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already answered above: this was implemented to get faster to semantic team (It will be updated so it can be used as Python package)

help='MappingSuite ID to be processed (leave empty to process all Mapping Suites).')
@click.option('--opt-mappings-path', default=DEFAULT_MAPPINGS_PATH)
@click.option('--opt-output-path', default=DEFAULT_OUTPUT_PATH)
def transform_notice(mapping_suite_id, opt_mapping_suite_id, opt_mappings_path, opt_output_path):
Copy link
Collaborator

Choose a reason for hiding this comment

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

fair enough!


@pytest.fixture
def cmd_transformer_path() -> str:
return "../../../../ted_sws/notice_transformer/entrypoints/cmd_mapping_suite_transformer.py"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This approach is suboptimal, and using a relative path like that is not safe at all.
It is much more elegant, easy and safe if one employs the testing facilities offered by the Click library. See the testing section in the documentation.



def test_cmd_transformer(fake_mapping_suite_id, fake_repository_path):
response = cmdRunner.invoke(transform_notice, [fake_mapping_suite_id, "--opt-mappings-path", fake_repository_path])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you found the clirunner in the Click documentation :))

__process_output_dir(fake_repository_path, fake_mapping_suite_id)


def __test_cmd_transformer_from_cli(fake_repository_path, cmd_transformer_path, fake_mapping_suite_id):
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this test commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed it. it was for locally testing the command as it runs as a cli script

@kaleanych kaleanych requested review from costezki and removed request for CaptainOfHacks April 6, 2022 11:00
@kaleanych kaleanych dismissed costezki’s stale review April 6, 2022 11:09

already fixed

@kaleanych kaleanych merged commit 106a270 into main Apr 6, 2022
@costezki costezki deleted the feature/ted-175 branch April 7, 2022 18:32
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.

3 participants