Repository navigation
Description
Currently the pexpect interface to gap call gap with the "-r" option.
From sage/interfaces/gap.py
gap_cmd = "gap -r"
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.
fbissey@moonloop ~ $ gap
┌───────┐ GAP 4.10.1 of 23-Feb-2019
│ GAP │ https://www.gap-system.org
└───────┘ Architecture: amd64
Configuration: gmp 6.1.2, readline
Loading the library and packages ...
Packages: AClib 1.3.1, Alnuth 3.1.0, AtlasRep 1.5.1, AutoDoc 2019.02.22, AutPGrp 1.10, CRISP 1.4.4, Cryst 4.1.18, CrystCat 1.1.8, CTblLib 1.2.2, FactInt 1.6.2, FGA 1.4.0,
GAPDoc 1.6.2, IO 4.5.4, IRREDSOL 1.4, LAGUNA 3.9.2, Polenta 1.3.8, Polycyclic 2.14, PrimGrp 3.3.2, RadiRoot 2.8, ResClasses 4.7.1, SmallGrp 1.3, Sophus 1.24,
TomLib 1.2.7, TransGrp 2.0.4, utils 0.61
Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap>
fbissey@moonloop ~ $ gap -r
┌───────┐ GAP 4.10.1 of 23-Feb-2019
│ GAP │ https://www.gap-system.org
└───────┘ Architecture: amd64
Configuration: gmp 6.1.2, readline
Loading the library and packages ...
Packages: AClib 1.3.1, Alnuth 3.1.0, AtlasRep 1.5.1, AutoDoc 2019.02.22, AutPGrp 1.10, CRISP 1.4.4, Cryst 4.1.18, CrystCat 1.1.8, CTblLib 1.2.2, FactInt 1.6.2, FGA 1.4.0,
GAPDoc 1.6.2, IO 4.5.4, IRREDSOL 1.4, LAGUNA 3.9.2, Polenta 1.3.8, Polycyclic 2.14, PrimGrp 3.3.2, RadiRoot 2.8, ResClasses 4.7.1, SmallGrp 1.3, Sophus 1.24,
TomLib 1.2.7, TransGrp 2.0.4, utils 0.61
Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap>
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 option ignore_dot_gap in the function all_installed_packages (in sage/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
Activity
kiwifb commentedon May 28, 2019
kiwifb commentedon May 28, 2019
Commit:
8958e4dkiwifb commentedon May 28, 2019
Branch: u/fbissey/gap_r
kiwifb commentedon May 28, 2019
Trivial change.
New commits:
8958e4dremove extraneous -r from gap_cmdkiwifb commentedon May 28, 2019
Author: François Bissey
strogdon commentedon May 28, 2019
Reviewer: Steven Trogdon
strogdon commentedon May 28, 2019
Here I have
The doctest
./sage -t --long src/sage/tests/gap_packages.py, with this branch, passes which would fail without the fix.Hopefully the positive review will prompt someone to notice if there is any side effect.
dimpase commentedon May 28, 2019
also
32 remaining items
embray commentedon Jun 7, 2019
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 :)
embray commentedon Jun 7, 2019
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).
embray commentedon Jun 7, 2019
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).
embray commentedon Jun 7, 2019
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
gap.For example, SageObjects can have both a
_gap_method, and a_gap_init_method. The former returns the object's GAP representation wrapped in aGapElement. It can take an optionalGapinstance as an argument: The GAP interpreter instance in which to create the element. The latter,_gap_init_, only returns a string of GAP code to be evaluated in the GAP interpreter to instantiate the object. This is consistent with how other interfaces work.The problem (or one of them) is that
_gap_init_does not take an optionalGapinstance, and just always assumes you're using the "main"gapinstance. This can lead to all kinds of inconsistencies, as sometimes the_gap_init_methods themselves query the Gap instance (e.g. what is the current$sagevariable number) for details on how to evaluate the object. So if you use one Gap instance in the_gap_init_call, but then pass the result of that call to a differentGapinstance it is not guaranteed to work.For this reason, among others, I would propose that we keep the current status quo w.r.t. disabling
.gapby default for now, but add theenable_dotgapoption, so that it's easy to create a newGapinstance that uses it. Then change the default behavior only once further refactoring is done to maintain better separation between the (B) and (C) use cases.kiwifb commentedon Jun 10, 2019
All right. I think it is also important to have the doctest that started it all to be fixed quickly.
nthiery commentedon Jun 11, 2019
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.
dimpase commentedon Jun 11, 2019
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?
nthiery commentedon Jun 11, 2019
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.
dimpase commentedon Jun 11, 2019
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.
embray commentedon Jun 14, 2019
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).
kiwifb commentedon Jul 23, 2019
I am opening a new ticket to fix the doctest in
gap_packagesunder all scenario #28233. Let's keep this ticket for the serious stuff about how we are supposed to run gap.