本文整理汇总了Python中liboozie.submission2.Submission.update_coord方法的典型用法代码示例。如果您正苦于以下问题:Python Submission.update_coord方法的具体用法?Python Submission.update_coord怎么用?Python Submission.update_coord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类liboozie.submission2.Submission
的用法示例。
在下文中一共展示了Submission.update_coord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sync_coord_workflow
# 需要导入模块: from liboozie.submission2 import Submission [as 别名]
# 或者: from liboozie.submission2.Submission import update_coord [as 别名]
def sync_coord_workflow(request, job_id):
ParametersFormSet = formset_factory(ParameterForm, extra=0)
job = check_job_access_permission(request, job_id)
check_job_edition_permission(job, request.user)
hue_coord = get_history().get_coordinator_from_config(job.conf_dict)
hue_wf = (hue_coord and hue_coord.workflow) or get_history().get_workflow_from_config(job.conf_dict)
wf_application_path = job.conf_dict.get('wf_application_path') and Hdfs.urlsplit(job.conf_dict['wf_application_path'])[2] or ''
coord_application_path = job.conf_dict.get('oozie.coord.application.path') and Hdfs.urlsplit(job.conf_dict['oozie.coord.application.path'])[2] or ''
properties = hue_coord and hue_coord.properties and dict([(param['name'], param['value']) for param in hue_coord.properties]) or None
if request.method == 'POST':
params_form = ParametersFormSet(request.POST)
if params_form.is_valid():
mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data])
# Update workflow params in coordinator
hue_coord.clear_workflow_params()
properties = dict([(param['name'], param['value']) for param in hue_coord.properties])
# Deploy WF XML
submission = Submission(user=request.user, job=hue_wf, fs=request.fs, jt=request.jt, properties=properties)
submission.deploy(deployment_dir=wf_application_path)
submission._create_file(wf_application_path, hue_wf.XML_FILE_NAME, hue_wf.to_xml(mapping=properties), do_as=True)
# Deploy Coordinator XML
job.conf_dict.update(mapping)
submission = Submission(user=request.user, job=hue_coord, fs=request.fs, jt=request.jt, properties=job.conf_dict, oozie_id=job.id)
submission._create_file(coord_application_path, hue_coord.XML_FILE_NAME, hue_coord.to_xml(mapping=job.conf_dict), do_as=True)
# Server picks up deployed Coordinator XML changes after running 'update' action
submission.update_coord()
request.info(_('Successfully updated Workflow definition'))
return redirect(reverse('oozie:list_oozie_coordinator', kwargs={'job_id': job_id}))
else:
request.error(_('Invalid submission form: %s' % params_form.errors))
else:
new_params = hue_wf and hue_wf.find_all_parameters() or []
new_params = dict([(param['name'], param['value']) for param in new_params])
# Set previous values
if properties:
new_params = dict([(key, properties[key]) if key in properties.keys() else (key, new_params[key]) for key, value in new_params.iteritems()])
initial_params = ParameterForm.get_initial_params(new_params)
params_form = ParametersFormSet(initial=initial_params)
popup = render('editor2/submit_job_popup.mako', request, {
'params_form': params_form,
'name': _('Job'),
'header': _('Sync Workflow definition?'),
'action': reverse('oozie:sync_coord_workflow', kwargs={'job_id': job_id})
}, force_template=True).content
return JsonResponse(popup, safe=False)
示例2: sync_coord_workflow
# 需要导入模块: from liboozie.submission2 import Submission [as 别名]
# 或者: from liboozie.submission2.Submission import update_coord [as 别名]
def sync_coord_workflow(request, job_id):
ParametersFormSet = formset_factory(ParameterForm, extra=0)
job = check_job_access_permission(request, job_id)
check_job_edition_permission(job, request.user)
hue_coord = get_history().get_coordinator_from_config(job.conf_dict)
hue_wf = (hue_coord and hue_coord.workflow) or get_history().get_workflow_from_config(job.conf_dict)
wf_application_path = (
job.conf_dict.get("wf_application_path") and Hdfs.urlsplit(job.conf_dict["wf_application_path"])[2] or ""
)
coord_application_path = (
job.conf_dict.get("oozie.coord.application.path")
and Hdfs.urlsplit(job.conf_dict["oozie.coord.application.path"])[2]
or ""
)
properties = (
hue_coord
and hue_coord.properties
and dict([(param["name"], param["value"]) for param in hue_coord.properties])
or None
)
if request.method == "POST":
params_form = ParametersFormSet(request.POST)
if params_form.is_valid():
mapping = dict([(param["name"], param["value"]) for param in params_form.cleaned_data])
# Update workflow params in coordinator
hue_coord.clear_workflow_params()
properties = dict([(param["name"], param["value"]) for param in hue_coord.properties])
# Deploy WF XML
submission = Submission(user=request.user, job=hue_wf, fs=request.fs, jt=request.jt, properties=properties)
submission._create_file(
wf_application_path, hue_wf.XML_FILE_NAME, hue_wf.to_xml(mapping=properties), do_as=True
)
# Deploy Coordinator XML
job.conf_dict.update(mapping)
submission = Submission(
user=request.user,
job=hue_coord,
fs=request.fs,
jt=request.jt,
properties=job.conf_dict,
oozie_id=job.id,
)
submission._create_file(
coord_application_path, hue_coord.XML_FILE_NAME, hue_coord.to_xml(mapping=job.conf_dict), do_as=True
)
# Server picks up deployed Coordinator XML changes after running 'update' action
submission.update_coord()
request.info(_("Successfully updated Workflow definition"))
return redirect(reverse("oozie:list_oozie_coordinator", kwargs={"job_id": job_id}))
else:
request.error(_("Invalid submission form: %s" % params_form.errors))
else:
new_params = hue_wf and hue_wf.find_all_parameters() or []
new_params = dict([(param["name"], param["value"]) for param in new_params])
# Set previous values
if properties:
new_params = dict(
[
(key, properties[key]) if key in properties.keys() else (key, new_params[key])
for key, value in new_params.iteritems()
]
)
initial_params = ParameterForm.get_initial_params(new_params)
params_form = ParametersFormSet(initial=initial_params)
popup = render(
"editor2/submit_job_popup.mako",
request,
{
"params_form": params_form,
"name": _("Job"),
"header": _("Sync Workflow definition?"),
"action": reverse("oozie:sync_coord_workflow", kwargs={"job_id": job_id}),
},
force_template=True,
).content
return JsonResponse(popup, safe=False)