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

Add symmath to openedx-calc #38

Merged
merged 1 commit into from
Jan 20, 2022
Merged

Conversation

Carlos-Muniz
Copy link
Contributor

closes #37

symmath is leaving edx-platform and moving to openedx-calc. As our first step we move symmath to openedx-calc. We update the requirements, test config files, the readme, the setup.py, and move all the tests to its own directory.

@Carlos-Muniz Carlos-Muniz requested a review from sarina January 13, 2022 20:38
@Carlos-Muniz Carlos-Muniz self-assigned this Jan 13, 2022
Copy link

@dianakhuang dianakhuang left a comment

Choose a reason for hiding this comment

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

I think this looks good to me overall. I didn't dig into the specific symmath lines of code since I'm assuming that's mostly, if not entirely, copy/paste. I don't think this will impact much until we delete this out of edx-platform.

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Code changes looks solid 👍🏻

Two issues with the tests though:

  1. I don't think linting is being run. Both the py38 and quality test contexts run unit tests; neither contexts run quality analysis. I think there's a disconnect in the github action -> tox machinery. Unfortunately it looks like this was the case before you opened your PR :(
  2. I think test_symmath_check_different_symbols is silently failing
2022-01-13T20:39:52.0945218Z test_symmath_check_different_symbols (tests.test_symmath_check.SymmathCheckTest) ... Err 'lxml.etree._Element' object has no attribute 'decode' while preprocessing; expr=<math xmlns="http://www.w3.org/1998/Math/MathML">
2022-01-13T20:39:52.0952420Z   <mstyle displaystyle="true">
2022-01-13T20:39:52.0952888Z   <mrow>
2022-01-13T20:39:52.0953227Z     <mi>x</mi>
2022-01-13T20:39:52.0953469Z     <mo>+</mo>
2022-01-13T20:39:52.0953758Z     <mi>y</mi>
2022-01-13T20:39:52.0953991Z   </mrow>
2022-01-13T20:39:52.0954305Z </mstyle>
2022-01-13T20:39:52.0954559Z </math>
2022-01-13T20:39:52.0955459Z Error evaluating expression 'x+y' as a valid equation
2022-01-13T20:39:52.0955869Z Traceback (most recent call last):
2022-01-13T20:39:52.0964356Z   File "/home/runner/work/openedx-calc/openedx-calc/symmath/symmath_check.py", line 270, in symmath_check
2022-01-13T20:39:52.0965117Z     fsym = f.sympy
2022-01-13T20:39:52.0965849Z   File "/home/runner/work/openedx-calc/openedx-calc/symmath/formula.py", line 468, in make_sympy
2022-01-13T20:39:52.0966297Z     self.the_sympy = self.make_sympy(xml[0])
2022-01-13T20:39:52.0966775Z   File "src/lxml/etree.pyx", line 1176, in lxml.etree._Element.__getitem__
2022-01-13T20:39:52.0967216Z IndexError: list index out of range
2022-01-13T20:39:52.0967531Z ok
2022-01-13T20:39:52.0996244Z test_symmath_check_equivalent_symbols (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:52.9970904Z test_symmath_check_floats (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7788603Z test_symmath_check_integers (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7984221Z test_symmath_check_same_symbols (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7984503Z 
2022-01-13T20:39:53.7985274Z ----------------------------------------------------------------------
2022-01-13T20:39:53.7985902Z Ran 64 tests in 3.923s
2022-01-13T20:39:53.7986042Z 
2022-01-13T20:39:53.7986327Z OK

Makefile Outdated Show resolved Hide resolved
README.rst Show resolved Hide resolved
requirements/base.txt Show resolved Hide resolved
@kdmccormick
Copy link
Member

@Carlos-Muniz Two other thoughts that just came to mind:

Firstly, you will want to bump the version of this project, potentially the major version since this is a relatively large change.

Secondly: by default, edx-platform will upgrade to the latest version of all project every week unless they are explicitly constrainted. So, edx-platform would inherit these changes within a week after merging this PR if you release a new version (which you should). To be honest, I don't know what happens if two versions of symmath (the edx-platform/common/lib version and this one) are both available to import!

So, in edx-platform, you may want to constrain openedx-calc to its current, symmath-less version before merging this PR. Then, once you're ready, you could delete the edx-platform/common/lib copy of symmath and upgrade to the latest version of openedx-calc all in one edx-platform PR.

@Carlos-Muniz
Copy link
Contributor Author

Code changes looks solid 👍🏻

Two issues with the tests though:

  1. I don't think linting is being run. Both the py38 and quality test contexts run unit tests; neither contexts run quality analysis. I think there's a disconnect in the github action -> tox machinery. Unfortunately it looks like this was the case before you opened your PR :(
  2. I think test_symmath_check_different_symbols is silently failing
2022-01-13T20:39:52.0945218Z test_symmath_check_different_symbols (tests.test_symmath_check.SymmathCheckTest) ... Err 'lxml.etree._Element' object has no attribute 'decode' while preprocessing; expr=<math xmlns="http://www.w3.org/1998/Math/MathML">
2022-01-13T20:39:52.0952420Z   <mstyle displaystyle="true">
2022-01-13T20:39:52.0952888Z   <mrow>
2022-01-13T20:39:52.0953227Z     <mi>x</mi>
2022-01-13T20:39:52.0953469Z     <mo>+</mo>
2022-01-13T20:39:52.0953758Z     <mi>y</mi>
2022-01-13T20:39:52.0953991Z   </mrow>
2022-01-13T20:39:52.0954305Z </mstyle>
2022-01-13T20:39:52.0954559Z </math>
2022-01-13T20:39:52.0955459Z Error evaluating expression 'x+y' as a valid equation
2022-01-13T20:39:52.0955869Z Traceback (most recent call last):
2022-01-13T20:39:52.0964356Z   File "/home/runner/work/openedx-calc/openedx-calc/symmath/symmath_check.py", line 270, in symmath_check
2022-01-13T20:39:52.0965117Z     fsym = f.sympy
2022-01-13T20:39:52.0965849Z   File "/home/runner/work/openedx-calc/openedx-calc/symmath/formula.py", line 468, in make_sympy
2022-01-13T20:39:52.0966297Z     self.the_sympy = self.make_sympy(xml[0])
2022-01-13T20:39:52.0966775Z   File "src/lxml/etree.pyx", line 1176, in lxml.etree._Element.__getitem__
2022-01-13T20:39:52.0967216Z IndexError: list index out of range
2022-01-13T20:39:52.0967531Z ok
2022-01-13T20:39:52.0996244Z test_symmath_check_equivalent_symbols (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:52.9970904Z test_symmath_check_floats (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7788603Z test_symmath_check_integers (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7984221Z test_symmath_check_same_symbols (tests.test_symmath_check.SymmathCheckTest) ... ok
2022-01-13T20:39:53.7984503Z 
2022-01-13T20:39:53.7985274Z ----------------------------------------------------------------------
2022-01-13T20:39:53.7985902Z Ran 64 tests in 3.923s
2022-01-13T20:39:53.7986042Z 
2022-01-13T20:39:53.7986327Z OK

I've looked into this issue more. From what I can tell, this test is failing because formula.make_sympy (in formula.py) does not work correctly when interpreting xml. The recursive implementation fails when it sees a tag it is not familiar with, in this case "mstyle".

@Carlos-Muniz Carlos-Muniz force-pushed the Carlos-Muniz/add-symmath branch from b059209 to 129859d Compare January 18, 2022 21:05
@Carlos-Muniz
Copy link
Contributor Author

A new issue #39 has been made to add more tests that evaluate the dynamath evaluation.

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Looking pretty good; just a couple more issues.

symmath/symmath_check.py Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
calc/__init__.py Show resolved Hide resolved
@kdmccormick
Copy link
Member

@Carlos-Muniz this will not fix the linting violations, but it will make so Python CI / Tests (ubuntu-20.04, 3.8, py38) runs only unit tests and Python CI / Tests (ubuntu-20.04, 3.8, quality) runs only quality checks: #40. Right now they're both running both, which is confusing.

@kdmccormick
Copy link
Member

@Carlos-Muniz As for the new quality failures that we're seeing: no, you don't need to fix all of those, but we do need to get the build passing (without disabling quality checking altogether). Here's what I'd recommend:

For pycodestyle:

  • Create a ./setup.cfg with a pycodestyle section and disable style rules that you think aren't helpful or are just beyond fixing at this point. For example, disabling E501 (line too long) will eliminate a looot of those violations.

For pylint:

  • You can use edx-lint (will need to be added to this repo's testing requirements) to generate a ./pylintrc file for this repo, which will tell pylint to ignore certain violations. Similar to pycodestyle, you can choose to ignore violations that you think are unhelpful or are just too far gone to be worth fixing at this point.

tox.ini Outdated Show resolved Hide resolved
Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Nice work!

Two nits, but no need for another round of review IMO

symmath/formula.py Outdated Show resolved Hide resolved
symmath/symmath_check.py Outdated Show resolved Hide resolved
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.

Move edx-platform/common/lib/symmath/symmath here
3 participants