-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
rewrite conway polynomial spkg and code in Sage library to not use ZODB #12205
Comments
comment:2
I did some work on this on the airplane, and better post a link before I forget about it or loose it: http://wstein.org/patches/conway_polynomials-0.3.spkg Basically, the database is tiny so it can easily and very efficiently just be stored as a standard sobj. Using ZODB is silly. |
comment:3
That's a good start. Now we need to put SPKG.txt and spkg-install in proper shape. I suppose there need to be more work sage side to use the sobj rather than zodb. |
comment:5
Looks like I missed your work on this ohanar getting rid of zodb would be good news all around. Do this need any rebasing? |
comment:6
What's the status? According to comment:4, conway_polynomials-0.4.spkg should be final. So, needs review? What should be done to test whether this is really enough to get rid of zodb? I mean: How can one remove zodb from an existing Sage install? |
comment:7
Well, a patch is also needed to the sage library, and unfortunately William never provided that. It probably wouldn't be that hard to reverse engineer what he was thinking from the SPKG, but I haven't really looked into it. The only other database in sage that used zodb was the Cremona database, but I rewrote that a year and a half ago to use sqlite3, so this is the only thing that should really be using zope at all (there may be other things that stupidly depend on it, but they should be easy to fix to not use zope). |
comment:8
I think all that needs to be changed are the files: databases/compressed_storage.py, databases/db.py and databases/conway.py. conway.py is where we will have to be careful to present the same interface to the rest of sage so has not to break anything. |
comment:9
OK rewrite of conway.py belongs here and the other two files belong to #10353. I am looking at conway.py and see if it is in my abilities. |
comment:10
I think it is easy but it will be question of getting the syntax right. In the mean time I found that the stein-watkins optional "huge" database also use zodb and will need a similar treatment. |
comment:11
In the end I am hitting a brick wall here. Possibly due to my lack of python skills and my will to only have minimal changes in conway.py. The issue is that the created sobj is a double dictionary and that the call to the ConwayPolynomials() class follow the same pattern as a double dictionary. You have calls of the kind: Implementing the class as a dictionary allows sage to start
but unfortunately but I get key errors:
I was hoping that inheriting the dict class the access problem would be solved but I am obviously doing something wrong here. Loading the sobj directly from sage is totally usable, it is just when trying to put it in a class. |
comment:12
Replying to @kiwifb:
This only changes the meaning of the |
comment:13
Interesting point but here it will call update() from the dict class which I don't think is what you meant. I still get the same results after doing your suggested replacement. |
comment:14
Replying to @kiwifb:
I don't think To make the dictionary read-only, you may want to override the dictionary modification methods too. Plus you probably want to amend pickling (interesting question: How should this pickle? Should it write its content to a file or should it pickle to "initialize ConwayPolynomials() for unpickling"? |
comment:15
Thanks Nils. I actually though about that _init method as it was strange to have two. Merging the two didn't improve my problems however. I wouldn't know about the pickling. I'd like this to give me the correct behaviour of the class first. I'll retry merging inits as there may have been caching getting in the way. |
comment:16
I found a way to properly initialise the database. It is a bit ugly but we may be able to move to the other problems: pickling and dict method override. I'll post a patch when I am on something else than that iPad. |
comment:17
Actually, what you should do is just write the ConwayPolynomials class without thinking about how to initialize from an sobj at all, but just as either a normal class that has an attribute storing the info or inheriting from dict and ensure that pickling works. Then you just have to make sure that the |
comment:18
Rather than inheriting from |
comment:19
I think we have to stick with the dictionary format since the code in sage is littered with calls to ConwayPolynomials()[p][n] and changing the storage would imply changing an enormous amount of code. I trust that your python foo is way ahead of mine. I would never have produced that getitem and didn't find any examples to do that with google. Your patch is longer than my current one but probably better behaved in the long run. It is very educative to me too. |
comment:20
Looks great! Two questions:
|
comment:21
I can answer the first question: It is generated in the spkg attached in this ticket from a python table in text format look it up. Technically it doesn't have to be a sobj the previous spkg was installing a bzipped version of the python table and then inserting it in the database. We could do something similar, not sure about the cost. |
comment:22
Replying to @kiwifb:
As much as I understand, the "format" (in the sense of the "interface to retrieve data") does not change. That's exactly the point: If you wanted to inherit from dict, then you'd also have to have a
Would that be changed by the patch? Looking at the lines
it seems to me that
By "storage", I understand the format of the data stored in the .sobj file containing the data base. I don't think that would be a problem, as long as there is a function that is able to read old data and transforms it into the new format.
That's in dive into python or other Python introductions, or in the Python documentation. |
comment:23
I noticed a a flaw with what I did -- There is no good reason as far as I can tell to use anything but plain text in the SPKG considering how small the database is. As for the second question, the only concern would be that the entire database is loaded into memory with each instance (granted this might not be a huge concern due to the small size of the database). The main reason I added the inheritance of |
This comment has been minimized.
This comment has been minimized.
comment:48
Attachment: 12205_root.patch.gz This needs to depend on Moreover, this causes build problems for
|
comment:49
SAGERUNTIME? I hadn't seen that. I should have paid more attention to the originating ticket. OK I hadn't thought of twisted but the comment really is for #10353. I shall try to update the sagenb spkg to include zope.interface sometime this week. |
comment:50
Replying to @kiwifb:
Basically, It used to be the case that |
comment:51
Understood. But zope.interface shouldn't be a blocker for this ticket, only for #10353. |
comment:54
Potential build failures due to #13963. |
comment:55
Could this have caused (note this is over
|
comment:56
Is it a new doctest? I see this on unreleased 5.7.beta0. I agressively patched sage-on-gentoo (5.5) to get rid of zodb and we haven't seen that anywhere. I'll admit the move to new gap is giving me trouble but it should be unrelated - or should it? |
comment:57
Replying to @kiwifb:
No, it's not. On first sight, it doesn't seem to use anything besides basic polynomial arithmetic. But if basic polynomial arithmetic were broken, we would see a lot more doctests failing. I'm not at all saying that this ticket has anything to do with it, I merge a bunch of tickets and when there's a failure I have to guess which ticket caused it. |
Merged: sage-5.7.beta0 |
comment:60
It is part of the spkg. Don't ask me why ohanar put a "print p " in there. I don't mind the spam but I had a complaint about it in sage-on-gentoo and removed it there. |
comment:61
Don't worry, it wasn't directed at anyone in particular! Presumably it's something left over from debugging. Shall I assume this is to be considered non-optimal and a ticket should be opened? |
comment:62
fbissey: sage-on-gentoo is like a third level of ticket review after the official reviewer and the release manager! :D |
comment:63
So... should I open a ticket? It does seem bizarre, and apparently easily fixed? But if it was necessary, I don't want to. |
comment:64
That's very easy to fix but opening a ticket is pretty much the only way it will ever get merged. |
comment:65
|
This is necessary so we can dump the ZODB spkg from Sage.
Installation Instructions
Depends on #13896
Depends on #13963
CC: @kini
Component: packages: huge
Author: R. Andrew Ohana
Reviewer: François Bissey
Merged: sage-5.7.beta0
Issue created by migration from https://trac.sagemath.org/ticket/12205
The text was updated successfully, but these errors were encountered: