-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Remove the "-r" option in calling gap in the pexpect interface #27878
Comments
This comment has been minimized.
This comment has been minimized.
Commit: |
Branch: u/fbissey/gap_r |
comment:2
Trivial change. New commits:
|
Author: François Bissey |
Reviewer: Steven Trogdon |
comment:3
Here I have
The doctest Hopefully the positive review will prompt someone to notice if there is any side effect. |
comment:4
also
|
comment:5
I don't quite understand the intention behind this change. When using the pexpect interface to GAP, which much of Sage still (sadly) relies on (I am making progress fixing that) we want the |
comment:6
ISTM the problem is not that we pass |
comment:7
My problem with putting |
comment:8
Indeed, as a user, I would be annoyed if I could not use from Sage the GAP packages I installed in my gap directory (e.g. by GAP's PackageManager). The GAP devs have decided to include the user's .gap directory by default; I would tend to follow that decision to have a GAP that's as close as possible from a normal gap. That being said, maybe we should indeed set -r whenever running Sage's test, to make them less context-dependent? With the annoying side effect that behavior may change between tests and normal usage. |
Changed branch from u/fbissey/gap_r to |
Changed commit from |
comment:12
As I wrote on the other ticket (#27913):
The problem is there is a tension here between Sage embedding GAP for its own uses, and users of Sage wanting to use GAP from within Sage and have it work the same as if they used GAP directly. I think for the latter case, users should initialize their own GAP via the pexpect interface, and perhaps we should change things so that it's not necessarily the same GAP that Sage is using internally. In the latter case I've also made very good progress getting the pexpect interface out of Sage's internal use cases (in this case for permutation groups) and porting it to libgap. I'll have some tickets for that soon; I've just been very otherwise occupied. |
comment:13
In any case, while this clearly needs to be discussed further the right answer is definitely not to just disable use of I agree with nthiery that one way or other ignoring the user's |
comment:14
I used the occasion of being in St Andrews to discuss the matter with GAP developers (namely Alex Konovolov and Michael Torpey). When running GAP tests, they disable the
Cheers, |
comment:18
That's nice. So it we can expect things to settle down slowly on that front. We just have to bear it for a little while. So now we need a mechanism to insert |
comment:19
OK wanting some feedback on this. So I still make the default to be run without New commits:
|
Changed branch from |
Commit: |
comment:20
Thanks François! This sounds very reasonable to me. There remains to force For the option configuration, I am hesitating between two approaches. With the current commits, An alternative would be to provide a mean for the user to configure the arguments to the gap command; something like What do you think? |
comment:21
I am not sure. First we are only talking about the pexpect interface in this ticket, Erik already mentioned there is currently no way to force libgap to ignore Lastly, I introduced an option because this is something we want to have some programmatic control over. But it could have been achieved some different way. The documentation just over the one I introduced for
This could be used to pass any options to gap
rather than a gap in a different path. |
comment:22
You have to be clear here what you mean by "GAP in Sage". The GAP interpreter included in the Sage distribution should work as similarly as possibly to a GAP distributed by the GAP project. I.e. when you run Then there's the use of GAP within the Sage library itself which as I've mentioned has competing use-cases: the GAP interface in Sage used directly by users as an interface to GAP without leaving the Sage interpreter (B), and then there's GAP used directly by Sage for internal use (C). This principle applies to A and B, but emphatically not for C (even if there are ostensibly benefits to doing so, such as packages that provide alternative implementations of some algorithms that happen to be used by Sage; if that capability exists it should be enabled explicitly through Sage). I think that the |
comment:23
If I had my way I would also be more aggressive about controlling exactly what GAP packages are loaded by the GAP interpreter used by Sage, because my experience has been that random GAP packages being loaded can lead to very difficult to trace bugs or differences in results. |
comment:24
Replying to @nthiery:
Yep--in particular autoloading of the xgap package has been a real problem for Sage's pexpect interface. |
comment:25
diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
index a7a9fab..43c957b 100644
--- a/src/sage/interfaces/gap.py
+++ b/src/sage/interfaces/gap.py
@@ -150,6 +150,12 @@ Use this code to change which GAP interpreter is run. E.g.,
import sage.interfaces.gap
sage.interfaces.gap.gap_cmd = "/usr/local/bin/gap"
+Disabling the use of ~/.gap - no personal packages or settings used.
+
+::
+ import sage.interfaces.gap
+ sage.interfaces.gap.no_dotgap = True
+ I might be missing something (or maybe this is only a proposal?) but this doesn't look right. The instructions above would only create a global variable
to initialize a GAP interface with that option set. I'm also not sure about the name Only the GAP interface used internally for Sage would set For libgap we're in a bit of a bind, but I think that the most important use case for the libgap interface in Sage is for interfacing with GAP internally (to replace the pexpect interface as much as possible), so this should disable .gap by default. |
comment:26
Replying to @embray:
Now that's a painful flashback from before you started being involved with sage Erik. It took me a while to figure out what was happening to my sage-on-gentoo install where I had installed the whole gap distribution. I'll concede that your point (C) sounds reasonable but has the after taste of the package you customise specifically for sage (or some other software). Off course we want to move all of the use of point (C) to libgap I would imagine , which leaves the pexpect interface at your point (B). But having upstream giving you the tools to get to (C) would be nice. I'll note that gap packages have the concept of recommended packages. Those are not dependencies but considered helpful but automatically loaded on presence which is harmful in our case (xgap is recommended in several packages). |
comment:27
Replying to @embray:
Proposal at this stage. I must say I have been a bit confused and modeled my documentation on the wrong model now that I look back at it. The name. At first I was going for |
comment:28
I am trying to answer too fast. I see you are trying to avoid negative settings and I can understand that. I guess we just have to bear the negative use internally. |
comment:29
I am testing an alternative based on my comments. |
comment:30
Replying to @kiwifb:
Yeah; the sense of the command-line parameter is negative, so this can be documented internally; but that doesn't mean the user-interface in Sage needs to be as well :) |
comment:31
Replying to @kiwifb:
Indeed it would be nice; but it's admittedly not easy. I've been watching the efforts over the last few years to make multiple parallel embedded Python interpreters possible from libpython, and while it mostly works now it was not a trivial effort. I think it's maybe a little easier for GAP than it was for Python, especially with HPC-GAP, where most of the important interpreter globals have been moved into thread-local variables. But it's still non-trivial, especially when you involve things like C extension modules :/ It's something I would gladly help work on if I had the time to do so, which I don't (and I doubt most of the GAP developers do either, even if it would likely be a desirable goal). |
comment:32
The other complication to this that I haven't addressed yet is that GAP should probably also load a different workspace (if any) for when it's running with or without the .gap directory loaded, or this could lead to even more confusing inconsistencies :/ Perhaps the arguments passed when starting GAP should be hashed into the hash in the workspace filename, or something? I'm not confident about this part as I still don't fully understand how GAP workspaces work (just enough to know that they can definitely be influenced heavily by what pakages and globals are loaded). |
comment:33
Replying to @embray:
I see now, after experimenting with this, that there is a technical challenge to it (I still think it is the right approach in principle). The problem is that although it is possible to have multiple Gap interpreter instances, much of the code in Sage makes inconsistent assumptions that you are only using the "main" instance, currently the global variable named For example, SageObjects can have both a The problem (or one of them) is that For this reason, among others, I would propose that we keep the current status quo w.r.t. disabling |
comment:34
All right. I think it is also important to have the doctest that started it all to be fixed quickly. |
comment:35
Replying to @embray:
In my research code (and in packages such as sage-semigroups), I really need to be using libgap (rather than a pexpect interface) for efficiency. I believe that's a common use case. I see the rationale for aiming two separate gap instances, an incorruptible one for internal use, and a more flexible one for direct access by users. I don't know whether that's technically feasible at this stage though with libgap. Also we still want to be able to pass gap objects efficiently from internal code to user code. |
comment:36
the sooneer a complete switch to libgap happens in sagelib, the better. I don't quite understand what "pass gap objects efficiently from internal code to user code" means here. IMHO this all fine in libgap, no? |
comment:37
Yes, indeed!
Currently yes, indeed. Now assume we were to have two separate instances of libgap, one for sagelib and one user-facing, to protect the former from corruption by e.g. user packages; then, it may become costly to move one object from one instance to the other. |
comment:38
I'm not sure many instances of libgap loaded as python extensions are technically feasible; this seem to mean that one would have to mangle names in the dlls to avoid clashes etc. What might be feasible are several libgap workspaces. |
comment:39
Tickets still needing working or clarification should be moved to the next release milestone at the soonest (please feel free to revert if you think the ticket is close to being resolved). |
comment:40
I am opening a new ticket to fix the doctest in |
Currently the pexpect interface to gap call gap with the "-r" option.
From
sage/interfaces/gap.py
This is a remnant of gap 4.8 and under where it enabled gap to be started in a quieter mode if I am not mistaken. There is no visible effect in starting gap with or without "-r" in gap 4.10 and over.
The only effect is more subtle.
~/.gap
and its equivalent on non linux system is not added to the list of paths where gap looks for packages. This means in turn that the optionignore_dot_gap
in the functionall_installed_packages
(insage/tests/gap_packages.py
) is meaningless when a pexpect gap instance is selected. And a doctest introduced in #27681 will fail if you have something in~/.gap
.Component: interfaces
Author: François Bissey
Branch/Commit: u/fbissey/gap_r @
474b365
Reviewer: Steven Trogdon
Issue created by migration from https://trac.sagemath.org/ticket/27878
The text was updated successfully, but these errors were encountered: