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

Replace use of sage.misc.package.PackageNotFoundError (2); lazy_import: Add keyword argument 'feature' #30616

Closed
mkoeppe opened this issue Sep 19, 2020 · 19 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Sep 19, 2020

This helps with the modularization of sagelib.

We demonstrate its use by simplifying:

  • sage.groups.braid (which depends on the optional library libbraiding via sage.libs.libbraiding). Actually a standard package
  • sage.sat.solvers.cryptominisat, .picosat
  • sage.matrix.matrix_space (meataxe)
  • sage.graphs.graph (tdlib, mcqd)

This simplification helps eliminate the use of sage.misc.package.PackageNotFoundError. See #30607.

CC: @kiwifb @jhpalmieri @slel @seblabbe @dcoudert

Component: refactoring

Author: Matthias Koeppe

Branch: e1f6624

Reviewer: David Coudert

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

@mkoeppe mkoeppe added this to the sage-9.2 milestone Sep 19, 2020
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 20, 2020

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 20, 2020

Commit: 30613c8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 20, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

fdc62f7src/sage/sat/solvers/cryptominisat.py: Use lazy_import with feature instead of try/except
30613c8src/sage/sat/solvers/picosat.py: Use lazy_import with feature instead of try/except

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 20, 2020

Author: Matthias Koeppe

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 21, 2020

Changed commit from 30613c8 to e1f6624

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 21, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

f2b5a1cGraph.treewidth: Fix up logic in algorithm selection
e1f6624Graph.{treewidth,clique_maximum,clique_number}: Use features instead of sage.misc.package.PackageNotFoundError

@mkoeppe mkoeppe changed the title lazy_import: Add keyword argument 'feature' Replace use of sage.misc.package.PackageNotFoundError (2); lazy_import: Add keyword argument 'feature' Sep 21, 2020
@dcoudert
Copy link
Contributor

comment:8

I tried before and after installing tdlib, mcqd, cryptominisat, pycosat (not obvious to know that its picosat), meataxe. Note that libbraiding was already installed (is it standard now ?). It's working well.

However, we have several pyflakes errors (see patchbot)

src/sage/graphs/graph.py:6419:20 undefined name 'mcqd'
src/sage/graphs/graph.py:6517:24 undefined name 'mcqd'

src/sage/groups/braid.py:82:1 'sage.misc.package.PackageNotFoundError' imported but unused
src/sage/groups/braid.py:1080:13 undefined name 'rightnormalform'
src/sage/groups/braid.py:1096:13 undefined name 'centralizer'
src/sage/groups/braid.py:1115:13 undefined name 'supersummitset'
src/sage/groups/braid.py:1138:13 undefined name 'greatestcommondivisor'
src/sage/groups/braid.py:1158:13 undefined name 'leastcommonmultiple'
src/sage/groups/braid.py:1183:13 undefined name 'conjugatingbraid'
src/sage/groups/braid.py:1208:13 undefined name 'conjugatingbraid'
src/sage/groups/braid.py:1236:15 undefined name 'ultrasummitset'
src/sage/groups/braid.py:1261:16 undefined name 'thurston_type'
src/sage/groups/braid.py:1326:24 undefined name 'rigidity'
src/sage/groups/braid.py:1358:15 undefined name 'sliding_circuits'

src/sage/matrix/matrix_space.py:287:24 undefined name 'Matrix_gfpn_dense'

src/sage/sat/solvers/cryptominisat.py:72:24 undefined name 'Solver'

src/sage/sat/solvers/picosat.py:63:23 undefined name 'solve'

@slel
Copy link
Member

slel commented Sep 23, 2020

comment:9

Replying to @dcoudert:

Note that libbraiding was already installed (is it standard now ?).

Yes, see build/pkgs/libbraiding/type which you can either
check with this command:

$ cat build/pkgs/libbraiding/type
standard

or by viewing that file online:

This happened in

which was merged in Sage 8.4.beta0.

@dcoudert
Copy link
Contributor

comment:10

Thanks.

Can we do something for the pyflakes issues or is it the prize to pay for lazy import ?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

comment:11

Unfortunately that's the prize to pay...

@dcoudert
Copy link
Contributor

Reviewer: David Coudert

@dcoudert
Copy link
Contributor

comment:12

So then.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

comment:13

Thank you!

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

comment:14

Replying to @mkoeppe:

Unfortunately that's the price to pay...

Follow-up: #30647 - Make lazy_import more friendly to pyflakes and other static checkers

@vbraun
Copy link
Member

vbraun commented Oct 5, 2020

Changed branch from u/mkoeppe/lazy_import__add_keyword_argument__feature_ to e1f6624

@kliem
Copy link
Contributor

kliem commented Dec 10, 2020

comment:16

I'm going to add the missing documentation on #30587.

@kliem
Copy link
Contributor

kliem commented Dec 10, 2020

Changed commit from e1f6624 to none

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

5 participants