-
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 175 #46
Feature/ted 175 #46
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
SETUP:
|
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!
Please see the comments below.
@@ -0,0 +1,3 @@ | |||
[report] | |||
exclude_lines = |
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.
interesting, what else could be added to such a file and what would be useful to us?
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.
These lines are not interpreted by by python when running coverage.
Will help to not be frustrated by (<100%) coverage for command line tools
dags/notice_transformer_dag.py
Outdated
sys.path = list(set(sys.path)) | ||
import os | ||
|
||
os.chdir("/opt/airflow/") |
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.
is this "hack" permanent? Or can we have something done at the "system" level?
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.
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" |
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.
very well
import os | ||
import sys | ||
|
||
module_path = os.path.dirname(os.path.realpath(__file__)) + '/../../../' |
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 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
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 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: |
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.
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
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.
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): |
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.
fair enough!
|
||
@pytest.fixture | ||
def cmd_transformer_path() -> str: | ||
return "../../../../ted_sws/notice_transformer/entrypoints/cmd_mapping_suite_transformer.py" |
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 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]) |
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 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): |
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.
why is this test commented out?
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.
removed it. it was for locally testing the command as it runs as a cli script
No description provided.