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

Test that everything can be imported during ci #36591

Merged
merged 13 commits into from
Jan 14, 2024

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Oct 30, 2023

Currently you cannot import many modules directly. We use pytest --collect-only to test during ci that the imports are working. As a first step, we run pytest through sage, which makes sure that sage.all is loaded. Once the reported errors are fixed (e.g. by filtering out modules that fail because of FeatureNotPresentError), we can check that importing without sage.all works.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe
Copy link
Member

mkoeppe commented Oct 30, 2023

This produces 47K lines of output, and various unexplained error messages.
Are there currently modules that cannot be imported? How does one spot them in the 47K lines of output?

error: option -c not recognized
ERROR sage/categories/finite_dimensional_lie_algebras_with_basis.py - RuntimeError: dictionary changed size during iteration
ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'
ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'
ERROR sage/crypto/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/crypto/mq/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/crypto/mq/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/ext_data/nbconvert/postprocess.py - FileNotFoundError: [Errno 2] No such file or directory: '-c'
ERROR sage/geometry/polyhedron/backend_normaliz.py - sage.features.FeatureNotPresentError: pynormaliz is not available.
Importing NmzResult failed: No module named 'PyNormaliz'
No equivalent system packages for debian are known to Sage.
To install pynormaliz using the Sage package manager, you can try to run:
  !sage -i pynormaliz
To install pynormaliz using the pip package manager, you can try to run:

@tobiasdiez
Copy link
Contributor Author

At the end you find a summary, if you scroll up a little bit more you find the full exception stack trace. I've now silenced the other output as much as possible (it still shows how much tests are collected per file).

@tobiasdiez
Copy link
Contributor Author

That's the summary now:

ERROR sage/categories/finite_dimensional_lie_algebras_with_basis.py - RuntimeError: dictionary changed size during iteration
ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'
ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'
ERROR sage/crypto/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/crypto/mq/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/crypto/mq/__init__.py - RuntimeError: dictionary changed size during iteration
ERROR sage/ext_data/nbconvert/postprocess.py - FileNotFoundError: [Errno 2] No such file or directory: '-c'
ERROR sage/geometry/polyhedron/backend_normaliz.py - sage.features.FeatureNotPresentError: pynormaliz is not available.
Importing NmzResult failed: No module named 'PyNormaliz'
No equivalent system packages for debian are known to Sage.
To install pynormaliz using the Sage package manager, you can try to run:
  !sage -i pynormaliz
To install pynormaliz using the pip package manager, you can try to run:
!sage -pip install pynormaliz==2.18
ERROR sage/geometry/polyhedron/backend_normaliz.py - sage.features.FeatureNotPresentError: pynormaliz is not available.
Importing NmzResult failed: No module named 'PyNormaliz'
No equivalent system packages for debian are known to Sage.
To install pynormaliz using the Sage package manager, you can try to run:
  !sage -i pynormaliz
To install pynormaliz using the pip package manager, you can try to run:
!sage -pip install pynormaliz==2.18
ERROR sage/graphs/graph_editor.py - sage.features.FeatureNotPresentError: phitigra is not available.
Importing GraphEditor failed: No module named 'phitigra'
No equivalent system packages for debian are known to Sage.
To install phitigra using the Sage package manager, you can try to run:
  !sage -i phitigra
No equivalent system packages for pip are known to Sage.
ERROR sage/graphs/graph_editor.py - sage.features.FeatureNotPresentError: phitigra is not available.
Importing GraphEditor failed: No module named 'phitigra'
No equivalent system packages for debian are known to Sage.
To install phitigra using the Sage package manager, you can try to run:
  !sage -i phitigra
No equivalent system packages for pip are known to Sage.
ERROR sage/interfaces/r.py - ModuleNotFoundError: No module named 'rpy2'
ERROR sage/interfaces/r.py - ModuleNotFoundError: No module named 'rpy2'
ERROR sage/repl/ipython_kernel/__main__.py - SystemExit: 2
ERROR sage/sat/solvers/cryptominisat.py - sage.features.FeatureNotPresentError: pycryptosat is not available.
Importing Solver failed: No module named 'pycryptosat'
No equivalent system packages for debian are known to Sage.
To install pycryptosat using the Sage package manager, you can try to run:
  !sage -i cryptominisat
No equivalent system packages for pip are known to Sage.
ERROR sage/sat/solvers/cryptominisat.py - sage.features.FeatureNotPresentError: pycryptosat is not available.
Importing Solver failed: No module named 'pycryptosat'
No equivalent system packages for debian are known to Sage.
To install pycryptosat using the Sage package manager, you can try to run:
  !sage -i cryptominisat
