OpenMath/py-scscp

Add instructions for using Python SCSCP package from SageMath

Closed this issue · 23 comments

Are there instructions and example for using this from SageMath?

defeo commented

Same as in Python

I've got client-server communication working from python, but can't load the package in Sage. What do I miss? Do I need to install it separately?

defeo commented

Yup, Sage has its own installation of Python, independent of your system. To install a pip package in Sage, type sage -pip install scscp.

that fails :(

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting scscp
  Could not fetch URL https://pypi.python.org/simple/scscp/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement scscp (from versions: )
No matching distribution found for scscp
defeo commented

How did you install SageMath? Binary image?

Yes, binary image...

defeo commented

Version? Platform? There have been various issues in Sage with TLS, I will have to ask on the devel list.

Thanks - it's a fresh installation of version 7.5.1 on OS X.

defeo commented

uh, oh, OS X... I'm afraid that's the culprit... See https://groups.google.com/forum/#!topic/sage-devel/jdLfIKQ1M18 I think @dimpase may know more about this.

try sage -i openssl and then sage -i pyopenssl (if necessary, rinse and repeat :))
(perhaps the latter will fail, and then you'd need to rebuild Sage's python:
sage -f python followed by make build)

(and the latter will not take much less time than simply building Sage from source :-))

@dimpase what do you mean by rinse/repeat then? I've managed sage -i openssl but not sage -i pyopenssl

@dimpase to which particular post out of all 17 in that thread do you refer?

@dimpase sorry, that's not helpful. I can't find exact wording like that in https://groups.google.com/forum/#!topic/sage-devel/jdLfIKQ1M18 - are we speaking about the same thread? Sage was rebuilding for an hour, now stuck at

[dochtml] [misc     ] for result in self.emit(event, *args):
[dochtml] An error occurred, but libGAP has no handler set.
[dochtml] Error message: Error, Variable: 'ReadlineInitLine' must have a value
[dochtml] 

I need someone's help to get SCSCP working in Sage to produce examples:

  • GAP server called from Sage
  • GAP calls Sage server and interacts with PARI/GP and Singular via Sage.

Can we also install scscp and openmath on SageMathCloud?

@dimpase aha, now I've seen your edited post:

try sage -i openssl and then sage -i pyopenssl (if necessary, rinse and repeat :))
(perhaps the latter will fail, and then you'd need to rebuild Sage's python:
sage -f python followed by make build)

GitHub does not notify about edits, so that was easy to miss. Trying that now. But then sage -f python fails. Its suggests to use python2 or python3 instead. Trying Python 2...

defeo commented

No content dictionary has been implemented for Sage,

I am not sure (Nicolas would know best) but I think that they have been working on generating some content dictionaries for Sage, this should be found out and tested.

I've managed to run sage -pip install scscp and sage -pip install openmath successfully, with the latest versions of scscp and openmath including last week's updates. Now in Sage I have:

sage: from scscp import SCSCPCLI
sage: c = SCSCPCLI('localhost')
sage: c.heads.scscp_transient_1.Identity([1])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-0221dc4bf136> in <module>()
----> 1 c.heads.scscp_transient_1.Identity([Integer(1)])

/Applications/SageMath/local/lib/python2.7/site-packages/scscp/cli.pyc in __call__(self, data, cookie, **opts)
     21             self._om = om.OMSymbol(name, cd=cd)
     22         def __call__(self, data, cookie=False, **opts):
---> 23             res = self._cli._call_wait(om.OMApplication(self._om, map(_conv_if_py, data)),
     24                                            cookie, **opts)
     25             if res.type == 'procedure_completed':

/Applications/SageMath/local/lib/python2.7/site-packages/scscp/cli.pyc in _conv_if_py(obj)
      8         return obj
      9     else:
---> 10         return convert.to_openmath(obj)
     11 
     12 class SCSCPCLI(SCSCPClient):

/Applications/SageMath/local/lib/python2.7/site-packages/openmath/convert.pyc in to_openmath(obj)
     59             return om.OMSymbol('emptyset', cd='set1')
     60 
---> 61     raise ValueError('Cannot convert %s to OpenMath.' % str(obj))

ValueError: Cannot convert 1 to OpenMath.

From what I can see on the GAP server's side, it gets incoming connection, returns the list of allowed heads, and then waits for next procedure call, but it never comes from Sage. Sage produces an error message because it does not know how to convert 1 to OpenMath, because the type of 1 is <type 'sage.rings.integer.Integer'>.

defeo commented

@defeo ok, I can do something: https://github.com/OpenDreamKit/OpenDreamKit/blob/master/WP3/D3.3/examples/SageMath-to-GAP.pdf.

It would be useful to extend SageMath to do the conversion for basic SageMath data types automatically, in order to be able to construct some non-trivial examples. For example, list amd matrices with integer entries, and/or permutations.

defeo commented

Since this is a Python package, not a SageMath package, this issue does not belong here. Closing it.

Of course, it would be good to have such instructions in SageMath.

Ok, I agree that it's not about THIS package. I'll contact you by other channels to ask help with getting this to work in SageMath :)