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

VT Bundle: Make database subsystem more robust #1092

Open
wants to merge 105 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
33e9bc1
WIP: Improve storage bundles to be uniform across storage types, impr…
dakoop May 23, 2013
9d4158c
WIP: Implement DB storage bundles; improve abstraction; improve locators
dakoop Jun 6, 2013
8158048
Merge branch 'master' into improve-vt-bundle
dakoop Jun 10, 2013
966c004
WIP: Implement DB storage bundles.
dakoop Jun 14, 2013
5cf3aa2
WIP: Refactor bundles.
dakoop Jun 14, 2013
ec62a3f
WIP: Dissociate BundleObj ids from serializers
dakoop Jun 14, 2013
9d28716
WIP: Add ZIP versions of default bundle types
dakoop Jun 15, 2013
8d8f4a4
WIP: Start migrating DB serialization routines
dakoop Jun 19, 2013
030f288
WIP: Migrate SQL backend to SQLAlchemy
dakoop Jun 22, 2013
413bf16
Merge branch 'master' into sql-alchemy
dakoop Jul 16, 2013
dde0a46
Push all sql through sqlalchemy, but use multi-statement capabilities…
dakoop Jul 19, 2013
57a89c8
IP: Translate io commands to use sqlalchemy.
dakoop Jul 22, 2013
4f3ae0d
WIP: Restructure db.services.io to be more versioned, introudce schem…
dakoop Jul 23, 2013
bd1c194
Add missing 1.0.4 -> 1.0.3 translation.
dakoop Jul 23, 2013
19303a3
More missing changes after git add, plus update db.services.query to …
dakoop Jul 23, 2013
ba33be0
Bug fixes based on testing GUI and sql access.
dakoop Jul 23, 2013
4fb619f
Merge branch 'master' into sql-alchemy
dakoop Jul 23, 2013
e874042
Bug fixes for SQL updates.
dakoop Jul 23, 2013
8dcac80
Add tests for translations between db versions.
dakoop Aug 1, 2013
09b4c71
<bugfix>Fix translation bugs between schema versions.</bugfix>
dakoop Aug 1, 2013
0d30846
Added missing change in db.services.io.
dakoop Aug 2, 2013
56563d3
Improve db translation tests.
dakoop Aug 6, 2013
f93338d
<bugfix>Fix ids on PortSpecItems</bugfix>
dakoop Aug 6, 2013
eb3d630
Fix bug in SQLAlchemy persistence.
dakoop Aug 7, 2013
92ebc4a
Update translation tests (again).
dakoop Aug 7, 2013
7252238
<bugfix>Fix translation bugs between schema versions.</bugfix>
dakoop Aug 7, 2013
5f27cb9
Move db v1.0.4 to v1.0.5
dakoop Jul 25, 2014
d56562b
Continue db v1.0.4 -> v1.0.5 move
dakoop Jul 25, 2014
88334e6
Move translate v1.0.4 -> v1.0.3 to v1.0.5 -> v1.0.3
dakoop Jul 25, 2014
3bedc01
Merge branch 'master' into sql-alchemy
dakoop Jul 26, 2014
e056f11
More work on 1.0.4 -> 1.0.5
dakoop Jul 27, 2014
f82a9b4
Add missing changes for 1.0.4 -> 1.0.5
dakoop Jul 27, 2014
cc57e9a
Add mising utils.py for 1.0.4
dakoop Jul 28, 2014
50c3016
Fix reverse translation bug
dakoop Jul 28, 2014
0220e38
Update drop error message, update 1.0.4 from 1.0.3
dakoop Jul 28, 2014
b92cabb
Fix test suite for sql-alchemy branch
dakoop Jul 28, 2014
f525696
Merge branch 'master' into improve-vt-bundle
rexissimus Oct 21, 2014
c624b4b
Added missing line from merge
rexissimus Oct 21, 2014
4a4f301
bundle.py: Fixed syntax and added docstrings
rexissimus Nov 17, 2014
a967b21
Automatically handle missing MANIFEST
rexissimus Nov 18, 2014
419a2f0
Use new bundle when loading/saving vt files
rexissimus Nov 26, 2014
943243c
Fixed loading/saving mashups using new bundle
rexissimus Nov 27, 2014
f12c231
Tests fixes
rexissimus Nov 28, 2014
aa8a054
Controller can now take a bundle
rexissimus Dec 1, 2014
4e06662
Save jobs as a file in the bundle
rexissimus Dec 1, 2014
d6941de
Added data directory in bundle
rexissimus Dec 2, 2014
dc769ea
Updated package hook for adding files to bundle/data/
rexissimus Dec 5, 2014
533e7e8
Merge branch 'master' into improve-vt-bundle
rexissimus Dec 8, 2014
db3d4fd
Added api for adding/deleting/listing bundle data
rexissimus Dec 8, 2014
0ed13e6
Merge branch 'master' into sql-alchemy
dakoop Jun 10, 2015
533f5e6
Delay py_import of sql-alchemy
dakoop Jun 10, 2015
1ca36b1
Make 1.0.5 persistence test more robust
dakoop Jun 11, 2015
54fa446
Add script to create database
dakoop Jun 11, 2015
af09794
Remove long cast on obj_id for db locators
dakoop Jun 11, 2015
ccb33ed
More db script updates
dakoop Jun 11, 2015
0efe836
Merge branch 'improve-vt-bundle' into sql-alchemy
dakoop Jun 11, 2015
21aa226
Update 1.0.5 specs with 1.0.4 changes
dakoop Jun 11, 2015
aa24f7c
WIP: Reworking some of bundle code
dakoop Jun 12, 2015
1bec3c7
Make DataFileSerializer use inheritance instead of rewriting
dakoop Jun 15, 2015
4ec0363
Support versions in partial forms of x.y.z
dakoop Jun 15, 2015
3606cf7
Add lazy loading support, fix bugs
dakoop Jun 15, 2015
d5d627c
Make 0.1 -> 1.0.3 translation a normal path
dakoop Jun 15, 2015
d3ae81d
WIP: Version bundles and make serialize specifics versioned
dakoop Jun 19, 2015
b361081
Fix file/dir test in runtestsuite's tempfile cleanup
dakoop Jul 30, 2015
539b940
Make serializers more configurable
dakoop Jul 31, 2015
ab1f8ad
Fix issue with grouped sql statements escaping
dakoop Jul 31, 2015
0291c2b
Add versioning support for bundle serializers
dakoop Jul 31, 2015
302d6e0
Add bundle mappings
dakoop Aug 4, 2015
79ad31c
Make bundle mappings & primary obj type easier
dakoop Aug 4, 2015
9abbdfa
WIP
dakoop Aug 4, 2015
16061b8
Don't hide root exceptions in tests
dakoop Aug 20, 2015
72c4a0b
Merge branch 'master' into sql-alchemy
dakoop Jul 1, 2016
b606cf9
Add missing cgi import
dakoop Jul 1, 2016
dcebdaa
Add note on libpng
dakoop Jul 1, 2016
594758f
Use qtconsole
dakoop Jul 1, 2016
b0240fa
Minor changes to locator
dakoop Jul 1, 2016
21c270e
Fix issues with merged code
dakoop Jul 5, 2016
db3bcce
WIP: Improve Bundle, BundleObj, Serializer interactions
dakoop Jul 5, 2016
1232de6
Initial file rework of bundle framework
dakoop Jul 6, 2016
412a59c
Update legacy and 1.0.5 bundles
dakoop Jul 7, 2016
c702de1
Version, type => mapping only, manifests to DirectorySerializers
dakoop Jul 7, 2016
430dc29
Create global bundle methods and use them in tests
dakoop Jul 7, 2016
7c89db8
Add calls for versioned bundles and translate support
dakoop Jul 8, 2016
d21d519
Update io calls
dakoop Jul 8, 2016
a9aa6a2
Fix mashup currentVersion non-init bug
dakoop Jul 8, 2016
032053d
Do bundle lookups on obj_type not attr_name
dakoop Jul 8, 2016
ecd3f57
Fix minor issues
dakoop Jul 8, 2016
f32f88d
Compress vt files
dakoop Jul 8, 2016
5bc9296
Fix minor issues
dakoop Jul 8, 2016
c3f592c
Simplify add_object code in controller
dakoop Jul 8, 2016
f3b3a2f
Support workflow, log, registry bundle
dakoop Jul 14, 2016
54cfa8f
Cleanup unused methods
dakoop Jul 14, 2016
be6c81a
WIP DB Serialization
dakoop Jul 21, 2016
2245051
Fix db bundle issues
dakoop Jul 21, 2016
c776ebc
Use sqlalchemy for DB serializers, manifest
dakoop Jul 22, 2016
d79c7fe
Change blob id column to integer, add name column
dakoop Jul 22, 2016
6488f06
Reorganize tests, WIP on terminator test
dakoop Jul 22, 2016
b359a6d
Hack around unittest issue
dakoop Jul 25, 2016
bfff109
Fix typo
dakoop Aug 3, 2016
7a8d0e1
Add has_changes for bundle
dakoop Aug 3, 2016
19158e7
Refactor controller.jobMonitor to controller.job_monitor
dakoop Aug 5, 2016
1fd065d
WIP to capture changes on bundle object lists
dakoop Aug 5, 2016
40c23b8
Revert "WIP to capture changes on bundle object lists"
dakoop Aug 17, 2016
85c8c8e
Move deep_eq_test to static function outside of domain classes
dakoop Aug 17, 2016
2c7bc29
Fix missed jobMonitor change
dakoop Aug 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 73 additions & 0 deletions scripts/create_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python
###############################################################################
##
## Copyright (C) 2014-2015, New York University.
## Copyright (C) 2011-2014, NYU-Poly.
## Copyright (C) 2006-2011, University of Utah.
## All rights reserved.
## Contact: contact@vistrails.org
##
## This file is part of VisTrails.
##
## "Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## - Neither the name of the New York University nor the names of its
## contributors may be used to endorse or promote products derived from
## this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
##
###############################################################################
import os
import sys
import tempfile
sys.path.append(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))
from vistrails.db.services import io
from db_utils import parse_db_cmd_line