No equivalent system packages for pip are known to Sage.
ERROR sage/sat/solvers/picosat.py - sage.features.FeatureNotPresentError: pycosat is not available.
Importing solve failed: No module named 'pycosat'
No equivalent system packages for debian are known to Sage.
To install pycosat using the Sage package manager, you can try to run:
  !sage -i pycosat
No equivalent system packages for pip are known to Sage.
ERROR sage/sat/solvers/picosat.py - sage.features.FeatureNotPresentError: pycosat is not available.
Importing solve failed: No module named 'pycosat'
No equivalent system packages for debian are known to Sage.
To install pycosat using the Sage package manager, you can try to run:
  !sage -i pycosat
No equivalent system packages for pip are known to Sage.
ERROR sage/tests/memcheck/symbolic_expression.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage/tests/memcheck/verify_no_leak.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage_setup/autogen/giacpy-mkkeywords.py - FileNotFoundError: [Errno 2] No such file or directory: 'aide_cas.txt'

(more details in the logs)

@mkoeppe
Copy link
Member

mkoeppe commented Nov 11, 2023

ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'
ERROR sage/combinat/root_system/coxeter_group.py - ModuleNotFoundError: No module named 'from sage'

I've fixed this bizarre looking error in #36698

@mkoeppe
Copy link
Member

mkoeppe commented Nov 11, 2023

ERROR sage/tests/memcheck/symbolic_expression.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage/tests/memcheck/verify_no_leak.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage_setup/autogen/giacpy-mkkeywords.py - FileNotFoundError: [Errno 2] No such file or directory: 'aide_cas.txt'

I'd suggest to just exclude these (sage.test and sage_setup) from anything "pytest"

@mkoeppe
Copy link
Member

mkoeppe commented Nov 11, 2023

ERROR sage/repl/ipython_kernel/main.py - SystemExit: 2

Also __main__.py files probably best to exclude from pytest globally if you can

@mkoeppe
Copy link
Member

mkoeppe commented Nov 11, 2023

ERROR sage/ext_data/nbconvert/postprocess.py - FileNotFoundError: [Errno 2] No such file or directory: '-c'

Exclude please

@vbraun vbraun force-pushed the develop branch 2 times, most recently from 883e05f to e349b00 Compare November 12, 2023 16:25
@tobiasdiez
Copy link
Contributor Author

ERROR sage/tests/memcheck/symbolic_expression.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage/tests/memcheck/verify_no_leak.py - ModuleNotFoundError: No module named 'valgrind'
ERROR sage_setup/autogen/giacpy-mkkeywords.py - FileNotFoundError: [Errno 2] No such file or directory: 'aide_cas.txt'

I'd suggest to just exclude these (sage.test and sage_setup) from anything "pytest"

There are doctests in these modules, so I think completely ignoring them is to coarse.

@tobiasdiez
Copy link
Contributor Author

tobiasdiez commented Nov 21, 2023

ERROR sage/repl/ipython_kernel/main.py - SystemExit: 2

Also __main__.py files probably best to exclude from pytest globally if you can

Done

ERROR sage/ext_data/nbconvert/postprocess.py - FileNotFoundError: [Errno 2] No such file or directory: '-c'

Exclude please

Done

@mkoeppe
Copy link
Member

mkoeppe commented Dec 21, 2023

The log has 2000 lines of the form

conftest_inputtest.py: 1
conftest_test.py: 2
sage/algebras/affine_nil_temperley_lieb.py: 12
sage/algebras/algebra.py: 1
sage/algebras/askey_wilson.py: 22
sage/algebras/associated_graded.py: 10
sage/algebras/cellular_basis.py: 11
sage/algebras/clifford_algebra.py: 71
sage/algebras/cluster_algebra.py: 84
sage/algebras/commutative_dga.py: 95

https://github.com/sagemath/sage/actions/runs/7285981360/job/19853897084?pr=36591#step:16:26

Could you add a message to the log please that explains what it is?

@mkoeppe
Copy link
Member

mkoeppe commented Dec 21, 2023

best to exclude setup.py

______________________________________________ ERROR collecting setup.py _______________________________________________
../local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/fancy_getopt.py:246: in getopt
    opts, args = getopt.getopt(args, short_opts, self.long_opts)
../local/var/lib/sage/venv-python3.11.1/lib/python3.11/getopt.py:95: in getopt
    opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
../local/var/lib/sage/venv-python3.11.1/lib/python3.11/getopt.py:195: in do_shorts
    if short_has_arg(opt, shortopts):
../local/var/lib/sage/venv-python3.11.1/lib/python3.11/getopt.py:211: in short_has_arg
    raise GetoptError(_('option -%s not recognized') % opt, opt)
