Opened 6 months ago
Closed 5 weeks ago
#27435 closed enhancement (fixed)
py3: failing doctest in graph_database.py with interactive_query
Reported by:  dcoudert  Owned by:  

Priority:  major  Milestone:  sage8.9 
Component:  graph theory  Keywords:  py3, graph 
Cc:  dimpase, jdemeyer  Merged in:  
Authors:  Ewan Davies, David Coudert  Reviewers:  Frédéric Chapoton, John Palmieri 
Report Upstream:  N/A  Work issues:  
Branch:  10fd0e8 (Commits)  Commit:  10fd0e835c2a89f5e89b283c691d7a10abb99a70 
Dependencies:  Stopgaps: 
Description
sage t long src/sage/graphs/graph_database.py ********************************************************************** File "src/sage/graphs/graph_database.py", line 1081, in sage.graphs.graph_database.GraphDatabase.interactive_query Failed example: D.interactive_query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=5, max_degree=3) Exception raised: Traceback (most recent call last): File "/Users/dcoudert/sage3/sage/local/lib/python3.6/inspect.py", line 1119, in getfullargspec sigcls=Signature) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/inspect.py", line 2186, in _signature_from_callable raise TypeError('{!r} is not a callable object'.format(obj)) TypeError: 0 is not a callable object The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/dcoudert/sage3/sage/local/lib/python3.6/sitepackages/sage/doctest/forker.py", line 671, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/sitepackages/sage/doctest/forker.py", line 1095, in compile_and_execute exec(compiled, globs) File "<doctest sage.graphs.graph_database.GraphDatabase.interactive_query[1]>", line 1, in <module> D.interactive_query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=Integer(5), max_degree=Integer(3)) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/sitepackages/sage/graphs/graph_database.py", line 1087, in interactive_query interact(f) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/sitepackages/sage/misc/decorators.py", line 343, in my_wrap return func(*args) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/sitepackages/sagenb/notebook/interact.py", line 2636, in interact (args, varargs, varkw, defaults) = inspect.getargspec(f) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/inspect.py", line 1073, in getargspec getfullargspec(func) File "/Users/dcoudert/sage3/sage/local/lib/python3.6/inspect.py", line 1125, in getfullargspec raise TypeError('unsupported callable') from ex TypeError: unsupported callable
Change History (20)
comment:1 Changed 6 months ago by
comment:2 Changed 6 months ago by
Hi, I am Piyush, I am new to sage, I was wondering if I could be of some help here.
I am not able to replicate this test. Is there something that I am missing? I am using Ubuntu 16.04
$ ./sage t long src/sage/graphs/graph_database.py Running doctests with ID 2019030811030440b4d48a. Git branch: develop Using optional=dochtml,memlimit,mpir,python2,sage Doctesting 1 file. sage t long src/sage/graphs/graph_database.py [50 tests, 0.49 s]  All tests passed!  Total time for all tests: 0.6 seconds cpu time: 0.5 seconds cumulative wall time: 0.5 seconds
comment:3 Changed 6 months ago by
The problem is with Python 3. We are working hard on the transition from Python 2 to Python 3.
comment:4 Changed 5 months ago by
 Milestone changed from sage8.7 to sage8.8
Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually)
comment:5 followup: ↓ 7 Changed 3 months ago by
I may have managed to fix this error. I don't know anything about the origins of the code but the error arises in in graph_database._gen_interact_func
where it seems a string defining a function called _
is run with exec
.
I tried changing the name of the function that gets defined and ran into a different python3related bug in the sagenb
python package (maintained out of the main sage tree): it still uses xrange
in sagenb.notebook.interact
at line 1185.
I downloaded the source for that package, changed the uses of xrange
, and now the doctest passes on my machine, but the bar for passing is simply emitting a string starting and finishing with <html>
and </html>
.
I'm not sure what to suggest for this ticket, the doctest in question has something to do with the old sage notebook (sagenb). The function interactive_query
returns some html that doesn't appear do anything in jupyter, and I can't use the old notebook on python3 (an error related to Twisted). Is the old notebook formally deprecated? See #22431 and in particular the 'side remark' about the graph database explorer.
If my changes to _gen_interact_func
and the sagenb
package are wanted I can send patches, but as I can't run the notebook myself on python3 I can't even verify that it's a proper fix.
comment:6 Changed 3 months ago by
 Cc dimpase added
Let's ask the author of #22431 if anything was said about graph_editor
and interactive queries in graph_database
.
Also I don't know if these tools have users. If not, we may simply deprecate the parts involving sagenb
. Otherwise, someone with enough knowledge in notebooks should try to solve the issues.
comment:7 in reply to: ↑ 5 Changed 3 months ago by
Replying to ghed359:
I may have managed to fix this error. I don't know anything about the origins of the code but the error arises in in
graph_database._gen_interact_func
where it seems a string defining a function called_
is run withexec
.I tried changing the name of the function that gets defined and ran into a different python3related bug in the
sagenb
python package (maintained out of the main sage tree): it still usesxrange
insagenb.notebook.interact
at line 1185.I downloaded the source for that package, changed the uses of
xrange
, and now the doctest passes on my machine, but the bar for passing is simply emitting a string starting and finishing with<html>
and</html>
.I'm not sure what to suggest for this ticket, the doctest in question has something to do with the old sage notebook (sagenb). The function
interactive_query
returns some html that doesn't appear do anything in jupyter, and I can't use the old notebook on python3 (an error related to Twisted). Is the old notebook formally deprecated? See #22431 and in particular the 'side remark' about the graph database explorer.If my changes to
_gen_interact_func
and thesagenb
package are wanted I can send patches, but as I can't run the notebook myself on python3 I can't even verify that it's a proper fix.
As long as these changes don't break sagenb on python2, it is fine. Please send a PR on https://github.com/sagemath/sagenb (perhaps they are already fixed in the 4 most recent open PRs there.)
As to functionality to be removed, I don't know.
comment:8 Changed 3 months ago by
 Branch set to u/ghed359/py3__failing_doctest_in_graph_database_py_with_interactive_query
comment:9 Changed 3 months ago by
 Cc jdemeyer added
 Commit set to 2d05ce8822d9fd403ccd56dbffa90db9f1285367
Thanks. We may need to think about how to deal with this in the eventual removal of sagenb, as the interact should in principle still be able to work in e.g. Jupyter notebooks, but would have to import from elsewhere. Cc:ing Jeroen as he knows a lot about how that is implemented in Jupyter and where things might need to import from now.
New commits:
2d05ce8  graph_database.py: fix doctest on python3

comment:10 Changed 3 months ago by
Now the error is in sagenb (tested over 8.8.beta6).
sage t long src/sage/graphs/graph_database.py ********************************************************************** File "src/sage/graphs/graph_database.py", line 1082, in sage.graphs.graph_database.GraphDatabase.interactive_query Failed example: D.interactive_query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=5, max_degree=3) Exception raised: Traceback (most recent call last): File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sage/doctest/forker.py", line 681, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sage/doctest/forker.py", line 1105, in compile_and_execute exec(compiled, globs) File "<doctest sage.graphs.graph_database.GraphDatabase.interactive_query[1]>", line 1, in <module> D.interactive_query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=Integer(5), max_degree=Integer(3)) File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sage/graphs/graph_database.py", line 1088, in interactive_query interact(f) File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sage/misc/decorators.py", line 343, in my_wrap return func(*args) File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sagenb/notebook/interact.py", line 2643, in interact for i, arg in enumerate(args)] File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sagenb/notebook/interact.py", line 2643, in <listcomp> for i, arg in enumerate(args)] File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sagenb/notebook/interact.py", line 3093, in render to_value=self.__to_value, width=self.__width) File "/Users/dcoudert/sage3/sage/local/lib/python3.7/sitepackages/sagenb/notebook/interact.py", line 1185, in __init__ default_value = [[default_value[i * columns + j] for j in xrange(columns)] for i in xrange(rows)] NameError: name 'xrange' is not defined **********************************************************************
comment:11 Changed 2 months ago by
 Milestone sage8.8 deleted
As the Sage8.8 release milestone is pending, we should delete the sage8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage8.9).
comment:12 Changed 2 months ago by
 Milestone set to sage8.9
comment:13 Changed 6 weeks ago by
If the problem is with sagenb, then can we mark the doctest as "# py2", since my understanding is that sagenb is not compatible with Python 3? That is, keep the proposed changes here, but also tag the doctest as py2 only.
comment:14 Changed 6 weeks ago by
can't we just skip installing sagenb on Python3?
comment:15 Changed 6 weeks ago by
I think that sagenb as a whole does not work with Python 3, but parts of it do, and parts are imported into the Sage library in various places. If we don't install it, some things will break. Some of the imports:
src/sage/graphs/graph_editor.py: import sagenb.notebook.interact src/sage/interacts/library.py: import sagenb.notebook.interact src/sage/interacts/debugger.py: from sagenb.notebook.interact import slider, input_box, selector
comment:16 Changed 6 weeks ago by
I agree with the proposal of marking this doctest as # py2
, but we should also add that there is known issue with py3, no ? This way, we don't await for a decision about sagenb.
comment:17 Changed 6 weeks ago by
 Branch changed from u/ghed359/py3__failing_doctest_in_graph_database_py_with_interactive_query to public/graphs/27435_doctest_in_graph_database
 Commit changed from 2d05ce8822d9fd403ccd56dbffa90db9f1285367 to 10fd0e835c2a89f5e89b283c691d7a10abb99a70
 Status changed from new to needs_review
comment:18 Changed 5 weeks ago by
This is fine with me. Anyone else have any comments? Objections to setting to positive review?
comment:19 Changed 5 weeks ago by
 Reviewers set to Frédéric Chapoton, John Palmieri
 Status changed from needs_review to positive_review
ok..
comment:20 Changed 5 weeks ago by
 Branch changed from public/graphs/27435_doctest_in_graph_database to 10fd0e835c2a89f5e89b283c691d7a10abb99a70
 Resolution set to fixed
 Status changed from positive_review to closed
I don't know how to fix it.