Open davidblitz opened 4 years ago
Let me start by saying that the installation should not take that long. Recently the packaging system of Sage had changed significantly, so I think the installation failed, but that Sage is not picking this up.
The easiest way to quickly start using conjecturing on Sage is to use the instructions for CoCalc locally on your own computer. This version is not specifically for CoCalc, and can be used on each Sage installation. The only limitations with this version is that you have to start Sage from the folder where the expressions executable is located.
I will try to update the packaging for Sage to bring it up to date as soon as possible.
About your other question: decoupling this from Sage will require more work. We strongly make use of Sage's ability to work with expressions. Turning this into a Python library would require us to reimplement this ourselves. The only possibility would be a Python library that produces the conjectures as textual strings. That would not require that much work.
So I just cloned the repo, built the c code, put the expressions binary in the SAGE_ROOT and tried to import conjecturing. However, when calling
conj = conjecturing.conjecture(objects, invariants, 10, verbose=True)
first I got an encoding error.
I fixed this by adding this encoding argument in line 407 of the conjecturing.py
file:
sp = subprocess.Popen(command, shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True, encoding='utf-8')
Then I got a broken pipe error and that's where I am now.
One more question out of curiosity: wouldn't it be easier to write python wrappers for some c functions and then call them in the python code instead of creating subprocesses?
Ok. The encoding is probably a consequence of Sage switching to Python 3. I still use an old version that is still on Python 2, so I hadn't noticed this issue. I'll solve it in the coming week. If your using the local version then you shouldn't clone the master branch but clone the cocalc branch instead. The difference is the path for the C executable.
You can just change the path in the conjecturing.py file. You just need to change expressions
to ./expressions
I will look at how to write Python wrappers for the C functions. I usually find this approach of subprocesses easier, because you don't have the hassle of communicating between the two programming languages. You just read the output of one program as if it is a file. I also have to say that I had very little Python experience at the moment that I wrote this code. I'm certain that many solutions I came up with can easily be improved so any comment is more than welcome.
If you change expressions
to ./expressions
, then of course the module will only work if Sage is executed from the folder containing the expressions executable. 😉
I finally got some conjectures :))
My solution became quite hacky, though. It involved adding this in line 465 in conjecturing.py
:
sout, serr = sp.communicate()
Anyway, I got some interesting conjectures and it's fun playing around with conjecturing. So thanks for the support!
Thanks. It might be that subprocess changed with the change to Python 3.
I'm currently trying to install Sage 9.0 in order to address these issue, but it appears that I will first need to update my operating system. I will look at these issues during the coming week. Thanks for bringing them to my attention and I hope you manage to prove some of the interesting conjectures. :wink:
I think I found the remaining issues with Python 3. I'm still working on getting the packaging fixed.
I installed SageMath 9.0 for Ubuntu 16.04 by unzipping the tarball (and subsequently calling ./sage once).
Then I followed these steps: https://github.com/nvcleemp/conjecturing/tree/master/spkg
The last step:
./sage -i conjecturing
seems to trigger a long compilation process. Right now, I'm at minute 15 on a two year old machine which is probably too long for many potential users.I'd be very happy if this package were more easy to install.
Also I'm curious if there is a way to turn this repository into a python package (which doesn't depend on sage)?