Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Make snapshots work again #236

Closed
kcrisman opened this issue Sep 18, 2014 · 20 comments
Closed

Make snapshots work again #236

kcrisman opened this issue Sep 18, 2014 · 20 comments
Labels

Comments

@kcrisman
Copy link
Member

Currently, all snapshots made (exactly when they are made is a bit of a mystery, but see sagenb/flask_version/worksheet.py for the @worksheet_commands) are IDENTICAL to the last version of the worksheet. This is completely useless, and actually worse than useless because it is misleading to users. Many have complained. This happened about the time that autosaves were greatly reduced, but no one has yet found the source of this. Maybe now is the time.

@kcrisman
Copy link
Member Author

Also, note that Worksheet.autosave() has return as the first line... I have no idea if that is related.

@kcrisman
Copy link
Member Author

This is essentially downstream at http://trac.sagemath.org/ticket/8776 - in fact, there is even code there, though I'm not sure it will be useful or even solves the same problem.

@kcrisman
Copy link
Member Author

(However, the idea in http://trac.sagemath.org/ticket/5291 (which was perhaps never implemented) for making sure there aren't too many snapshots could be worth keeping if needed.)

@kcrisman
Copy link
Member Author

I have wonderful news! SNAPSHOTS DO WORK! They just aren't being _un_snapshotted correctly. Here are two different snapshots of a worksheet I just created.

$ bunzip2 1411062323.bz2 -c




{{{id=1|


///

}}}$ bunzip2 1411062348.bz2 -c



{{{id=1|

2+2

///

4

}}}


{{{id=2|


///

}}}

@kcrisman
Copy link
Member Author

Okay, here is a first thing. All one needs to do is in def html_specific_revision(self, username, ws, rev): of sagenb/notebook/notebook.py, to change

        return template(os.path.join("html", "notebook",
                                 "specific_revision.html"),
                    worksheet = ws,
                    username = username, rev = rev, prev_rev = prev_rev,
                    next_rev = next_rev, time_ago = time_ago)

with worksheet = W, which is after all the actual new scratch worksheet created for this!

But there are two problems with this before it could actually be implemented - probably related.

  • The title of the worksheet is, naturally enough, 'scratch' and not whatever your worksheet name is. Maybe it should be 'name+rev#" but I don't know how that would affect things. But 'scratch' seems nonintuitive.
  • For some reason in the template it uses (sagenb/data/sage/html/notebook/specific_revision.html) the usual bar with edit and so forth disappears. That shouldn't happen - one shouldn't have to click to the revision list and then to the worksheet, but just immediately change. I don't know why that happens.

In fact, I think both of the above are related to the user being _sage_, the doc browser user, see e.g.

 <div id="share-publish-buttons">
{% if not worksheet.docbrowser() and not worksheet.is_published() %}

in sagenb/data/sage/html/notebook/base.html

Anyway, I am pretty sure this is now solved; the rest is window-dressing, which I may not have time to do immediately.

@kcrisman
Copy link
Member Author

Here are a couple things that don't quite work for various reasons, but they are on the right path.

    W = self.create_new_worksheet(ws.name(),ws.owner(),add_to_list=False)
    #W = self.scratch_worksheet()
    W.delete_cells_directory()
    W.edit_save(txt)
    #W.set_name(ws.name())
    #W.set_owner(ws.owner())

@kcrisman
Copy link
Member Author

Interestingly, 'Revision History -- Previous sessions' doesn't seem quite right to see after one has reverted, since one can "revert" to saves in the future of the revision you reverted to.

Also, the "Revision List" color needs to stand out more, maybe there is some css that can fix that.

More annoyingly, I have just made the disturbing discovery that add_to_list=True/False does nothing at all. That would certainly impact things - and indeed, http://localhost:8080/home/_sage_/ has every single doc browser worksheet ever!

@kcrisman
Copy link
Member Author

In fact, b0043f0 is where @mwhansen removed this. But it looks like this is different anyway - it seems to not be for adding to a list of actual worksheets, but rather to currently computed worksheets. Indeed, when you quit a worksheet it does

del self.__worksheets[W.filename()]

so that can't be it. But I suppose we should get rid of add_to_list, anyway, if all worksheets are enqueued.
In fact,

self.__worksheets[W.filename()] = W

is called every time notebook.worksheet() is called, which is always called upon new worksheet creation - and then this is called again. So it was redundant, every worksheet is added to the list. It's the __storage.save_worksheet that does the real saving.

@kcrisman
Copy link
Member Author

Okay, I think I have a usable fix. Fixing the worksheet should be just a matter of the change above and then changing the worksheet name. Fixing the CSS is doable because the specific revision has a body id of specific-revision-page we can use. Good. Hopefully a branch is coming up.

@kcrisman
Copy link
Member Author

See #247 - ready for review.

@kcrisman
Copy link
Member Author

(I wasn't able to get the bar of actions back in easily, but I think that is okay now that the revision list is clearer and separated a bit visually.)

@kcrisman
Copy link
Member Author

Fixed by #247

@novoselt
Copy link
Member

I have a question - how the snapshots are supposed to work? On my "work" server I observe the following: with 1 minute autosave interval there are no revisions. When I press "Save" there are still no revisions. When I press "Save & Quit", then open worksheet again and go to revisions, there are some which seem to coincide with me pressing either of two saving buttons. Is this expected behaviour? Any chance of writing some explanation of how things work/should work on the top of revisions page similar to how it is done for data, e.g. I create a file and see instructions

Access 234 in this worksheet by typing DATA+'234'. Here DATA is a special variable that gives the exact path to all data files uploaded to this worksheet.

@kcrisman
Copy link
Member Author

Any chance of writing some explanation of how things work/should work on the top of revisions page similar to how it is done for data,

Open a ticket here and I might be able to do this. "Save" should have worked properly, I believe. By the way, this is somewhat separate from the autosave, which is still apparently more or less broken.

@schymans
Copy link

I got here from http://trac.sagemath.org/ticket/8776 and in both places the situation seems to be fixed, but unfortunately, in Sage 6.6, I still do not see the snapshots. Do I need to update something separately? Thanks for your work on this!

@kcrisman
Copy link
Member Author

Can you be more specific as to what isn't working? You do need to use the History tab, if memory serves. Also, it only takes a snapshot when you explicitly save (currently).

@schymans
Copy link

Strange, if I click on "Save" or "Save and quit" now, I see a new revision when I then re-open and click on "Revisions". However, most of my worksheets have no revisions at all in the revision history. I'll keep in mind to save more often and then I'll watch if the revisions actually survive rebooting. Are they stored in the worksheet folder? Thanks for the quick reply!

@kcrisman
Copy link
Member Author

Interesting. I can't say for sure exactly why you are seeing that behavior; yes, they should be in the given folder, if I recall correctly (which I may not).

@schymans
Copy link

Thanks, I found them. Each worksheet in sage_notebook.sagenb/home/admin/ has a subfolder snapshots if any snapshots were created. I can now see how a new .bz2 file is added to the folder when I click on save. However, for some reason the new snapshot does not show in the list when I then click on "Revisions" in the browser. Perhaps the contents of the snapshots directory are not refreshed frequently?

@kcrisman
Copy link
Member Author

That is more or less correct, you have to reload the page or reset the cache or something - I came across this in testing. I usually "Save and Quit" and then restart. Good luck!

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

No branches or pull requests

3 participants