Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpful message if GAP fails to load a package #14483

Closed
nathanncohen mannequin opened this issue Apr 24, 2013 · 24 comments
Closed

Helpful message if GAP fails to load a package #14483

nathanncohen mannequin opened this issue Apr 24, 2013 · 24 comments

Comments

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Apr 24, 2013

Very short patch ! I met that problem while trying to run

sage: sage.combinat.designs.block_design.WittDesign(24)

and I had no idea how to install a gap package in the copy of gap that Sage contains...

Nathann

CC: @dimpase @vbraun @malb

Component: combinatorics

Author: Nathann Cohen

Reviewer: Dmitrii Pasechnik

Merged: sage-5.10.beta1

Issue created by migration from https://trac.sagemath.org/ticket/14483

@nathanncohen nathanncohen mannequin added this to the sage-5.10 milestone Apr 24, 2013
@nathanncohen nathanncohen mannequin assigned jdemeyer Apr 24, 2013
@nathanncohen nathanncohen mannequin added the s: needs review label Apr 24, 2013
@jeffpferreira
Copy link

comment:2

This patch works for me, applied to sage 5.8:

sage: sage.combinat.designs.block_design.WittDesign(24)

Incidence structure with 24 points and 759 block

However, after being prompted to run install_package("gap_packages"), gap_packages-4.5.7 is found. After you updated the spkg was I supposed to find gap_packages-4.6.3 ?

@dimpase
Copy link
Member

dimpase commented Apr 25, 2013

comment:3

how does this ticket relate to #14039 ?

@dimpase

This comment has been minimized.

@dimpase
Copy link
Member

dimpase commented Apr 25, 2013

comment:4

removed http://www.steinertriples.fr/gap-4.6.3.p0.spkg from the ticket description.

@dimpase
Copy link
Member

dimpase commented Apr 25, 2013

comment:5

Positive review - the patch works on Sage 4.5.9.beta5 just fine. GAP updates should be dealt with elsewhere.

@jdemeyer
Copy link

Reviewer: Dmitrii Pasechnik

@jdemeyer jdemeyer changed the title Update of GAP, and a an helpful message it fails at loading a package Helpful message if GAP fails to load a package Apr 25, 2013
@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:8

However, after being prompted to run install_package("gap_packages"), gap_packages-4.5.7 is found. After you updated the spkg was I supposed to find gap_packages-4.6.3 ?

Nononono, gap and gap_packages are different spkg. Besides, when you ask Sage to install a package for you it will download the latest "accepted" package, so not the one from this ticket :-)

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:9

how does this ticket relate to #14039 ?

Oops...

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:10

Positive review - the patch works on Sage 4.5.9.beta5 just fine.

Thaaaaaaanks !

GAP updates should be dealt with elsewhere.

Yepyep. Sorry 'bout that :-)

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 25, 2013

comment:11

Doesn't really matter here, but in general error messages should be kept brief. If you want to show the user some explanation or hints how to get around a potential pitfall you should use warnings so that it is only printed once during the session.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:12

Oh, I see. Thanks :-)

Nathann

@jdemeyer
Copy link

comment:13
sage -t devel/sage/sage/groups/perm_gps/permgroup.py
**********************************************************************
File "devel/sage/sage/groups/perm_gps/permgroup.py", line 152, in sage.groups.perm_gps.permgroup.load_hap
Failed example:
    sage.groups.perm_gps.permgroup.load_hap()
Exception raised:
    Traceback (most recent call last):
      File "/mazur/release/merger/sage-5.10.beta1/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 466, in _run
        self.execute(example, compiled, test.globs)
      File "/mazur/release/merger/sage-5.10.beta1/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 825, in execute
        exec compiled in globs
      File "<doctest sage.groups.perm_gps.permgroup.load_hap[0]>", line 1, in <module>
        sage.groups.perm_gps.permgroup.load_hap()
      File "/mazur/release/merger/sage-5.10.beta1/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.py", line 157, in load_hap
        gap.load_package("hap")
      File "/mazur/release/merger/sage-5.10.beta1/local/lib/python2.7/site-packages/sage/interfaces/gap.py", line 514, in load_package
        "install_package(\"gap_packages\")"%pkg)
    RuntimeError: Error loading Gap package hap. You may want to install a collection of GAP packages by installing the 'gap_packages' Sage spkg. If so, then run instal
l_package("gap_packages")
**********************************************************************

@jdemeyer
Copy link

comment:14

I agree with Volker that a long warning is better than a long error message.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:15

Okayyyyyyyyyyyyyyyy....

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 25, 2013

comment:16

What do you think of this ? Honestly I preferred the previous version... A warning just before an exception does not stand out at all ... :-/

Nathann

@jeffpferreira
Copy link

comment:18
sage -t devel/sage/sage/groups/perm_gps/permgroup.py    
**********************************************************************
File "/Applications/sage/devel/sage/sage/groups/perm_gps/permgroup.py", line 152:
    sage: sage.groups.perm_gps.permgroup.load_hap()
Exception raised:
    Traceback (most recent call last):
      File "/Applications/sage/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Applications/sage/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Applications/sage/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_1[2]>", line 1, in <module>
        sage.groups.perm_gps.permgroup.load_hap()###line 152:
    sage: sage.groups.perm_gps.permgroup.load_hap()
      File "/Applications/sage/local/lib/python/site-packages/sage/groups/perm_gps/permgroup.py", line 157, in load_hap
        gap.load_package("hap")
      File "/Applications/sage/local/lib/python/site-packages/sage/interfaces/gap.py", line 511, in load_package
        raise RuntimeError('Error loading Gap package %s'%pkg)
    RuntimeError: Error loading Gap package hap
**********************************************************************

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 28, 2013

comment:19

Fixed ! What do you think of this warning/exception thing, by the way ?

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 28, 2013

comment:20

I'm pretty sure the doctest will fail if you happen to have gap_packages installed (which includes HAP). How about we use gap.load_package("foobar") or something like that instead?

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 28, 2013

comment:21

Such a doctest already exists in interfaces/gap.py. Do you think that we should remove this doctest from permgroup.py ? I think it make sense.

What do you think of this warning/exception thing ?

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 28, 2013

comment:22

The doctest for the load_package() isn't necessary if it is tested elsewhere, but it is the natural place in the docstring to point out that you have to install HAP. I'll let you decide if you want to keep it or not.

As I said already, helpful explanations should be warnings not errors. The error message should be less than a whole line if possible. Advanced users shouldn't be drowned in paragraphs of text for simple errors. We could make warnings more prominent (say, using colors or bold text), but thats for another ticket.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 28, 2013

comment:23

Then I will probaly remove the doctest.

My problem with exceptions and warnings is not so general : in that case, a warning is printed just before the exception is raised, and no one sees the warning as a result. It would make more sense to just raise an exception. I will try to make the error message shorter.

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 28, 2013

comment:24

Attachment: trac_14483.patch.gz

What about this ?

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 28, 2013

comment:25

Fine with me.

@jdemeyer
Copy link

Merged: sage-5.10.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants