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

Follow up #36741: improve code structure #37737

Merged
merged 7 commits into from
May 12, 2024

Conversation

soehms
Copy link
Member

@soehms soehms commented Apr 3, 2024

From #36741 (comment)

Overall, I would suggest to remove the direct and unconditional use of multiprocessing from sage.features.
Perhaps sage.doctest can put such Value attributes into features that are to be hidden.

This PR implements the suggestion made in #36741 (comment)

I looked a little bit into it and here's an idea:

  • In features, implement a simple hide() / unhide() / is_hidden() interface.
  • The only state is _hidden, not shared (for parallel doctesting this will be set before fork so it's ok)
  • Implement AvailableSoftware.hidden() similar to AvailableSoftware.seen() so the logic stays in that class and internals don't leak to sage.doctest.control (if necessary use _seen[idx] to record hidden state and/or number of hidings, or add another shared array)

Fixes #37905

📝 Checklist

  • The title is concise and informative.
  • 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

@soehms soehms added this to the sage-10.4 milestone Apr 3, 2024
@soehms soehms marked this pull request as ready for review April 3, 2024 21:37
@soehms soehms requested a review from tornaria April 3, 2024 21:37
Copy link
Contributor

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@soehms
Copy link
Member Author

soehms commented Apr 8, 2024

LGTM, thanks

Thanks, too!

@vbraun
Copy link
Member

vbraun commented Apr 10, 2024

I'm getting this in parallel tests, but passes in isolation:

sage -t --long --warn-long 43.9 --random-seed=123 src/sage/doctest/external.py
**********************************************************************
File "src/sage/doctest/external.py", line 518, in sage.doctest.external.AvailableSoftware.hidden
Failed example:
    available_software.hidden()
Expected:
    [...'conway_polynomials',
     'database_cremona_mini_ellcurve',
     'database_ellcurves',
     'database_graphs'...]
Got:
    ['database_cremona_mini_ellcurve', 'database_ellcurves', 'database_graphs']
**********************************************************************

Copy link

github-actions bot commented Apr 11, 2024

Documentation preview for this PR (built with commit 0f87bb8; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@tornaria
Copy link
Contributor

I'm getting this in parallel tests, but passes in isolation:

sage -t --long --warn-long 43.9 --random-seed=123 src/sage/doctest/external.py
**********************************************************************
File "src/sage/doctest/external.py", line 518, in sage.doctest.external.AvailableSoftware.hidden
Failed example:
    available_software.hidden()
Expected:
    [...'conway_polynomials',
     'database_cremona_mini_ellcurve',
     'database_ellcurves',
     'database_graphs'...]
Got:
    ['database_cremona_mini_ellcurve', 'database_ellcurves', 'database_graphs']
**********************************************************************

I can't reproduce this. Could you give us more details and/or share the head of the tree where you see this?

@vbraun
Copy link
Member

vbraun commented Apr 12, 2024

I got this twice in a row when running make distclean && make && make ptestlong

But in general can we make the test maybe less fragile, is it really important that those 4 items have to be consecutively in there? Maybe you just want to check that one is in there so hidden works at all?

@soehms
Copy link
Member Author

soehms commented Apr 12, 2024

is it really important that those 4 items have to be consecutively in there? Maybe you just want to check that one is in there so hidden works at all?

The fact that conway_polynomials is missing from the answer is indeed strange. If this would happen when a developer runs sage -tp --hide=conway_polynomials we would give him a wrong feedback.

@soehms
Copy link
Member Author

soehms commented May 9, 2024

The current commit addresses #37905 in the context of this PR. As mentioned in #37857 (comment) the connection betwee the content of the variable _seen and the result of the method __contains__ turns out to be problematic when using the hide option since this option may cause an available feature to be temporarily unavailable. Therefore, I suggest decoupling the result from the content of _seen.

Note that there is no real need to cache the result of self._features[idx].is_present() as it is already cached in the _is_present method of the Feature class. From this point of view it seems that there is no real need to set _seen to -1. @kwankyu, since you introduced this variable in March 2016 (in this commit), can you please confirm that I'm right?

Likewise, there is no need to set _hidden to -1. I couldn't reproduce the failure that @vbraun got (see #37737 (comment)), but I suspect this happened because _hidden for the feature conway_polynomials was set to -1 (by a thread calling __contains__ as the feature was not hidden). Therefore, there is a good chance that this failure will no longer occur.

@mkoeppe
Copy link
Contributor

mkoeppe commented May 9, 2024

test-mod shows this failure. This is a separate test of the modularized distribution sagemath-categories.

[sagemath_categories-10.4.beta5] [spkg-check] sage -t --random-seed=207122778768807178970207259884772121442 --environment=sage.all__sagemath_categories sage/doctest/external.py
[sagemath_categories-10.4.beta5] [spkg-check] **********************************************************************
[sagemath_categories-10.4.beta5] [spkg-check] File "sage/doctest/external.py", line 519, in sage.doctest.external.AvailableSoftware.hidden
[sagemath_categories-10.4.beta5] [spkg-check] Failed example:
[sagemath_categories-10.4.beta5] [spkg-check]     sorted(available_software.hidden())
[sagemath_categories-10.4.beta5] [spkg-check] Expected:
[sagemath_categories-10.4.beta5] [spkg-check]     [...'conway_polynomials',...
[sagemath_categories-10.4.beta5] [spkg-check]      'database_cremona_mini_ellcurve',...
[sagemath_categories-10.4.beta5] [spkg-check]      'database_ellcurves',...
[sagemath_categories-10.4.beta5] [spkg-check]      'database_graphs'...]
[sagemath_categories-10.4.beta5] [spkg-check] Got:
[sagemath_categories-10.4.beta5] [spkg-check]     []
[sagemath_categories-10.4.beta5] [spkg-check] **********************************************************************

vbraun pushed a commit to vbraun/sage that referenced this pull request May 11, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

From sagemath#36741 (comment)

> Overall, I would suggest to remove the direct and unconditional use of
multiprocessing from sage.features.
> Perhaps sage.doctest can put such Value attributes into features that
are to be hidden.

This PR implements the suggestion made in
sagemath#36741 (comment)

> I looked a little bit into it and here's an idea:
>
> * In features, implement a simple hide() / unhide() / is_hidden()
interface.
> * The only state is _hidden, not shared (for parallel doctesting this
will be set before fork so it's ok)
> * Implement AvailableSoftware.hidden() similar to
AvailableSoftware.seen() so the logic stays in that class and internals
don't leak to sage.doctest.control (if necessary use _seen[idx] to
record hidden state and/or number of hidings, or add another shared
array)

Fixes sagemath#37905


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] 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. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37737
Reported by: Sebastian Oehms
Reviewer(s): Matthias Köppe, Sebastian Oehms
vbraun pushed a commit to vbraun/sage that referenced this pull request May 12, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

From sagemath#36741 (comment)

> Overall, I would suggest to remove the direct and unconditional use of
multiprocessing from sage.features.
> Perhaps sage.doctest can put such Value attributes into features that
are to be hidden.

This PR implements the suggestion made in
sagemath#36741 (comment)

> I looked a little bit into it and here's an idea:
>
> * In features, implement a simple hide() / unhide() / is_hidden()
interface.
> * The only state is _hidden, not shared (for parallel doctesting this
will be set before fork so it's ok)
> * Implement AvailableSoftware.hidden() similar to
AvailableSoftware.seen() so the logic stays in that class and internals
don't leak to sage.doctest.control (if necessary use _seen[idx] to
record hidden state and/or number of hidings, or add another shared
array)

Fixes sagemath#37905


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] 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. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37737
Reported by: Sebastian Oehms
Reviewer(s): Matthias Köppe, Sebastian Oehms
@vbraun vbraun merged commit 7ace60e into sagemath:develop May 12, 2024
15 checks passed
@soehms
Copy link
Member Author

soehms commented May 13, 2024

Thanks!

@soehms soehms deleted the improve_multiprocessing_hide_option branch May 13, 2024 16:24
vbraun pushed a commit to vbraun/sage that referenced this pull request May 29, 2024
…iss, coxeter3, ....)

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

We relieve the distribution **sagemath-standard** (in both versions -
`SAGE_ROOT/pkgs/sagemath-standard` and `SAGE_ROOT/src`) from the duty to
build "optional extensions" based on what Sage packages are installed.

The installation is now done uniformly using the modularized
distributions **sagemath-bliss**, **sagemath-coxeter3** etc.

We introduce the missing features `coxeter3` and `sirocco` so that the
doctester does not have to rely on the sage-the-distro installation
records any more.

The wheels of the distributions now build correctly even when not going
through building an sdist first, which previously was required to apply
MANIFEST-based filtering. This is achieved using the new
`sage_setup.command.build_py`.

User-visible change:
- To install these options, use `./configure --enable-sagemath_bliss`
before building, or use `./sage -i sagemath_bliss` or `make
sagemath_bliss`.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [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 and checked the documentation
preview.

### ⌛ Dependencies

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

- Depends on sagemath#37737 (merged here)
- Depends on sagemath#37973 (merged here)
    
URL: sagemath#37857
Reported by: Matthias Köppe
Reviewer(s): François Bissey
vbraun pushed a commit to vbraun/sage that referenced this pull request May 31, 2024
…iss, coxeter3, ....)

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

We relieve the distribution **sagemath-standard** (in both versions -
`SAGE_ROOT/pkgs/sagemath-standard` and `SAGE_ROOT/src`) from the duty to
build "optional extensions" based on what Sage packages are installed.

The installation is now done uniformly using the modularized
distributions **sagemath-bliss**, **sagemath-coxeter3** etc.

We introduce the missing features `coxeter3` and `sirocco` so that the
doctester does not have to rely on the sage-the-distro installation
records any more.

The wheels of the distributions now build correctly even when not going
through building an sdist first, which previously was required to apply
MANIFEST-based filtering. This is achieved using the new
`sage_setup.command.build_py`.

User-visible change:
- To install these options, use `./configure --enable-sagemath_bliss`
before building, or use `./sage -i sagemath_bliss` or `make
sagemath_bliss`.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [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 and checked the documentation
preview.

### ⌛ Dependencies

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

- Depends on sagemath#37737 (merged here)
- Depends on sagemath#37973 (merged here)
    
URL: sagemath#37857
Reported by: Matthias Köppe
Reviewer(s): François Bissey
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.

Doctests failures in sage/doctest/control.py when sagemath-meataxe is installed
4 participants