def create_db(config, version=None):
db_connection = io.default_open_db_connection(config)
clean = False
try:
io.get_db_version_from_db(db_connection, True)
except Exception:
# asssume we don't have anything in the database
clean = True
if not clean:
raise Exception("Database already exists. Delete or upgrade it")

if version is not None:
config['version'] = version
db_connection = io.open_db_connection(config)
io.create_db_tables(db_connection)
io.close_db_connection(db_connection)

if __name__ == '__main__':
import vistrails.core.application

more_options = {'v:': ('schema version', False, 'version'),
}
config, options = parse_db_cmd_line(sys.argv, more_options)
version = None
if options['v']:
version = options['v']

vistrails.core.application.init()
create_db(config, version)
4 changes: 2 additions & 2 deletions scripts/delete_from_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
###############################################################################
import os
import sys
sys.path.append(os.path.join(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))), 'vistrails'))
sys.path.append(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))
from vistrails.db.services import io
from db_utils import parse_db_cmd_line

Expand Down
4 changes: 2 additions & 2 deletions scripts/merge_vistrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def main(out_fname, in_fnames):

"""
# FIXME this breaks when you use abstractions!
(save_bundle, vt_save_dir) = io.open_bundle_from_zip_xml(DBVistrail.vtType, in_fnames[0])
(save_bundle, vt_save_dir) = io.open_bundle_from_zip_xml(in_fnames[0])
for in_fname in in_fnames[1:]:
(new_save_bundle, new_save_dir) = io.open_bundle_from_zip_xml(DBVistrail.vtType, in_fname)
(new_save_bundle, new_save_dir) = io.open_bundle_from_zip_xml(in_fname)
vistrails.db.services.vistrail.merge(save_bundle, new_save_bundle, "", True, vt_save_dir, new_save_dir)
io.save_bundle_to_zip_xml(save_bundle, out_fname)

Expand Down
22 changes: 16 additions & 6 deletions scripts/update_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import os
import sys
import tempfile
sys.path.append(os.path.join(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))), 'vistrails'))
sys.path.append(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))
from vistrails.db.services import io
from vistrails.db.versions import currentVersion
from db_utils import parse_db_cmd_line
Expand Down Expand Up @@ -67,7 +67,8 @@ def update_db(config, new_version=None, tmp_dir=None, restore=False):
filenames.append(os.path.join(restore, fname))
else:
for obj_type in obj_types:
obj_id_lists[obj_type] = io.get_db_object_list(config, obj_type)
obj_id_lists[obj_type] = io.get_db_object_list(db_connection,
obj_type)

# read data out of database
thumbnail_dir = os.path.join(tmp_dir, 'thumbs')
Expand All @@ -92,12 +93,17 @@ def update_db(config, new_version=None, tmp_dir=None, restore=False):
io.save_vistrail_bundle_to_zip_xml(res, vt_name, local_tmp_dir)

# drop the old database
io.drop_db_tables(db_connection)
io.close_db_connection(db_connection)

# recreate with the new version of the specs
io.setup_db_tables(db_connection, None, old_version)
# we close and re-open the connection because the schema may change
db_connection = io.open_db_connection(config)
io.create_db_tables(db_connection)

# add the new data back
for filename in filenames:
(res, _) = io.open_vistrail_bundle_from_zip_xml(filename)
res = io.open_vistrail_bundle_from_zip_xml(filename)
try:
io.save_vistrail_bundle_to_db(res, db_connection, 'with_ids')
except Exception, e:
Expand All @@ -116,7 +122,11 @@ def update_db(config, new_version=None, tmp_dir=None, restore=False):
new_version = None
if options['v']:
new_version = options['v']
if options['d']:
tmp_dir = options['d']
else:
tmp_dir = None

vistrails.core.application.init()

update_db(config, new_version, options['d'], options['e'])
update_db(config, new_version, tmp_dir, options['e'])
4 changes: 2 additions & 2 deletions vistrails/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"upgrade Python or\ninstall unittest2, else VisTrails "
"might fail because of missing symbols.\n")


from vistrails.core.api import *
# FIXME circular import in tests since tests import vistrails.core.debug
# from vistrails.core.api import *
30 changes: 9 additions & 21 deletions vistrails/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,29 +271,18 @@ def process_interactive_input(self):
pe = version
version = None
else:
if hasattr(locator, '_vnode') and \
locator._vnode is not None:
version = locator._vnode
if hasattr(locator,'_vtag'):
# if a tag is set, it should be used instead of the
# version number
if locator._vtag != '':
version = locator._vtag
version = locator.version
execute = self.temp_configuration.check('execute')
mashuptrail = None
mashupversion = None
if hasattr(locator, '_mshptrail'):
mashuptrail = locator._mshptrail
if hasattr(locator, '_mshpversion'):
mashupversion = locator._mshpversion
if mashupversion:
execute = True
mashup_trail = locator.mashuptrail
mashup_version = locator.mashupVersion
if mashup_version:
execute = True
if self.temp_configuration.showWindow:
self.showBuilderWindow()
self.builderWindow.open_vistrail_without_prompt(locator,
version, execute,
mashuptrail=mashuptrail,
mashupVersion=mashupversion)
mashuptrail=mashup_trail,
mashupVersion=mashup_version)

if self.temp_configuration.check('parameterExploration'):
self.builderWindow.executeParameterExploration(pe)
Expand Down Expand Up @@ -410,9 +399,8 @@ def open_vistrail(self, locator=None, version=None, is_abstraction=False):
if controller is None:
# vistrail is not already open
try:
loaded_objs = vistrails.core.db.io.load_vistrail(locator, is_abstraction)
controller = self.add_vistrail(loaded_objs[0], locator,
*loaded_objs[1:])
bundle = vistrails.core.db.io.load_vistrail(locator, False)
controller = self.add_vistrail(bundle, locator)
if locator.is_untitled():
return controller
controller.is_abstraction = is_abstraction
Expand Down
31 changes: 27 additions & 4 deletions vistrails/core/collection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,29 @@ def create_vistrail_entity(self, vistrail):
self.add_entity(entity)
return entity

def update_from_database(self, db_locator):
# db_conn = db_locator.get_connection()
config = {'host': db_locator._host,
'port': int(db_locator._port),
'db': db_locator._db,
'user': db_locator._user,
'passwd': db_locator._passwd}
db_connection = vistrails.db.services.io.open_db_connection(config)
rows = vistrails.db.services.io.get_db_object_list(db_connection,
'vistrail')
vistrails.db.services.io.close_db_connection(db_connection)
for row in rows:
if row[0] in [1,]:
continue
locator = DBLocator(config['host'], config['port'], config['db'],
config['user'], config['passwd'],
obj_type='vistrail', obj_id=row[0])
(vistrail, abstractions, thumbnails, mashups) = load_vistrail(locator)
vistrail.abstractions = abstractions
vistrail.thumbnails = thumbnails
vistrail.mashups = mashups
self.create_vistrail_entity(vistrail)

def update_from_directory(self, directory):
filenames = glob.glob(os.path.join(directory, '*.vt'))
for filename in filenames:
Expand Down Expand Up @@ -331,10 +354,10 @@ def updateVistrail(self, url, vistrail=None):
locator = BaseLocator.from_url(url)
if locator.is_valid():
if not vistrail:
(vistrail, abstractions, thumbnails, mashups) = load_vistrail(locator)
vistrail.abstractions = abstractions
vistrail.thumbnails = thumbnails
vistrail.mashups = mashups
bundle = load_vistrail(locator)
vistrail.abstractions = [a.obj for a in bundle.abstractions]
vistrail.thumbnails = [t.obj for t in bundle.thumbnails]
vistrail.mashups = [m.obj for m in bundle.mashups]
entity = self.create_vistrail_entity(vistrail)
for p in workspaces:
self.add_to_workspace(entity, p)
Expand Down
2 changes: 1 addition & 1 deletion vistrails/core/collection/vistrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def create_mashup_entity(self, trail_id, mashup, action):
entity.create_time = action.db_date
locator = BaseLocator.from_url(self.url)
locator.kwargs['mashuptrail'] = trail_id
locator.kwargs['mashup'] = action.id
locator.kwargs['mashupVersion'] = action.id
entity.url = locator.to_url()
return entity

Expand Down
27 changes: 22 additions & 5 deletions vistrails/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
_usage_args = set()

_simple_documentation = """
addBundleData: Add data files to vistrail bundle
autoConnect: Automatically connect dragged in modules
autoSave: Automatically save backup vistrails every two minutes
batch: Run in batch mode instead of interactive mode
Expand All @@ -72,6 +73,7 @@
dbDefault: Save vistrails in a database by default
debugLevel: How much information should VisTrails log
defaultFileType: Default file type/extension for vistrails (.vt or .xml)
deleteBundleData: Delete data files in vistrail bundle
detachHistoryView: Show the version tree in a separate window
dotVistrails: User configuration directory
enablePackagesSilently: Automatically enable packages when needed
Expand All @@ -93,6 +95,7 @@
jobList: List running workflows
jobInfo: List jobs in running workflow
loadPackages: Whether to load the packages enabled in the configuration file
listBundleData: List data files in vistrail bundle
logDir: Log files directory
maxRecentVistrails: Number of recent vistrails
maximizeWindows: VisTrails windows should be maximized
Expand Down Expand Up @@ -124,7 +127,6 @@
showInlineParameterWidgets: Show editable parameters inside modules
showScrollbars: Show scrollbars on the version tree and workflow canvases
showSplash: Show VisTrails splash screen during startup
showSpreadsheetOnly: Hides the VisTrails main window
showVariantErrors: Show error when variant input value doesn't match type during execution
showVistrailsNews: Show news from VisTrails (once per message)
showWindow: Show the main window
Expand Down Expand Up @@ -152,6 +154,11 @@
"""

_documentation = """
addBundleData: Boolean

