Summary: | Cantor hangs at "Initializing Session" when choosing Sage backend (Sage version 7.6) | ||
---|---|---|---|
Product: | [Applications] cantor | Reporter: | Jacob <doublejinitials> |
Component: | sage-backend | Assignee: | Alexander Semke <alexander.semke> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alexander.semke, alexanderrieder, arojas, hackitforfun, kishore96, warquark |
Priority: | NOR | ||
Version: | 16.12 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/cantor/f071930f73d9c73fcf720f4f105a915810c3cb58 | Version Fixed In: | 18.04.3 |
Sentry Crash Report: |
Description
Jacob
2017-01-23 20:22:16 UTC
I can not find Sage 7.5 to download. Is this bug present when you use Sage 7.6? I can confirm sage 7.6 and cantor 17.04 not working in arch linux (In reply to hackitforfun from comment #2) > I can confirm sage 7.6 and cantor 17.04 not working in arch linux Thanks hackitforfun I will give a look in it. I can confirm the bug. This is caused by the ipython 5.0 upgrade. There are (at least) two issues here: - Ipython 5.0 uses prompt_toolkit instead of readline. By default it has prompt and syntax highlighting enabled, which breaks the Cantor parser (it can't interpret the ANSI codes correctly). This could be fixed on the Sage side by forcing it to run ipython with the --simple-prompt flag - Even with the --simple-prompt flag, ipython 5.0 doesn't accept multiline input anymore. This breaks passing the initialization commands to Sage. This is being tracked upstream at https://github.com/ipython/ipython/issues/9816 (In reply to Antonio Rojas from comment #5) > This is caused by the ipython 5.0 upgrade. There are (at least) two issues > here: > > - Ipython 5.0 uses prompt_toolkit instead of readline. By default it has > prompt and syntax highlighting enabled, which breaks the Cantor parser (it > can't interpret the ANSI codes correctly). This could be fixed on the Sage > side by forcing it to run ipython with the --simple-prompt flag > > - Even with the --simple-prompt flag, ipython 5.0 doesn't accept multiline > input anymore. This breaks passing the initialization commands to Sage. This > is being tracked upstream at https://github.com/ipython/ipython/issues/9816 The multiline input issue seems to be fixed (https://github.com/ipython/ipython/pull/10606). What changes would I need to make to my installation of sage and/or cantor to get it to run ipython with the --simple-prompt option? With Cantor 17.08.3 and sage 8.0 on Arch linux, if I run 'cantor -b sage' from a terminal, there is no terminal output, and Cantor opens, but keeps on showing the 'initialising Session' dialog box. (In reply to Kishore Gopalakrishnan from comment #6) > (In reply to Antonio Rojas from comment #5) > > With Cantor 17.08.3 and sage 8.0 on Arch linux, if I run 'cantor -b sage' > from a terminal, there is no terminal output, and Cantor opens, but keeps on > showing the 'initialising Session' dialog box. The communication with Sage was made more stable in 18.04. Can you please check the current release? Do you still have problems with Sage? No, this still doesn't work. Major changes are needed to work with newer versions of Sage (newer than 2 years) in Sage itself (so that it allows running ipython in simple prompt mode), in ipython (i think those are already merged) and in Cantor (to adapt to latest ipython versions using prompt_toolkit instead of readline). (In reply to Alexander Semke from comment #7) > (In reply to Kishore Gopalakrishnan from comment #6) > > (In reply to Antonio Rojas from comment #5) > > > > With Cantor 17.08.3 and sage 8.0 on Arch linux, if I run 'cantor -b sage' > > from a terminal, there is no terminal output, and Cantor opens, but keeps on > > showing the 'initialising Session' dialog box. > The communication with Sage was made more stable in 18.04. Can you please > check the current release? Do you still have problems with Sage? With Cantor 18.04 and sage version 8.1 on Arch Linux, it now indefinitely has 'calculating...' displayed in the status bar after I enter any sage command in a cell and press shift+enter. No results are displayed, even if I do simple stuff like '2+3 <shift+enter>'. I.e., the sage backend is still completely unusable, although it now seems to start up without any obvious error dialog displayed. I suspect, that this is still a problem with multiline input with ipython. I have tested sage backend with changed process ('maxima', 'octave-cli', 'mathjs', 'python', 'nodejs') and all of them read multiline input from backend correctly and only ipython and sage read only first line of the multiline input. Could anybody confirm, that changing in 262 line of sage of this exec sage-ipython "$@" -i by this exec sage-ipython --simple-prompt "$@" -i solve the login sage problem? (In reply to Nikita Sirgienko from comment #11) > Could anybody confirm, that changing in 262 line of sage of this > > exec sage-ipython "$@" -i > > by this > > exec sage-ipython --simple-prompt "$@" -i > > solve the login sage problem? It does, indeed. (Sage 8.2, ipython 5.6.0) (In reply to Antonio Rojas from comment #12) > It does, indeed. (Sage 8.2, ipython 5.6.0) Well, thanks for report. Now, this changes in sage file fix this bug, but you lose color in sage output. So, I create feature request ticket for Sage: https://trac.sagemath.org/ticket/25363 If the ticket will be accepted (for example, in sage 8.3), I add version dependent fix, which will be fix sage backend for sage >= 8.3 (but sage < 8.3 still be broken) without color losing in sage output. I also maybe report prompt_toolkit about problem with multiline input for (pseudo)terminal devices. However, it also fix the sage backend only for future versions Theoretically, If there is way to run 'sage-ipython' directly, without sage bash file, I guess, that I could fix this bug for all sage versions, but I am not sure. (In reply to Nikita Sirgienko from comment #13) > Theoretically, If there is way to run 'sage-ipython' directly, without sage > bash file, I guess, that I could fix this bug for all sage versions, but I > am not sure. Running sage-ipython directly should work fine, the problem is finding where the binary is installed. You can get the location of the SAGE_LOCAL dir with sage -c "from sage.env import SAGE_LOCAL; print SAGE_LOCAL" and the sage-ipython should be located in $SAGE_LOCAL/bin (In reply to Antonio Rojas from comment #14) > (In reply to Nikita Sirgienko from comment #13) > > Theoretically, If there is way to run 'sage-ipython' directly, without sage > > bash file, I guess, that I could fix this bug for all sage versions, but I > > am not sure. > > Running sage-ipython directly should work fine, the problem is finding where > the binary is installed. You can get the location of the SAGE_LOCAL dir with > > sage -c "from sage.env import SAGE_LOCAL; print SAGE_LOCAL" > > and the sage-ipython should be located in $SAGE_LOCAL/bin $ sage -c "from sage.env import SAGE_LOCAL; print SAGE_LOCAL" gives '/usr/' for me, and sage-ipython locate in '/usr/share/sagemath/bin', so it's not so simple. That worse, sage-ipython fails for me with this trackeback: Traceback (most recent call last): File "./sage-ipython", line 7, in <module> from sage.repl.interpreter import SageTerminalApp File "/usr/lib/python2.7/dist-packages/sage/repl/interpreter.py", line 112, in <module> from sage.env import SAGE_LOCAL File "/usr/lib/python2.7/dist-packages/sage/env.py", line 123, in <module> _add_variable_or_fallback('SAGE_ETC', opj('$SAGE_LOCAL', 'etc')) File "/usr/lib/python2.7/dist-packages/sage/env.py", line 103, in _add_variable_or_fallback value = sep.join(components) TypeError: sequence item 0: expected string, NoneType found And I don't understand, how I can fix it and run sage-ipython correctly. I guess, that sage bash file set up environment for sage-ipython, and we need also do it before directly run sage-ipython. (In reply to Nikita Sirgienko from comment #13) > (In reply to Antonio Rojas from comment #12) > > It does, indeed. (Sage 8.2, ipython 5.6.0) > Well, thanks for report. > Now, this changes in sage file fix this bug, but you lose color in sage > output. > So, I create feature request ticket for Sage: > https://trac.sagemath.org/ticket/25363 > If the ticket will be accepted (for example, in sage 8.3), I add version > dependent fix, which will be fix sage backend for sage >= 8.3 (but sage < > 8.3 still be broken) without color losing in sage output. > > I also maybe report prompt_toolkit about problem with multiline input for > (pseudo)terminal devices. However, it also fix the sage backend only for > future versions > > Theoretically, If there is way to run 'sage-ipython' directly, without sage > bash file, I guess, that I could fix this bug for all sage versions, but I > am not sure. Wouldn't it be better if the main sage bash script would simply forward the CLI parameters to sage-ipython. With this we'd simply always call sage with --simple-promt or the user will provide this parameter explicitly in cantor settings for sage where the user already has to specify the path for sage. With this solution it would be up to the sage's user/frontend to specify this parameter or not and there is no need to always use it as proposed in your trac ticket. (In reply to Alexander Semke from comment #16) > Wouldn't it be better if the main sage bash script would simply forward the > CLI parameters to sage-ipython. With this we'd simply always call sage with > --simple-promt or the user will provide this parameter explicitly in cantor > settings for sage where the user already has to specify the path for sage. > With this solution it would be up to the sage's user/frontend to specify > this parameter or not and there is no need to always use it as proposed in > your trac ticket. Alexender, I reread my ticket message and maybe I was not quite accurate. The ticket suggest add new option (--simple-prompt), that be passed to ipython, like another ipython forward options for sage. So if you run 'sage --simple-prompt' you have sage with ipython with --simple-prompt option and Sage backend could work with sage output. If you don't specify this option, sage don't forward pass '--simple-prompt' to ipython and then ipython starts with default input handler: prompt_tookit. Sage don't send -gthread, -qthread, -q4thread, -wthread and -pylab always to sage-ipython. Sage do it, only if user specify corresponding options. And my ticket just expand list of this options by adding new option (and new corresponding option too). (In reply to Nikita Sirgienko from comment #17) > Alexender, I reread my ticket message and maybe I was not quite accurate. > The ticket suggest add new option (--simple-prompt), that be passed to > ipython, like another ipython forward options for sage. > So if you run 'sage --simple-prompt' you have sage with ipython with > --simple-prompt option and Sage backend could work with sage output. > If you don't specify this option, sage don't forward pass '--simple-prompt' > to ipython and then ipython starts with default input handler: prompt_tookit. > Sage don't send -gthread, -qthread, -q4thread, -wthread and -pylab always to > sage-ipython. Sage do it, only if user specify corresponding options. And my > ticket just expand list of this options by adding new option (and new > corresponding option too). Ok, got it now. Thanks for the clarification. Now, on master branch, Cantor have patch for sage login for versions 8.1 and 8.2 (I think the patch also can work with future 8.3 version) I will want to add this patch in 18.04.3 release, but it will be usefull, if this patch will be tested before release not only by developers. Could anybody with Sage 8.1 or 8.2 builds Cantor from source code and confirm, that login starts work correctly? (In reply to Nikita Sirgienko from comment #19) > Now, on master branch, Cantor have patch for sage login for versions 8.1 and > 8.2 (I think the patch also can work with future 8.3 version) > I will want to add this patch in 18.04.3 release, but it will be usefull, if > this patch will be tested before release not only by developers. > Could anybody with Sage 8.1 or 8.2 builds Cantor from source code and > confirm, that login starts work correctly? Cantor built from source works on Arch with sagemath version 8.2. Git commit f071930f73d9c73fcf720f4f105a915810c3cb58 by Nikita Sirgienko. Committed on 01/07/2018 at 18:16. Pushed by sirgienko into branch 'Applications/18.04'. Fix broken sage login for Sage versions greater, than 8.0 (8.1, 8.2, 8.3, etc.) and set version 8.1 and 8.2 as recommends. FIXED-IN: 18.04.3 M +5 -0 src/backends/sage/CMakeLists.txt A +13 -0 src/backends/sage/cantor-execsage M +1 -1 src/backends/sage/sagebackend.cpp M +49 -20 src/backends/sage/sagesession.cpp M +1 -0 src/backends/sage/sagesession.h https://commits.kde.org/cantor/f071930f73d9c73fcf720f4f105a915810c3cb58 |