ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 01 Mar 2015 00:37:26 +0100Using from Python (breaking the monolith)https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/Sage contains a many libraries (or Cython wrappers to libraries) that would be useful in other Python programs (to me anyway). So I would like to use some of them isolated from within Python programs. I understand that this is not easily possible. Is it still possible at all? This is actually not so much about how to use Sage from Python but about carving pieces out of the monolithic structure of Sage. (At the moment it seems like I have to implement all kinds of stuff from scratch which seems silly since much of it is already there.)
Concretely: Among other things I want to compute with matrices that have entries in rings of Laurent series over finite fields.
Now you will say: just write a Sage script rather than a Python script. So here are my reasons to prefer Python with isolated libraries (in increasing order of importance):
1. Practical: putting the full 1.5 GB (?) of sage in home on my office computer pushes me beyond the quota limit.
2. Extendability: Not everything I need is available in Sage. But if I want to extend the code I will have do wade through the Sage code making changes here and there and then defend them against updates (and maybe adjust the build process). This seems like a lot of hassle.
3. Verifiability: At some point my code will (hopefully) produce some solutions to some problem and I will want to say (maybe in a published paper) "these are solutions and they are all solutions to the problem". Then critical minds will not believe me and all I can say is: "Well, you only have to check the correctness of my 200 lines of code (say). -- Plus of course everything in the Sage git repository, plus the libraries it depends on (at least the part that my code uses, which you will have to work out for yourself); and make sure to patch in these changes I made here and there!"Sat, 28 Feb 2015 10:34:49 +0100https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/Comment by Luca for <p>Sage contains a many libraries (or Cython wrappers to libraries) that would be useful in other Python programs (to me anyway). So I would like to use some of them isolated from within Python programs. I understand that this is not easily possible. Is it still possible at all? This is actually not so much about how to use Sage from Python but about carving pieces out of the monolithic structure of Sage. (At the moment it seems like I have to implement all kinds of stuff from scratch which seems silly since much of it is already there.)</p>
<p>Concretely: Among other things I want to compute with matrices that have entries in rings of Laurent series over finite fields.</p>
<p>Now you will say: just write a Sage script rather than a Python script. So here are my reasons to prefer Python with isolated libraries (in increasing order of importance):</p>
<ol>
<li>Practical: putting the full 1.5 GB (?) of sage in home on my office computer pushes me beyond the quota limit.</li>
<li>Extendability: Not everything I need is available in Sage. But if I want to extend the code I will have do wade through the Sage code making changes here and there and then defend them against updates (and maybe adjust the build process). This seems like a lot of hassle.</li>
<li>Verifiability: At some point my code will (hopefully) produce some solutions to some problem and I will want to say (maybe in a published paper) "these are solutions and they are all solutions to the problem". Then critical minds will not believe me and all I can say is: "Well, you only have to check the correctness of my 200 lines of code (say). -- Plus of course everything in the Sage git repository, plus the libraries it depends on (at least the part that my code uses, which you will have to work out for yourself); and make sure to patch in these changes I made here and there!"</li>
</ol>
https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/?comment=25968#post-id-25968I fully agree with you, and I am certainly not the only one. Unfortunately, Sage is a monolith, and there is little you can do right now. Making Sage more modular is one of the goals of this submitted EU project <https://github.com/sagemath/grant-europe>, that will hopefully begin next september.Sat, 28 Feb 2015 16:33:00 +0100https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/?comment=25968#post-id-25968Answer by vdelecroix for <p>Sage contains a many libraries (or Cython wrappers to libraries) that would be useful in other Python programs (to me anyway). So I would like to use some of them isolated from within Python programs. I understand that this is not easily possible. Is it still possible at all? This is actually not so much about how to use Sage from Python but about carving pieces out of the monolithic structure of Sage. (At the moment it seems like I have to implement all kinds of stuff from scratch which seems silly since much of it is already there.)</p>
<p>Concretely: Among other things I want to compute with matrices that have entries in rings of Laurent series over finite fields.</p>
<p>Now you will say: just write a Sage script rather than a Python script. So here are my reasons to prefer Python with isolated libraries (in increasing order of importance):</p>
<ol>
<li>Practical: putting the full 1.5 GB (?) of sage in home on my office computer pushes me beyond the quota limit.</li>
<li>Extendability: Not everything I need is available in Sage. But if I want to extend the code I will have do wade through the Sage code making changes here and there and then defend them against updates (and maybe adjust the build process). This seems like a lot of hassle.</li>
<li>Verifiability: At some point my code will (hopefully) produce some solutions to some problem and I will want to say (maybe in a published paper) "these are solutions and they are all solutions to the problem". Then critical minds will not believe me and all I can say is: "Well, you only have to check the correctness of my 200 lines of code (say). -- Plus of course everything in the Sage git repository, plus the libraries it depends on (at least the part that my code uses, which you will have to work out for yourself); and make sure to patch in these changes I made here and there!"</li>
</ol>
https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/?answer=25981#post-id-25981Hello,
Right. This is a problem of Sage. But it would be a tremendous amount of work to isolate a part of Sage (not talking about the fact that you would also need to maintain it). Some people (including me) are in favour of something more modular. But the focus is currently not on having some part of Sage isolated but having Sage isolated from its components (i.e. third party softwares and libraries such as GAP, Pari/GP, mpir, etc).
And some comments about your reasons
1. You are definitely right! If you are using (Gentoo)[https://www.gentoo.org/] it is already possible to use Sage over your system. Which means that you only have to install a lot of standard packages (singular, GAP, etc) + the Sage library. A lot of effort is currently done to have the same in (Debian)[https://www.debian.org/] but it is not yet ready. If Sage is finally usable directly on your system this would reduce dramatically the size (it is only ~63M of source code). You are very welcome to help. Sage is an open source project which means that it is mainly developed by its users.
2. It is very simple to have your own Python/Cython files outside of Sage as an independent Sage code. A priori there is no need to dig into Sage source code. But it of course depends on your needs. You might also want to contribute to Sage source code. It is how Sage gets better.
3. If you really want something proven you should neither use Sage nor Python (except if you can get a certificate of your computation). If you just want a strong belief that the result is the one you have, you can just do as everyone is doing within Sage: write careful doctests for each piece of code which go through all possible branch of the algorithm. And possibly add some randomized testing.Sun, 01 Mar 2015 00:37:26 +0100https://ask.sagemath.org/question/25964/using-from-python-breaking-the-monolith/?answer=25981#post-id-25981