本文整理匯總了Python中vistrails.core.vistrail.controller.VistrailController.set_vistrail方法的典型用法代碼示例。如果您正苦於以下問題:Python VistrailController.set_vistrail方法的具體用法?Python VistrailController.set_vistrail怎麽用?Python VistrailController.set_vistrail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vistrails.core.vistrail.controller.VistrailController
的用法示例。
在下文中一共展示了VistrailController.set_vistrail方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: previewChanges
# 需要導入模塊: from vistrails.core.vistrail.controller import VistrailController [as 別名]
# 或者: from vistrails.core.vistrail.controller.VistrailController import set_vistrail [as 別名]
def previewChanges(self, aliases):
print "previewChanges", aliases
# we will just execute the pipeline with the given alias dictionary
controller = VistrailController()
controller.set_vistrail(self.plot_vistrail, self.locator)
version = self.plot_vistrail.get_version_number(self.workflow_tag) if self.workflow_tag else controller.get_latest_version_in_graph()
controller.change_selected_version(version)
(results, _) = controller.execute_current_workflow(aliases)
示例2: execute_wf
# 需要導入模塊: from vistrails.core.vistrail.controller import VistrailController [as 別名]
# 或者: from vistrails.core.vistrail.controller.VistrailController import set_vistrail [as 別名]
def execute_wf(wf, output_port):
# Save the workflow in a temporary file
temp_wf_fd, temp_wf = tempfile.mkstemp()
try:
f = open(temp_wf, 'w')
f.write(wf)
f.close()
os.close(temp_wf_fd)
# Clean the cache
interpreter = get_default_interpreter()
interpreter.flush()
# Load the Pipeline from the temporary file
vistrail = Vistrail()
locator = XMLFileLocator(temp_wf)
workflow = locator.load(Pipeline)
# Build a Vistrail from this single Pipeline
action_list = []
for module in workflow.module_list:
action_list.append(('add', module))
for connection in workflow.connection_list:
action_list.append(('add', connection))
action = vistrails.core.db.action.create_action(action_list)
vistrail.add_action(action, 0L)
vistrail.update_id_scope()
tag = 'parallel flow'
vistrail.addTag(tag, action.id)
# Build a controller and execute
controller = VistrailController()
controller.set_vistrail(vistrail, None)
controller.change_selected_version(vistrail.get_version_number(tag))
execution = controller.execute_current_workflow(
custom_aliases=None,
custom_params=None,
extra_info=None,
reason='API Pipeline Execution')
# Build a list of errors
errors = []
pipeline = vistrail.getPipeline(tag)
execution_errors = execution[0][0].errors
if execution_errors:
for key in execution_errors:
module = pipeline.modules[key]
msg = '%s: %s' %(module.name, execution_errors[key])
errors.append(msg)
# Get the execution log from the controller
try:
module_log = controller.log.workflow_execs[0].item_execs[0]
except IndexError:
errors.append("Module log not found")
return dict(errors=errors)
else:
machine = controller.log.workflow_execs[0].machines[
module_log.machine_id]
xml_log = serialize(module_log)
machine_log = serialize(machine)
# Get the output value
output = None
serializable = None
if not execution_errors:
executed_module, = execution[0][0].executed
executed_module = execution[0][0].objects[executed_module]
try:
output = executed_module.get_output(output_port)
except ModuleError:
errors.append("Output port not found: %s" % output_port)
return dict(errors=errors)
reg = vistrails.core.modules.module_registry.get_module_registry()
base_classes = inspect.getmro(type(output))
if Module in base_classes:
serializable = reg.get_descriptor(type(output)).sigstring
output = output.serialize()
# Return the dictionary, that will be sent back to the client
return dict(errors=errors,
output=output,
serializable=serializable,
xml_log=xml_log,
machine_log=machine_log)
finally:
os.unlink(temp_wf)
示例3: execute
# 需要導入模塊: from vistrails.core.vistrail.controller import VistrailController [as 別名]
# 或者: from vistrails.core.vistrail.controller.VistrailController import set_vistrail [as 別名]
def execute(workflowJSON):
''' Execute a workflow from it's JSON representation
'''
debug('convert json to xml')
workflowXML = json2xml(workflowJSON)
#temp_wf_fd, temp_wf = tempfile.mkstemp('.xml')
debug('create temporary file')
temp_wf_fd, temp_wf = tempfile.mkstemp()
try:
f = open(temp_wf, 'w')
f.write(workflowXML)
f.close()
os.close(temp_wf_fd)
#load workflow temp file into vistrails
#vt.load_workflow(temp_wf)
#execute workflow
#execution = vt.execute()
debug('Load the Pipeline from the temporary file')
vistrail = Vistrail()
locator = XMLFileLocator(temp_wf)
workflow = locator.load(Pipeline)
debug('Build a Vistrail from this single Pipeline')
action_list = []
for module in workflow.module_list:
action_list.append(('add', module))
for connection in workflow.connection_list:
action_list.append(('add', connection))
action = vistrails.core.db.action.create_action(action_list)
debug('add actions')
vistrail.add_action(action, 0L)
vistrail.update_id_scope()
tag = 'climatepipes'
vistrail.addTag(tag, action.id)
debug('Build a controller and execute')
controller = VistrailController()
controller.set_vistrail(vistrail, None)
controller.change_selected_version(vistrail.get_version_number(tag))
execution = controller.execute_current_workflow(
custom_aliases=None,
custom_params=None,
extra_info=None,
reason='API Pipeline Execution')
debug('get result')
execution_pipeline = execution[0][0]
if len(execution_pipeline.errors) > 0:
error("Executing workflow")
for key in execution_pipeline.errors:
error(execution_pipeline.errors[key])
print execution_pipeline.errors[key]
return None
modules = execution_pipeline.objects
for id, module in modules.iteritems():
if isinstance(module, ToGeoJSON):
return json.dumps({'result': module.JSON, 'error': None })
finally:
os.unlink(temp_wf)
示例4: load
# 需要導入模塊: from vistrails.core.vistrail.controller import VistrailController [as 別名]
# 或者: from vistrails.core.vistrail.controller.VistrailController import set_vistrail [as 別名]
def load(self, loadworkflow=True):
config = ConfigParser.ConfigParser()
if config.read(self.config_file):
if config.has_section('global'):
if config.has_option('global', 'cellnum'):
self.cellnum = config.getint('global', 'cellnum')
if config.has_option('global', 'filenum'):
self.filenum = config.getint('global', 'filenum')
if config.has_option('global', 'varnum'):
self.varnum = config.getint('global', 'varnum')
print " ------ Loaded plot %s, varnum = %d ------ " % ( self.name, self.varnum )
if config.has_option('global', 'workflow_tag'):
self.workflow_tag = config.get('global', 'workflow_tag')
# else:
# debug.warning("CDAT Package: file %s does not contain a required option 'workflow_tag'. Widget will not be loaded."%self.config_file)
# self.loaded = False
# return
if config.has_option('global', 'filetypes'):
types = config.get('global', 'filetypes')
tlist = [t.strip() for t in types.split(";")]
for t in tlist:
kv = t.split(":")
self.filetypes[kv[0].strip()] = [v.strip()
for v in kv[1].split(",")]
if config.has_option('global', 'qt_filter'):
self.qt_filter = config.get('global', 'qt_filter')
if config.has_option('global', 'dependencies'):
deps = config.get('global', 'dependencies')
self.dependencies = [d.strip() for d in deps.split(",")]
if config.has_option('global', 'serialized_config_alias'):
self.serializedConfigAlias = config.get('global', 'serialized_config_alias')
for y in range(self.filenum):
self.files.append( 'Filename' + str(y+1) )
for v in range(self.varnum):
self.vars.append( 'VariableName' + str(v+1) )
self.axes.append( 'Axes' + str(v+1) )
for x in range(self.cellnum):
section_name = 'cell' + str(x+1)
if config.has_section(section_name):
cellType = config.get(section_name, 'celltype')
if config.has_option(section_name, 'address_alias'):
self.cells.append( Cell( cellType, None, None,
config.get(section_name, 'address_alias') ) )
else:
self.cells.append(Cell( cellType,"Row"+str(x+1), "Column"+str(x+1) ) )
else:
for y in range(self.filenum):
option_name = 'filename_alias' + str(y+1)
if config.has_option('global', option_name):
self.files.append(config.get('global', option_name))
for v in range(self.varnum):
option_name = 'varname_alias' + str(v+1)
if config.has_option('global', option_name):
self.vars.append(config.get('global', option_name))
axes_name = 'axes_alias' + str(v+1)
if config.has_option('global', axes_name):
self.axes.append(config.get('global', axes_name))
for x in range(self.cellnum):
section_name = 'cell' + str(x+1)
if (config.has_section(section_name) and
config.has_option(section_name, 'celltype') and
config.has_option(section_name, 'row_alias') and
config.has_option(section_name, 'col_alias')):
self.cells.append(Cell(config.get(section_name, 'celltype'),
config.get(section_name, 'row_alias'),
config.get(section_name, 'col_alias')))
if loadworkflow:
#load workflow in vistrail
#only if dependencies are enabled
manager = get_package_manager()
self.unsatisfied_deps = []
for dep in self.dependencies:
if not manager.has_package(dep):
self.unsatisfied_deps.append(dep)
if len(self.unsatisfied_deps) == 0:
try:
(self.plot_vistrail, abstractions , thumbnails, mashups) = load_vistrail(self.locator)
controller = VistrailController()
controller.set_vistrail(self.plot_vistrail, self.locator,
abstractions, thumbnails,
mashups)
self.workflow_version = self.plot_vistrail.get_version_number(self.workflow_tag) if self.workflow_tag else controller.get_latest_version_in_graph()
print " Loaded %s version: %s" % ( self.name, str( self.workflow_version ) )
controller.change_selected_version(self.workflow_version)
self.workflow = controller.current_pipeline
self.loaded = True
except Exception, err:
debug.warning( "Error loading workflow %s: %s" % ( self.name, err ) )
self.loaded = False
else:
debug.warning("UV-CDAT: %s widget could not be loaded \
#.........這裏部分代碼省略.........