本文整理汇总了Python中oozie.models.Workflow类的典型用法代码示例。如果您正苦于以下问题:Python Workflow类的具体用法?Python Workflow怎么用?Python Workflow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Workflow类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_oozie_workflow
def list_oozie_workflow(request, job_id, coordinator_job_id=None):
oozie_workflow = check_job_access_permission(request, job_id)
oozie_coordinator = None
if coordinator_job_id is not None:
oozie_coordinator = check_job_access_permission(request, coordinator_job_id)
history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)
hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)
parameters = oozie_workflow.conf_dict.copy()
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
else:
workflow_graph = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)
return render('dashboard/list_oozie_workflow.mako', request, {
'history': history,
'oozie_workflow': oozie_workflow,
'oozie_coordinator': oozie_coordinator,
'hue_workflow': hue_workflow,
'hue_coord': hue_coord,
'parameters': parameters,
'has_job_edition_permission': has_job_edition_permission,
'workflow_graph': workflow_graph
})
示例2: list_oozie_workflow
def list_oozie_workflow(request, job_id, coordinator_job_id=None, bundle_job_id=None):
oozie_workflow = check_job_access_permission(request, job_id)
oozie_coordinator = None
if coordinator_job_id is not None:
oozie_coordinator = check_job_access_permission(request, coordinator_job_id)
oozie_bundle = None
if bundle_job_id is not None:
oozie_bundle = check_job_access_permission(request, bundle_job_id)
if oozie_coordinator is not None:
setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
if oozie_bundle is not None:
setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)
history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)
hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)
parameters = oozie_workflow.conf_dict.copy()
for action in oozie_workflow.actions:
action.oozie_coordinator = oozie_coordinator
action.oozie_bundle = oozie_bundle
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
full_node_list = hue_workflow.node_list
else:
workflow_graph, full_node_list = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)
if request.GET.get('format') == 'json':
return_obj = {
'id': oozie_workflow.id,
'status': oozie_workflow.status,
'progress': oozie_workflow.get_progress(full_node_list),
'graph': workflow_graph,
'log': oozie_workflow.log,
'actions': massaged_workflow_actions_for_json(oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle)
}
return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")
return render('dashboard/list_oozie_workflow.mako', request, {
'history': history,
'oozie_workflow': oozie_workflow,
'oozie_coordinator': oozie_coordinator,
'oozie_bundle': oozie_bundle,
'hue_workflow': hue_workflow,
'hue_coord': hue_coord,
'parameters': parameters,
'has_job_edition_permission': has_job_edition_permission,
'workflow_graph': workflow_graph
})
示例3: _import_workflows
def _import_workflows(self, directory, managed=True):
for example_directory_name in os.listdir(directory):
if os.path.isdir(os.path.join(directory, example_directory_name)):
with open(os.path.join(directory, example_directory_name, 'workflow.zip')) as fp:
workflow_xml, metadata = Workflow.decompress(fp)
workflow_root = etree.fromstring(workflow_xml)
try:
Workflow.objects.get(name=workflow_root.get('name'), managed=managed)
except Workflow.DoesNotExist:
LOG.info(_("Installing workflow %s") % workflow_root.get('name'))
LOG.debug("Workflow definition:\n%s" % workflow_xml)
workflow = Workflow.objects.new_workflow(owner=self.user)
workflow.is_shared = True
workflow.managed = managed
workflow.name = workflow_root.get('name')
workflow.save()
Workflow.objects.initialize(workflow)
import_workflow_root(workflow=workflow, workflow_definition_root=workflow_root, metadata=metadata, fs=self.fs)
workflow.doc.all().delete() # Delete doc as it messes up the example sharing
示例4: _is_workflow
def _is_workflow(self):
from oozie.models import Workflow
return Workflow.get_application_path_key() in self.properties
示例5: list_oozie_workflow
def list_oozie_workflow(request, job_id):
oozie_workflow = check_job_access_permission(request, job_id)
oozie_coordinator = None
if request.GET.get('coordinator_job_id'):
oozie_coordinator = check_job_access_permission(request, request.GET.get('coordinator_job_id'))
oozie_bundle = None
if request.GET.get('bundle_job_id'):
oozie_bundle = check_job_access_permission(request, request.GET.get('bundle_job_id'))
if oozie_coordinator is not None:
setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
if oozie_bundle is not None:
setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)
oozie_parent = oozie_workflow.get_parent_job_id()
if oozie_parent:
oozie_parent = check_job_access_permission(request, oozie_parent)
workflow_data = None
credentials = None
doc = None
hue_workflow = None
workflow_graph = 'MISSING' # default to prevent loading the graph tab for deleted workflows
full_node_list = None
if ENABLE_V2.get():
try:
# To update with the new History document model
hue_coord = get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or get_history().get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord and hue_coord.workflow: hue_coord.workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow: hue_workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow:
workflow_graph = ''
full_node_list = hue_workflow.nodes
workflow_id = hue_workflow.id
wid = {
'id': workflow_id
}
doc = Document2.objects.get(type='oozie-workflow2', **wid)
new_workflow = get_workflow()(document=doc)
workflow_data = new_workflow.get_data()
credentials = Credentials()
else:
# For workflows submitted from CLI or deleted in the editor
# Until better parsing in https://issues.cloudera.org/browse/HUE-2659
workflow_graph, full_node_list = OldWorkflow.gen_status_graph_from_xml(request.user, oozie_workflow)
except:
LOG.exception("Error generating full page for running workflow %s" % job_id)
else:
history = get_history().cross_reference_submission_history(request.user, job_id)
hue_coord = history and history.get_coordinator() or get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or get_history().get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord and hue_coord.workflow: Job.objects.can_read_or_exception(request, hue_coord.workflow.id)
if hue_workflow: Job.objects.can_read_or_exception(request, hue_workflow.id)
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
full_node_list = hue_workflow.node_list
else:
workflow_graph, full_node_list = get_workflow().gen_status_graph_from_xml(request.user, oozie_workflow)
parameters = oozie_workflow.conf_dict.copy()
for action in oozie_workflow.actions:
action.oozie_coordinator = oozie_coordinator
action.oozie_bundle = oozie_bundle
if request.GET.get('format') == 'json':
return_obj = {
'id': oozie_workflow.id,
'status': oozie_workflow.status,
'progress': oozie_workflow.get_progress(full_node_list),
'graph': workflow_graph,
'actions': massaged_workflow_actions_for_json(oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle)
}
return JsonResponse(return_obj, encoder=JSONEncoderForHTML)
oozie_slas = []
if oozie_workflow.has_sla:
oozie_api = get_oozie(request.user, api_version="v2")
params = {
'id': oozie_workflow.id,
'parent_id': oozie_workflow.id
}
oozie_slas = oozie_api.get_oozie_slas(**params)
return render('dashboard/list_oozie_workflow.mako', request, {
'oozie_workflow': oozie_workflow,
'oozie_coordinator': oozie_coordinator,
'oozie_bundle': oozie_bundle,
'oozie_parent': oozie_parent,
'oozie_slas': oozie_slas,
#.........这里部分代码省略.........
示例6: list_oozie_workflow
def list_oozie_workflow(request, job_id):
oozie_workflow = check_job_access_permission(request, job_id)
oozie_coordinator = None
if request.GET.get('coordinator_job_id'):
oozie_coordinator = check_job_access_permission(request, request.GET.get('coordinator_job_id'))
oozie_bundle = None
if request.GET.get('bundle_job_id'):
oozie_bundle = check_job_access_permission(request, request.GET.get('bundle_job_id'))
if oozie_coordinator is not None:
setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
if oozie_bundle is not None:
setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)
if ENABLE_V2.get():
# To update with the new History document model
hue_coord = get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or get_history().get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord and hue_coord.workflow: hue_coord.workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow: hue_workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
full_node_list = hue_workflow.nodes
else:
workflow_graph, full_node_list = '', None
else:
history = get_history().cross_reference_submission_history(request.user, job_id)
hue_coord = history and history.get_coordinator() or get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or get_history().get_workflow_from_config(oozie_workflow.conf_dict)
if hue_coord and hue_coord.workflow: Job.objects.can_read_or_exception(request, hue_coord.workflow.id)
if hue_workflow: Job.objects.can_read_or_exception(request, hue_workflow.id)
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
full_node_list = hue_workflow.node_list
else:
workflow_graph, full_node_list = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)
parameters = oozie_workflow.conf_dict.copy()
for action in oozie_workflow.actions:
action.oozie_coordinator = oozie_coordinator
action.oozie_bundle = oozie_bundle
if request.GET.get('format') == 'json':
return_obj = {
'id': oozie_workflow.id,
'status': oozie_workflow.status,
'progress': oozie_workflow.get_progress(full_node_list),
'graph': workflow_graph,
'actions': massaged_workflow_actions_for_json(oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle)
}
return JsonResponse(return_obj, encoder=JSONEncoderForHTML)
oozie_slas = []
if oozie_workflow.has_sla:
oozie_api = get_oozie(request.user, api_version="v2")
params = {
'id': oozie_workflow.id,
'parent_id': oozie_workflow.id
}
oozie_slas = oozie_api.get_oozie_slas(**params)
return render('dashboard/list_oozie_workflow.mako', request, {
'oozie_workflow': oozie_workflow,
'oozie_coordinator': oozie_coordinator,
'oozie_bundle': oozie_bundle,
'oozie_slas': oozie_slas,
'hue_workflow': hue_workflow,
'hue_coord': hue_coord,
'parameters': parameters,
'has_job_edition_permission': has_job_edition_permission,
'workflow_graph': workflow_graph
})
示例7: list_oozie_workflow
def list_oozie_workflow(request, job_id):
oozie_workflow = check_job_access_permission(request, job_id)
oozie_coordinator = None
if request.GET.get("coordinator_job_id"):
oozie_coordinator = check_job_access_permission(request, request.GET.get("coordinator_job_id"))
oozie_bundle = None
if request.GET.get("bundle_job_id"):
oozie_bundle = check_job_access_permission(request, request.GET.get("bundle_job_id"))
if oozie_coordinator is not None:
setattr(oozie_workflow, "oozie_coordinator", oozie_coordinator)
if oozie_bundle is not None:
setattr(oozie_workflow, "oozie_bundle", oozie_bundle)
oozie_parent = oozie_workflow.get_parent_job_id()
if oozie_parent:
oozie_parent = check_job_access_permission(request, oozie_parent)
workflow_data = None
credentials = None
doc = None
hue_workflow = None
workflow_graph = "MISSING" # default to prevent loading the graph tab for deleted workflows
full_node_list = None
if ENABLE_V2.get():
try:
# To update with the new History document model
hue_coord = get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
hue_workflow = (hue_coord and hue_coord.workflow) or get_history().get_workflow_from_config(
oozie_workflow.conf_dict
)
if hue_coord and hue_coord.workflow:
hue_coord.workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow:
hue_workflow.document.doc.get().can_read_or_exception(request.user)
if hue_workflow:
workflow_graph = ""
full_node_list = hue_workflow.nodes
workflow_id = hue_workflow.id
wid = {"id": workflow_id}
doc = Document2.objects.get(type="oozie-workflow2", **wid)
new_workflow = get_workflow()(document=doc)
workflow_data = new_workflow.get_data()
credentials = Credentials()
else:
# For workflows submitted from CLI or deleted in the editor
# Until better parsing in https://issues.cloudera.org/browse/HUE-2659
workflow_graph, full_node_list = OldWorkflow.gen_status_graph_from_xml(request.user, oozie_workflow)
except:
LOG.exception("Error generating full page for running workflow %s" % job_id)
else:
history = get_history().cross_reference_submission_history(request.user, job_id)
hue_coord = (
history and history.get_coordinator() or get_history().get_coordinator_from_config(oozie_workflow.conf_dict)
)
hue_workflow = (
(hue_coord and hue_coord.workflow)
or (history and history.get_workflow())
or get_history().get_workflow_from_config(oozie_workflow.conf_dict)
)
if hue_coord and hue_coord.workflow:
Job.objects.can_read_or_exception(request, hue_coord.workflow.id)
if hue_workflow:
Job.objects.can_read_or_exception(request, hue_workflow.id)
if hue_workflow:
workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
full_node_list = hue_workflow.node_list
else:
workflow_graph, full_node_list = get_workflow().gen_status_graph_from_xml(request.user, oozie_workflow)
parameters = oozie_workflow.conf_dict.copy()
for action in oozie_workflow.actions:
action.oozie_coordinator = oozie_coordinator
action.oozie_bundle = oozie_bundle
if request.GET.get("format") == "json":
return_obj = {
"id": oozie_workflow.id,
"status": oozie_workflow.status,
"progress": oozie_workflow.get_progress(full_node_list),
"graph": workflow_graph,
"actions": massaged_workflow_actions_for_json(
oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle
),
}
return JsonResponse(return_obj, encoder=JSONEncoderForHTML)
oozie_slas = []
if oozie_workflow.has_sla:
oozie_api = get_oozie(request.user, api_version="v2")
params = {"id": oozie_workflow.id, "parent_id": oozie_workflow.id}
#.........这里部分代码省略.........