E   getopt.GetoptError: option -c not recognized

@mkoeppe
Copy link
Member

mkoeppe commented Dec 21, 2023

There are lots of error messages related to optional packages, for example https://github.com/sagemath/sage/actions/runs/7285981360/job/19853897084?pr=36591#step:16:3134

sage/geometry/polyhedron/backend_normaliz.py - sage.features.FeatureNotPresentError: pynormaliz is not available.
Importing NmzResult failed: No module named 'PyNormaliz'
No equivalent system packages for debian are known to Sage.
To install pynormaliz using the Sage package manager, you can try to run:
  !sage -i pynormaliz
To install pynormaliz using the pip package manager, you can try to run:
!sage -pip install pynormaliz==2.18

Would it be easy to skip the files that are marked as depending on an optional feature?

@tobiasdiez
Copy link
Contributor Author

The log has 2000 lines of the form

conftest_inputtest.py: 1
conftest_test.py: 2
sage/algebras/affine_nil_temperley_lieb.py: 12
sage/algebras/algebra.py: 1
sage/algebras/askey_wilson.py: 22
sage/algebras/associated_graded.py: 10
sage/algebras/cellular_basis.py: 11
sage/algebras/clifford_algebra.py: 71
sage/algebras/cluster_algebra.py: 84
sage/algebras/commutative_dga.py: 95

https://github.com/sagemath/sage/actions/runs/7285981360/job/19853897084?pr=36591#step:16:26

Could you add a message to the log please that explains what it is?

Done.

There are lots of error messages related to optional packages, for example https://github.com/sagemath/sage/actions/runs/7285981360/job/19853897084?pr=36591#step:16:3134

sage/geometry/polyhedron/backend_normaliz.py - sage.features.FeatureNotPresentError: pynormaliz is not available.
Importing NmzResult failed: No module named 'PyNormaliz'
No equivalent system packages for debian are known to Sage.
To install pynormaliz using the Sage package manager, you can try to run:
  !sage -i pynormaliz
To install pynormaliz using the pip package manager, you can try to run:
!sage -pip install pynormaliz==2.18

Would it be easy to skip the files that are marked as depending on an optional feature?

Will look into this as follow-up. (It is really not the point of this PR to fix/exclude any of these failing imports)

Copy link

Documentation preview for this PR (built with commit cc3792f; changes) is ready! 🎉

@@ -174,6 +174,9 @@ jobs:

- name: Check that all modules can be imported
run: |
# The following command checks that all modules can be imported.
# The output also includes a long list of modules together with the number of tests in each module.
# This can be ignored.
Copy link
Member

Choose a reason for hiding this comment

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

Is the output intended? Do you use this information? Or should everyone ignore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's safe to ignore (but pytest doesn't support a way to hide it)

Copy link
Member

Choose a reason for hiding this comment

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

Fine. I assume that you mean that you also do not use this information. We'll iterate the cosmetics in follow-up PRs.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 2, 2024
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

Currently you cannot import many modules directly. We use `pytest
--collect-only` to test during ci that the imports are working. As a
first step, we run pytest through sage, which makes sure that `sage.all`
is loaded. Once the reported errors are fixed (e.g. by filtering out
modules that fail because of FeatureNotPresentError), we can check that
importing without `sage.all` works.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36591
Reported by: Tobias Diez
Reviewer(s): Matthias Köppe, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 5, 2024
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

Currently you cannot import many modules directly. We use `pytest
--collect-only` to test during ci that the imports are working. As a
first step, we run pytest through sage, which makes sure that `sage.all`
is loaded. Once the reported errors are fixed (e.g. by filtering out
modules that fail because of FeatureNotPresentError), we can check that
importing without `sage.all` works.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36591
Reported by: Tobias Diez
Reviewer(s): Matthias Köppe, Tobias Diez
@vbraun vbraun merged commit 1044a6c into sagemath:develop Jan 14, 2024
23 checks passed
@mkoeppe mkoeppe added this to the sage-10.3 milestone Jan 14, 2024
@mkoeppe mkoeppe mentioned this pull request Jan 29, 2024
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 11, 2024
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
As reported in https://groups.google.com/g/sage-
devel/c/mLtXcaypU3Q/m/jHoVjQ9oAAAJ @kwankyu

This failure was introduced as a side effect of sagemath#36591: The pytest
discovery of modules disagrees with `sage_setup`'s notion of package
directories vs. data directories. We repair it by making
`sage.tests.books` an ordinary package directory (correct because the
whole thing is shipped by **sagemath-repl**).

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
Fixes sagemath#37216
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37185
Reported by: Matthias Köppe
Reviewer(s): Gonzalo Tornaría
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants