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

added three tests to cover changes made by the pull request #1361 #1645

Merged
merged 10 commits into from
Jan 6, 2022

Conversation

GreenfishK
Copy link

@GreenfishK GreenfishK commented Jan 3, 2022

Fixes

SUBSTR: The 'length' parameter was not included. Now it is
SUBSTR: Did not work with group variables. E.g. when ?x was used in group by and in substr, ?x would appear as __aggr_1 in Builtin_substr in the query algebra tree. Group variables in built in functions are now replaced properly
CONCAT: Nested expressions with group variables in CONCAT are now translated properly
function header: The parameter query_algebra is not optional anymore

Changes

algebra.py: copied the code from algebra in PR #1361 and made another correction in the Builtin_SUBSTR section so that nested arguments are resolved correctly.
test_functions__functions_on_srings.txt: one line was added in the select clause to test the substr function with the position and length parameter.
test_graph_patterns__group_and_substr.txt: Added a group variable (from the group by clause) in the substr function of the select clause to test whether such queries get properly translated.
test_graph_patterns__group_and_nested_concat.txt: added a nested concat expression with a group variable. This test fails with a TypeError.

test_functions__functions_on_srings.txt: one line was added in the select clause to test the substr function with the position and length parameter.
test_graph_patterns__group_and_substr.txt: Added a group variable (from the group by clause) in the substr function of the select clause to test whether such queries get properly translated.
test_graph_patterns__group_and_nested_concat.txt: added a nested concat expression with a group variable. This test fails with a TypeError.
@GreenfishK
Copy link
Author

@aucampia @nicholascar How should we proceed here? Should I make the bugfix in this PR or make a separate pull request for the bug fix?

@aucampia
Copy link
Member

aucampia commented Jan 3, 2022

How should we proceed here? Should I make the bugfix in this PR or make a separate pull request for the bug fix?

@GreenfishK I think it is best to combine this with the fix if you have it, which as far as I understand in this case you do.

Sometimes we will merge failing tests, but then they must be marked with xfail (e.g. here) so that they don't block the CI system, but generally this would only be if we don't have a fix at hand. xfail test make it easier to illustrate the problem to someone else and then later on do a handover, and it is also good for new contributors to get into things as they have less to learn. Sufficently annotated xfail markers (i.e. ones with raises) also make it possible to see if something breaks further (i.e. if a different exception is raised), and it also makes it possible to see if something was inadvertently fixed as they still run and if they do pass they get reported as xpass (unexpected pass)

@aucampia
Copy link
Member

aucampia commented Jan 3, 2022

Change looks good though, but to summarise, it would be best to combine it with #1361 by either adding it to that PR (probably simplest), or adding the changes from that PR to this and updating the description here.

@GreenfishK
Copy link
Author

@aucampia There seem to be still some issues with the translateAlgebra function and I am going nuts while trying to figure out how to activate the logger in order to debug it. I could not find any pyproject.toml or pytest.ini file where I could set the level to DEBUG. I also tried running pytest via CLI and with some log options activated but it did not work. Do you have any suggestions?
Thanks!

@GreenfishK
Copy link
Author

@aucampia There seem to be still some issues with the translateAlgebra function and I am going nuts while trying to figure out how to activate the logger in order to debug it. I could not find any pyproject.toml or pytest.ini file where I could set the level to DEBUG. I also tried running pytest via CLI and with some log options activated but it did not work. Do you have any suggestions? Thanks!

Oh, nevermind. I figured it out. I just put in tox.ini. Thanks anyway

test_graph_patterns__group_and_substr.txt: formatted select clause
test_translate_algebra.py: added logging for debugging
tox.ini: configured logging for pytests and set the level to DEBUG for debugging
@aucampia
Copy link
Member

aucampia commented Jan 3, 2022

depends on how you run it, I run on my computer like this:

## setup venv
\rm -rv .venv
python3.8 -m venv .venv
.venv/bin/python3 -m pip install -r requirements.txt -r requirements.dev.txt -r requirements.dev-extra.txt

## run test with debug logging (--log-level DEBUG) and report for all tests (-rA)
.venv/bin/python3 -m pytest --log-level DEBUG -rA

But yes if you change tox.ini:

diff --git a/tox.ini b/tox.ini
index c09483da..38b534b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@ commands =
     {envpython} -m mypy rdflib --show-error-context --show-error-codes
     {envpython} setup.py clean --all
     {envpython} setup.py build
-    {envpython} -m pytest
+    {envpython} -m pytest --log-level DEBUG -rA
 deps =
        -rrequirements.txt
        -rrequirements.dev.txt

Then it will do the same, and you can do the same by editing setup.cfg:

diff --git a/setup.cfg b/setup.cfg
index 3e59cdf2..5990ade2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -39,9 +39,13 @@ addopts =
    --ignore=admin
    --ignore=rdflib/extras/external_graph_libs.py
    --ignore-glob=docs/*.py
+   -rA
 doctest_optionflags = ALLOW_UNICODE
 filterwarnings =
     # The below warning is a consequence of how pytest doctest detects mocks and how DefinedNamespace behaves when an undefined attribute is being accessed.
     ignore:Code. pytest_mock_example_attribute_that_shouldnt_exist is not defined in namespace .*:UserWarning
     # The below warning is a consequence of how pytest detects fixtures and how DefinedNamespace behaves when an undefined attribute is being accessed.
     ignore:Code. _pytestfixturefunction is not defined in namespace .*:UserWarning
+log_cli = true
+log_cli_level = "DEBUG"

or run with:

PYTEST_ADDOPTS="-rA --log-level DEBUG" tox -e py37

I will add it to developers.rst when I have time.

@GreenfishK
Copy link
Author

I just added this to tox.ini

[pytest]
log_cli = 1
log_cli_level = DEBUG 
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) 
log_cli_date_format=%Y-%m-%d %H:%M:%S 

I am running it comfortably using PyCharm

@aucampia
Copy link
Member

aucampia commented Jan 3, 2022

By the way, I am on matrix/gitter if you want help, won't always respond immediately but I do have notifications turned on: https://gitter.im/RDFLib/rdflib / https://matrix.to/#/#RDFLib_rdflib:gitter.im

@GreenfishK
Copy link
Author

By the way, I am on matrix/gitter if you want help, won't always respond immediately but I do have notifications turned on: https://gitter.im/RDFLib/rdflib / https://matrix.to/#/#RDFLib_rdflib:gitter.im

Thank you! For now I am good, I just solved the issues and will make another commit to this PR and add the description from #1361. This way it was somehow easier for me.

Filip Kovacevic added 3 commits January 3, 2022 19:42
….arg.n3() with convert_node_arg(node.arg). This method checks the instance of the argument (as it can be an Identifier, CompValue, Expr, str, ... ) and then responds appropriately during the tree traversion.

test_translate_algebra.py: added debugging to test_translate_algebra
…. elements are now not converted with convert_node_arg(...) before they are added to defaultdict. Pushing to see if this solves the problem in the CI tool on github.
@aucampia
Copy link
Member

aucampia commented Jan 3, 2022

I don't know what is wrong with drone, it looks like everything is fine though, maybe Nic can retrigger drone somehow, but you can also re-trigger it by amending your latest commit and doing a force push:

git commit --amend --date=now
git push --force

@GreenfishK
Copy link
Author

I don't know what is wrong with drone, it looks like everything is fine though, maybe Nic can retrigger drone somehow, but you can also re-trigger it by amending your latest commit and doing a force push:

git commit --amend --date=now
git push --force

I tried it but it didn't work. hm...

@aucampia
Copy link
Member

aucampia commented Jan 4, 2022

@nicholascar @ashleysommer any idea what is up with drone?

@aucampia
Copy link
Member

aucampia commented Jan 4, 2022

@GreenfishK I'm fine if all non drone test pass given drone is not running, so I would not let that hold you back if it is.

@aucampia
Copy link
Member

aucampia commented Jan 4, 2022

Please let me know once this is ready for review, I don't want to review if you are still working on it and I'm assuming you are still working on it given you mentioned you add the description from #1361.

@GreenfishK
Copy link
Author

Please let me know once this is ready for review, I don't want to review if you are still working on it and I'm assuming you are still working on it given you mentioned you add the description from #1361.

Hi @aucampia, it is ready for review. I actually already added the description in the section "Fixes"

@aucampia
Copy link
Member

aucampia commented Jan 5, 2022

@GreenfishK Apologies for not noticing, I will have a look tonight, thanks for the patience and effort.

@GreenfishK
Copy link
Author

@GreenfishK Apologies for not noticing, I will have a look tonight, thanks for the patience and effort.

Thank's for your support!

tox.ini Outdated Show resolved Hide resolved
Copy link
Member

@aucampia aucampia left a comment

Choose a reason for hiding this comment

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

Change looks good, I made some small suggestions (relating to comments and logging) but otherwise I think it is okay to merge.

Filip Kovacevic and others added 4 commits January 6, 2022 07:34
Commented out for now as it is not ideal in all cases and can done via CLI, too

Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
removing unnecessary comment

Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
removing debug message

Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
removing logging

Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
@GreenfishK
Copy link
Author

Change looks good, I made some small suggestions (relating to comments and logging) but otherwise I think it is okay to merge.

Ok, I took over all your suggestions and committed the changes.

Copy link
Member

@aucampia aucampia left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for the effort @GreenfishK.

Copy link
Member

@nicholascar nicholascar left a comment

Choose a reason for hiding this comment

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

Thank you both @GreenfishK and @aucampia for all your work on this PR!

@nicholascar nicholascar merged commit 4cdd742 into RDFLib:master Jan 6, 2022
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.

None yet

3 participants