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

Fix SSL timeout in doctest / internet feature #36696

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

tornaria
Copy link
Contributor

Recently I've been getting timeouts in a couple of doctests in src/sage/doctest/control.py, including earlier today when testing 10.2.rc1

This has two causes:

  1. The test for the internet feature doesn't catch a TimeoutError.
  2. These two doctests cause internet feature to be tested.

The first one is clearly a bug: sagemath only expects urllib.error.URLError, but in some cases urllib raises TimeoutError. Arguably a bug in urlib, but easier to fix (or workaround) on our side. Done in the first commit of this PR.

The second one is IMO a bug, since I didn't use --optional=internet no test should hit internet (in particular, should not test internet feature).

These two doctests are meant to test options --hide=all and --hide=optional. For some reason the semantics of these include testing for the internet feature. I believe the semantics of these options should be similar to --optional=all, that is, exclude "external" software (internet feature is considered "external").

That's what I implemented in the second commit in this PR.

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.

@tornaria
Copy link
Contributor Author

Note that this is not trivial to test, since the timeout bug is hard to reproduce (it triggers only if the timeout happens after the https request is made and before the response is read back, or something like that).

A reasonable way to test the second commit is to temporarily patch the method Internet._is_present() in src/sage/features/internet.py to unconditionally raise TimeoutError.

@tornaria tornaria requested a review from vbraun November 10, 2023 23:27
@mkoeppe mkoeppe requested a review from soehms November 10, 2023 23:30
@mkoeppe mkoeppe added this to the sage-10.2 milestone Nov 11, 2023
@tornaria
Copy link
Contributor Author

Are the following failures my fault?

----------------------------------------------------------------------
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/degree_sequences.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/tutorial.py  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/comparability.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/connectivity.pyx  # 2 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/digraph_generators.py  # 8 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/generic_graph.py  # 5 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/genus.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/graph.py  # 3 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/graph_coloring.pyx  # 2 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/graph_generators.py  # 17 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/hypergraph_generators.py  # 9 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/repl/rich_output/pretty_print.py  # 3 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/sets/set_from_iterator.py  # 15 doctests failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py  # 1 doctest failed
----------------------------------------------------------------------

@tornaria
Copy link
Contributor Author

I'll assume is some of this shit:

Applying: Merge https://github.com/sagemath/sage/pull/36671
Applying: Merge https://github.com/sagemath/sage/pull/36529
Applying: Merge https://github.com/sagemath/sage/pull/36372

Heck, these are moving targets and the log doesn't even print the commit hash that was merged!

Bear in mind this PR was pushed within a day of 10.2.rc1 being released.

#36372 goes to show how broken this act is: there is a disagreement on the status of that PR, and CI is being hold hostage.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

Are the following failures my fault?

----------------------------------------------------------------------
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/degree_sequences.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/tutorial.py  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/comparability.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/connectivity.pyx  # 2 doctests failed

No, they also show up in other PRs. A problem with nauty.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

I'll assume is some of this shit:

Applying: Merge https://github.com/sagemath/sage/pull/36671
Applying: Merge https://github.com/sagemath/sage/pull/36529
Applying: Merge https://github.com/sagemath/sage/pull/36372

I don't think so.

Heck, these are moving targets and the log doesn't even print the commit hash that was merged!

Actually the log does print all that information, just not where you looked. https://github.com/sagemath/sage/actions/runs/6830550892/job/18578658840?pr=36696#step:3:20

The applied patches are also in the "upstream" artifact - https://github.com/sagemath/sage/actions/runs/6830550892?pr=36696

@tornaria
Copy link
Contributor Author

I'll assume is some of this shit:

Applying: Merge https://github.com/sagemath/sage/pull/36671
Applying: Merge https://github.com/sagemath/sage/pull/36529
Applying: Merge https://github.com/sagemath/sage/pull/36372

I don't think so.

Heck, these are moving targets and the log doesn't even print the commit hash that was merged!

Actually the log does print all that information, just not where you looked. https://github.com/sagemath/sage/actions/runs/6830550892/job/18578658840?pr=36696#step:3:20

