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

Feature request / search: Rename bdb file after analysis #130

Open
leocasarsa opened this issue May 6, 2016 · 4 comments
Open

Feature request / search: Rename bdb file after analysis #130

leocasarsa opened this issue May 6, 2016 · 4 comments

Comments

@leocasarsa
Copy link

The autosave system of bdb files makes it hard to track in which state the bdb file currently is.

Granted, one could do this by initializing a population and calling pop.analysis_status(), for instance, but this is not quick to do if someone works on multiple bdb files. Being able to copy and rename the bdb file after making the population - or maybe after each crucial inference step to avoid losing previous costly inference steps- would come in handy.

@riastradh-probcomp
Copy link
Contributor

riastradh-probcomp commented May 6, 2016

echo .backup foo-42.bdb | sqlite3 ./foo.bdb

probcomp/bayeslite#316

@riastradh-probcomp
Copy link
Contributor

Also, if you want to do something hypothetically, without permanently modifying the database, you can do it inside a transaction:

bdb.execute('BEGIN')
# Mess around -- interactively, if you like.
bdb.execute('...')
# File will not be modified until:
bdb.execute('COMMIT')

Or a savepoint, which is nicer for the Python API and nests, unlike transactions:

with bdb.savepoint():
    bdb.execute('...')
    # not saved yet 
print 'ok'
# saved once you see 'ok'

If you don't like your hypothetical changes, you can roll back out of a transaction, or raise an exception to abort a savepoint:

bdb.execute('BEGIN')
...
bdb.execute('ROLLBACK')

try:
    with bdb.savepoint():
        ...
        if not ok:
            raise NotOKException
except NotOKException:
    pass

@leocasarsa
Copy link
Author

Nice! We should either make this more visible or make it standard to be inside a transaction.

@riastradh-probcomp
Copy link
Contributor

http://probcomp.csail.mit.edu/bayesdb/doc/bql.html#transactions
http://probcomp.csail.mit.edu/bayesdb/doc/api.html#bayeslite.BayesDB.savepoint

The docstring for BayesDB.savepoint() is a little terse. I will expand with a short example.

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

No branches or pull requests

2 participants