Add data files to vistrail bundle. Specify the file to add
or a directory to add files from.

autoConnect: Boolean

Try to automatically connect a newly dragged in module to the rest
Expand All @@ -178,6 +185,11 @@

The location that VisTrails uses as a default directory for data.

deleteBundleData: Boolean

Delete data files in vistrail bundle. Specify file or
a directory to delete all files in that directory.

db: String

The name for the database to load the vistrail from.
Expand Down Expand Up @@ -285,6 +297,11 @@

Whether to load the packages enabled in the configuration file.

listBundleData:

List data files in vistrail bundle. Specify path to
only list files matching that path.

logDir: Path

The path that indicates where log files should be stored.
Expand Down Expand Up @@ -465,10 +482,6 @@

Whether the VisTrails splash screen should be shown on startup.

showSpreadsheetOnly: Boolean

Whether the VisTrails main window should be hidden.

showVariantErrors: Boolean

Alert the user if the value along a connection coming from a
Expand Down Expand Up @@ -804,6 +817,10 @@ def __init__(self, name, sub_fields):
ConfigField('jobAutorun', False, bool),
ConfigField('jobList', False, bool, ConfigType.COMMAND_LINE_FLAG),
ConfigField('jobInfo', False, bool, ConfigType.COMMAND_LINE_FLAG)],
"BundleData":
[ConfigField("addBundleData", False, bool, ConfigType.COMMAND_LINE_FLAG),
ConfigField("deleteBundleData", False, bool, ConfigType.COMMAND_LINE_FLAG),
ConfigField("listBundleData", False, bool, ConfigType.COMMAND_LINE_FLAG)],
}

# FIXME make sure that the platform-specific configs are added!
Expand Down