If you mean this:

commit 3d28c298df87999cb38a8b94aa05270aaff0550f
Author: ci-sage workflow <ci-sage@example.com>
Date:   Sat Nov 11 00:56:50 2023 +0000

    Merge https://github.com/sagemath/sage/pull/36372

commit 768cf3ff76a63ffb38b0b4f9b9b0b6a089e89695
Author: ci-sage workflow <ci-sage@example.com>
Date:   Sat Nov 11 00:56:49 2023 +0000

    Merge https://github.com/sagemath/sage/pull/36529

commit 1520c1f6571f9aeb6a16f270a7d53d68c35ffd76
Author: ci-sage workflow <ci-sage@example.com>
Date:   Sat Nov 11 00:56:46 2023 +0000

    Merge https://github.com/sagemath/sage/pull/36671

There's not enough information here. These are the merge commits, but I don't expect they will be anywhere I can find them (i.e., in the PR).

Usually when I do git log --first-parent I get something like

$ git log --first-parent develop..
commit af8dbaa6977dadf0ab9b1e59e68930f084cbfa7c (HEAD -> develop-merge)
Merge: 8aa61ce6392 3f92c49026b
Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
Date:   Fri Nov 10 20:28:33 2023 -0300

    Merge PR #36696: Fix SSL timeout

[...]

At least this way I can see 3f92c49 is the commit that was merged, and I can find it in the PR (in fact it's this PR). Let's compare with 3d28c298df87999cb38a8b94aa05270aaff0550f <--- see, not even GH knows about this commit.

The applied patches are also in the "upstream" artifact - https://github.com/sagemath/sage/actions/runs/6830550892?pr=36696

That's so much friction that I'm already sweating (no good since summer is coming here in the south). Also, I worry that different jobs may be started at different times; so it could be that different jobs in the same check merge different commits (e.g. in case some blocker pr changes in between). For the same reason it'd be nice to print the same (complete) information in every job, and don't print incomplete information anywhere.

If showing the Merge: line is not feasible, or just for bonus points, the commit message for the merge could include a link to the parent commit, something like

Merge https://github.com/sagemath/sage/pull/36696 @ https://github.com/sagemath/sage/commit/3f92c49026b16f94da78240066e41ef6f27d9aa0

which would be hopefully clickable (needs the full URL since only complete URLs are clickable in logs afaik). Or else, just print a link to the PR + link to the commit instead of only a link to the PR.

My constructive suggestion above should not be confused with me endorsing this scheme, which I still think it's too brittle (both from technical and social sides).

@tornaria
Copy link
Contributor Author

Are the following failures my fault?

----------------------------------------------------------------------
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/degree_sequences.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/combinat/tutorial.py  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/comparability.pyx  # 1 doctest failed
sage -t --long --random-seed=286735480429121101562228604801325644303 sage/graphs/connectivity.pyx  # 2 doctests failed

No, they also show up in other PRs. A problem with nauty.

CI seems to be fixed now (see #36702).

Shall I then restart this check? (only way I know is to amend and force push).

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

CI seems to be fixed now (see #36702).

No, I think it's a stochastically appearing problem. My current guess is that the recently updated nauty does not respect SAGE_FAT_BINARY and thus it depends on CPU details of the runner

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

Actually the log does print all that information, just not where you looked. https://github.com/sagemath/sage/actions/runs/6830550892/job/18578658840?pr=36696#step:3:20

If you mean this:

commit 3d28c298df87999cb38a8b94aa05270aaff0550f
Author: ci-sage workflow <ci-sage@example.com>
Date:   Sat Nov 11 00:56:50 2023 +0000

    Merge https://github.com/sagemath/sage/pull/36372
[...]

There's not enough information here.

You are right.

[...] Usually when I do git log --first-parent I get something like

$ git log --first-parent develop..
commit af8dbaa6977dadf0ab9b1e59e68930f084cbfa7c (HEAD -> develop-merge)
Merge: 8aa61ce6392 3f92c49026b
Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
Date:   Fri Nov 10 20:28:33 2023 -0300

    Merge PR #36696: Fix SSL timeout

[...]

At least this way I can see 3f92c49 is the commit that was merged, and I can find it in the PR (in fact it's this PR). Let's compare with 3d28c298df87999cb38a8b94aa05270aaff0550f <--- see, not even GH knows about this commit.

OK, I'll see what I can do.

The applied patches are also in the "upstream" artifact - https://github.com/sagemath/sage/actions/runs/6830550892?pr=36696

That's so much friction that I'm already sweating [...]

I agree, it's far from convenient.

If showing the Merge: line is not feasible, or just for bonus points, the commit message for the merge could include a link to the parent commit, something like

Merge https://github.com/sagemath/sage/pull/36696 @ https://github.com/sagemath/sage/commit/3f92c49026b16f94da78240066e41ef6f27d9aa0

which would be hopefully clickable (needs the full URL since only complete URLs are clickable in logs afaik). Or else, just print a link to the PR + link to the commit instead of only a link to the PR.

Good idea and easy to do.

(Edit: I'll do this in #36686)

@tornaria
Copy link
Contributor Author

CI seems to be fixed now (see #36702).

No, I think it's a stochastically appearing problem. My current guess is that the recently updated nauty does not respect SAGE_FAT_BINARY and thus it depends on CPU details of the runner

Ah, that's easy to fix: add --enable-generic --disable-popcnt to configure args. See: https://github.com/void-linux/void-packages/blob/master/srcpkgs/nauty/template

@tornaria
Copy link
Contributor Author

CI seems to be fixed now (see #36702).

No, I think it's a stochastically appearing problem. My current guess is that the recently updated nauty does not respect SAGE_FAT_BINARY and thus it depends on CPU details of the runner

Ah, that's easy to fix: add --enable-generic --disable-popcnt to configure args. See: https://github.com/void-linux/void-packages/blob/master/srcpkgs/nauty/template

I mean possibly. I didn't test.

Also note --disable-popcnt might be a bit too much. In void we are supposed to support x86_64 baseline which has only SSE2, but I guess all the runners should be at least sse4 + popcnt (iirc nehalem already has popcnt). But the --enable-generic might be important, e.g. if the builder supports avx-512 but the runner does not.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

Thanks a lot! Happening in #36707

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 11, 2023

Not sure if your change to --hide is the right fix. If I understand it correctly, the actual problem is that the code below unconditionally runs is_present even for external features. Here's a fix that changes this by going through AvailableSoftware.__contains__

diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
index 8583d7a447d..297da6133ce 100644
--- a/src/sage/doctest/control.py
+++ b/src/sage/doctest/control.py
@@ -1502,18 +1502,14 @@ class DocTestController(SageObject):
             available_software._allow_external = self.options.optional is True or 'external' in self.options.optional
 
             for h in self.options.hide:
-                try:
+                if h in available_software:
                     i = available_software._indices[h]
-                except KeyError:
-                    pass
-                else:
                     f = available_software._features[i]
-                    if f.is_present():
-                        f.hide()
-                        self.options.hidden_features.add(f)
-                        for g in f.joined_features():
-                            if g.name in self.options.optional:
-                                self.options.optional.discard(g.name)
+                    f.hide()
+                    self.options.hidden_features.add(f)
+                    for g in f.joined_features():
+                        if g.name in self.options.optional:
+                            self.options.optional.discard(g.name)
 
             for o in self.options.disabled_optional:
                 try:

@tornaria
Copy link
Contributor Author

Not sure if your change to --hide is the right fix. If I understand it correctly, the actual problem is that the code below unconditionally runs is_present even for external features. Here's a fix that changes this by going through AvailableSoftware.__contains__

Indeed, that is the problema, and this solution feels much better. I've replaced my commit by yours.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

@tornaria
Copy link
Contributor Author

Doctest failure at https://github.com/sagemath/sage/actions/runs/6837912542/job/18594471128?pr=36696#step:14:29

The logic is not working properly. It seems meataxe is not being hide (in my local test this didn't hit me because I don't have meataxe installed). IOW, I think the reason this gives "5 tests" instead of "4 tests" is because it's actually running the last test (labeled "optional meataxe") in spite of the hidden meataxe.

It's possible that it's another bug so that calling f.hide() before f.is_present() does not work (I can't imagine another cause).

I'm inclined to revert to my previous workaround, since this looks like a slippery slope (cf. a series of unfortunate events vol 10).

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

I'm inclined to revert to my previous workaround

That would be fine with me for getting 10.2 out

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

Downgrading until fixed

@tornaria
Copy link
Contributor Author

Downgrading until fixed

That feels a bit rude. What is the point?

I've reverted the branch to 4a70c1e which is what was tested before.

Copy link

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

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

Downgrading until fixed

That feels a bit rude. What is the point?

Sorry, just so that the doctest failure doesn't show up in the CI runs of all PRs.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

Let's get this in.

@tornaria
Copy link
Contributor Author

Downgrading until fixed

That feels a bit rude. What is the point?

Sorry, just so that the doctest failure doesn't show up in the CI runs of all PRs.

I assumed "blocker" without "positive review" is not automatically merged, is it? If it is, you did the right thing here of course, but it kind of violates the principle of least surprise.

Thanks for the review.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

I assumed "blocker" without "positive review" is not automatically merged, is it?

It is, actually.
The "positive review" label is currently not very stable. That's part of the weakness of this mechanism social side that you mentioned in #36696 (comment)

@tornaria
Copy link
Contributor Author

tornaria commented Nov 12, 2023

I assumed "blocker" without "positive review" is not automatically merged, is it?

It is, actually. The "positive review" label is currently not very stable. That's part of the weakness of this mechanism social side that you mentioned in #36696 (comment)

That's a problem, because when you do something completely correct from a technical point of view, it could still feel a little bit rude from a social point of view, specially if the person involved is not aware of the reason.

Wouldn't it make sense to have a separate label for "hotfixes" ?

Although maybe having a "hotfix" branch (with some person in charge) would be better. Maybe call it main and make it the default branch (so workflows issues can actually be fixed). Or even do it in develop. This might need some coordination with the release manager.

@mkoeppe
Copy link
Contributor

mkoeppe commented Nov 12, 2023

I assumed "blocker" without "positive review" is not automatically merged, is it?

It is, actually. The "positive review" label is currently not very stable. That's part of the weakness of this mechanism social side that you mentioned in #36696 (comment)

That's a problem, because when you do something completely correct from a technical point of view, it could still feel a little bit rude from a social point of view, specially if the person involved is not aware of the reason.

I agree, so the best practice should be to always include a clear comment when relabeling. I've updated https://github.com/sagemath/sage/wiki/Sage-10.2-Release-Tour#open-blocker-prs-are-applied-automatically-in-ci-workflows, take a look

vbraun pushed a commit to vbraun/sage that referenced this pull request Nov 12, 2023
    
Recently I've been getting timeouts in a couple of doctests in
`src/sage/doctest/control.py`, including earlier today when testing
10.2.rc1

This has two causes:
1. The test for the internet feature doesn't catch a `TimeoutError`.
2. These two doctests cause internet feature to be tested.

The first one is clearly a bug: sagemath only expects
`urllib.error.URLError`, but in some cases urllib raises `TimeoutError`.
Arguably a bug in urlib, but easier to fix (or workaround) on our side.
Done in the first commit of this PR.

The second one is IMO a bug, since I didn't use `--optional=internet` no
test should hit internet (in particular, should not test internet
feature).

These two doctests are meant to test options `--hide=all` and
`--hide=optional`. For some reason the semantics of these include
testing for the internet feature. I believe the semantics of these
options should be similar to `--optional=all`, that is, exclude
"external" software  (internet feature is considered "external").

That's what I implemented in the second commit in this PR.

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#36696
Reported by: Gonzalo Tornaría
Reviewer(s):
@soehms
Copy link
Member

soehms commented Nov 13, 2023

Sorry I wasn't able to attend at the weekend.

It's possible that it's another bug so that calling f.hide() before f.is_present() does not work (I can't imagine another cause).

Yes! The sole purpose of calling is_present in control.py is informational, i.e. restricting the content of the Hidden features:... message. Therefore, I will propose a smarter implementation for this in a new PR, which (incidentally) provides more accurate information, i.e. Features that have been hidden instead of Hidden features. More precisely, I will make the feature class count calls to the is_present method in a state where the instance is hidden and present at the same time. This can then be used to filter the message content.

vbraun pushed a commit to vbraun/sage that referenced this pull request Nov 14, 2023
    
<!-- ^^^^^
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 -->
Handling `SAGE_FAT_BINARY` as suggested by @tornaria in
sagemath#36696 (comment)

Disabling popcnt is consistent with the handling of SAGE_FAT_BINARY in
our `primesieve` install script.

Bumping the patch level so it gets recompiled when applied as a CI
hotfix.

<!-- 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. -->

### 📝 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.
- [ ] The description explains in detail what this PR is about.
- [x] 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#36707
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik
@vbraun vbraun merged commit 4d2dd49 into sagemath:develop Nov 14, 2023
33 of 44 checks passed
@soehms
Copy link
Member

soehms commented Nov 20, 2023

Sorry I wasn't able to attend at the weekend.

It's possible that it's another bug so that calling f.hide() before f.is_present() does not work (I can't imagine another cause).

Yes! The sole purpose of calling is_present in control.py is informational, i.e. restricting the content of the Hidden features:... message. Therefore, I will propose a smarter implementation for this in a new PR, which (incidentally) provides more accurate information, i.e. Features that have been hidden instead of Hidden features. More precisely, I will make the feature class count calls to the is_present method in a state where the instance is hidden and present at the same time. This can then be used to filter the message content.

This is #36741!

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 7, 2023
…customizable by repository variable

    
<!-- ^^^^^
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 -->
Instead of using `gh pr checkout`, we obtain the CI fixes via their
patch URLs.

- This is faster because typically we do not have to unshallow the repo
to apply the patches (seconds instead of ~2 minutes)
- Fewer surprises when applied to a PR based on an older release
- Conjecturally uses fewer API queries, helping avoid sagemath#36685

When a repository variable `SAGE_CI_FIXES_FROM_REPOSITORIES` is set in a
fork, it is used instead of the hardcoded sagemath/sage as the source(s)
of the CI fixes; this gives better control in decentralized development.
When set to "none", this also makes it possible to see the "ground
truth", addressing a concern raised in
sagemath#36349 (comment). See
comments at the top of `.ci/merge-fixes.sh` for details.

Also improving the display of details of the merged PRs, as requested by
@tornaria in
sagemath#36696 (comment)

Example runs:
- https://github.com/sagemath/sage/actions/runs/6854931832/job/186389018
59?pr=36686 (here it recovers gracefully from failed merges due to the
10.2.rc1/10.2.rc2 tagging confusions)
- https://github.com/mkoeppe/sage/actions/runs/6855410957/job/1864038039
8#step:3:8 (I have set `SAGE_CI_FIXES_FROM_REPOSITORIES=none` in my fork
-- for testing this PR)

<!-- 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. -->

### 📝 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.
- [x] 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#36686
Reported by: Matthias Köppe
Reviewer(s): Gonzalo Tornaría, Kwankyu Lee, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 9, 2023
…customizable by repository variable

    
<!-- ^^^^^
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 -->
Instead of using `gh pr checkout`, we obtain the CI fixes via their
patch URLs.

- This is faster because typically we do not have to unshallow the repo
to apply the patches (seconds instead of ~2 minutes)
- Fewer surprises when applied to a PR based on an older release
- Conjecturally uses fewer API queries, helping avoid sagemath#36685

When a repository variable `SAGE_CI_FIXES_FROM_REPOSITORIES` is set in a
fork, it is used instead of the hardcoded sagemath/sage as the source(s)
of the CI fixes; this gives better control in decentralized development.
When set to "none", this also makes it possible to see the "ground
truth", addressing a concern raised in
sagemath#36349 (comment). See
comments at the top of `.ci/merge-fixes.sh` for details.

Also improving the display of details of the merged PRs, as requested by
@tornaria in
sagemath#36696 (comment)

Example runs:
- https://github.com/sagemath/sage/actions/runs/6854931832/job/186389018
59?pr=36686 (here it recovers gracefully from failed merges due to the
10.2.rc1/10.2.rc2 tagging confusions)
- https://github.com/mkoeppe/sage/actions/runs/6855410957/job/1864038039
8#step:3:8 (I have set `SAGE_CI_FIXES_FROM_REPOSITORIES=none` in my fork
-- for testing this PR)

<!-- 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. -->

### 📝 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.
- [x] 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#36686
Reported by: Matthias Köppe
Reviewer(s): Gonzalo Tornaría, Kwankyu Lee, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 24, 2024
…kages

    
<!-- ^^^^^
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. -->

This PR implements the suggestion made in
sagemath#36696 (comment).
This means that it introduces a counter in the feature class to detect
the number of events a feature has been asked to be present while it was
hidden. This allows to remove the call of the `is_present` method in
`doctest/control.py`.

In order to test it I ran `sage -tp --all --hide=all`. Ideally this
should give *All tests passed*. But I got two failing files. One of
those was `src/sage/features/databases.py` because
`database_cremona_mini_ellcurve` was detected to be optional even
thought it is a standard package. This is a leftover of
sagemath#35820 which I fix here.

Similarily I got 37 failures in
`src/sage/groups/abelian_gps/abelian_group.py` since
`gap_package_polycyclic` was classified optional even though it is a Gap
standard package since Gap 4.10 (as well as `gap_package_atlasrep`). But
in this case a corresponding fix, i.e.:

```
 def all_features():
-    return [GapPackage("atlasrep", spkg="gap_packages"),
+    return [GapPackage("atlasrep", spkg="gap_packages",
type='standard'),
             GapPackage("design", spkg="gap_packages"),
             GapPackage("grape", spkg="gap_packages"),
             GapPackage("guava", spkg="gap_packages"),
             GapPackage("hap", spkg="gap_packages"),
-            GapPackage("polycyclic", spkg="gap_packages"),
+            GapPackage("polycyclic", spkg="gap_packages",
type='standard'),
             GapPackage("qpa", spkg="gap_packages"),
             GapPackage("quagroup", spkg="gap_packages")]
```

is not the correct way (it gives `UserWarning: Feature
gap_package_polycyclic is declared standard, but it is provided by
gap_packages, which is declared optional in SAGE_ROOT/build/pkgs`). I
would say, the correct fix would be to remove both Gap packages from the
`all_features` list and erase the corresponding *optional tags*  in
`permgroup_named.py`, `distance_regular.pyx`, `abelian_aut.py`,
`abelian_group.py` and `abelian_group_gap.py`. If you agree I will open
another PR for this.


BTW: there seem to be more packages with ambiguous type (detected with
current Docker image):

```
Digest:
sha256:790197bb223bd7e20b0a2e055aa7b4c5846dc86d94b2425cd233cb6160a5b944
Status: Downloaded newer image for sagemath/sagemath:develop
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.2.rc4, Release Date: 2023-11-17                │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: from sage.features.all import all_features
sage: [(f, f._spkg_type()) for f in all_features() if f.is_present() and
f._spkg_type() != 'standard']
[(Feature('sage.misc.cython'), 'optional'),
 (Feature('database_cremona_mini_ellcurve': Cremona's database of
elliptic curves),
  'optional'),
 (Feature('gap_package_atlasrep'), 'optional'),
 (Feature('gap_package_polycyclic'), 'optional'),
 (Feature('sage.libs.ecl'), 'optional'),
 (Feature('sage.libs.gap'), 'optional'),
 (Feature('sage.libs.singular'), 'optional'),
 (Feature('sage.numerical.mip'), 'optional')]
sage:
sage: [(f, f._spkg_type()) for f in all_features() if not f.is_present()
and f._spkg_type() == 'standard']
[(Feature('sagemath_doc_html'), 'standard'), (Feature('sage.sat'),
'standard')]
```


### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] 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#36741
Reported by: Sebastian Oehms
Reviewer(s): Matthias Köppe, Sebastian Oehms
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.

4 participants