def _method_get_state(workspace, token, URLS, job_manager, method_spec_json, param_values_json, method_job_id):
    methodSpec = json.loads(method_spec_json)
    methodInputValues = json.loads(correct_method_specs_json(param_values_json))
    njsClient = NarrativeJobService(URLS.job_service, token = token)
    wsClient = workspaceService(URLS.workspace, token = token)
    if method_job_id.startswith("method:"):
        method_job_id = method_job_id[7:]
        is_async = is_async_method(methodSpec)
        appState = None
        if is_async:
            # It's an SDK method, we use narrative proxy user to deal with sharing
            ujs_proxy = job_manager.proxy_client()
            appState = ujs_proxy.check_app_state(method_job_id)
        else:  # If it's NJS script method then we cannot use narrative proxy user
            appState = njsClient.check_app_state(method_job_id)
        for stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            appState['widget_outputs'] = app_state_output_into_method_output(workspace, token, wsClient, methodSpec, methodInputValues, rpcOut)
        appState['job_id'] = "method:" + appState['job_id']
        return appState
    else:
        input = {}
        rpcArgs = prepare_generic_method_input(token, workspace, methodSpec, methodInputValues, input);
        output = method_job_id
        methodOut = prepare_generic_method_output(token, workspace, methodSpec, input, output)
        return methodOut
def _app_get_state(workspace, token, URLS, job_manager, app_spec_json, method_specs_json, param_values_json, app_job_id):
    appSpec = json.loads(app_spec_json)
    paramValues = json.loads(correct_method_specs_json(param_values_json))
    methIdToSpec = json.loads(correct_method_specs_json(method_specs_json))
    njsClient = NarrativeJobService(URLS.job_service, token = token)
    wsClient = workspaceService(URLS.workspace, token = token)
    if app_job_id.startswith("njs:"):
        app_job_id = app_job_id[4:]
    appState = njsClient.check_app_state(app_job_id)
    appState['widget_outputs'] = {}
    prevStepReady = True
    for stepSpec in appSpec['steps']:
        stepId = stepSpec['step_id']
        methodId = stepSpec['method_id']
        methodSpec = methIdToSpec[methodId]
        if stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            prevStepReady = True
        elif 'output_mapping' in methodSpec['behavior'] and prevStepReady:
            rpcOut = None
            prevStepReady = True
        else:
            prevStepReady = False
            continue
        methodInputValues = extract_param_values(paramValues, stepId)
        appState['widget_outputs'][stepId] = app_state_output_into_method_output(workspace, token, wsClient, methodSpec, methodInputValues, rpcOut)
    appState['job_id'] = "njs:" + appState['job_id']
    return appState
示例#3
0
def _method_get_state(workspace, token, URLS, job_manager, method_spec_json,
                      param_values_json, method_job_id):
    methodSpec = json.loads(method_spec_json)
    methodInputValues = json.loads(
        correct_method_specs_json(param_values_json))
    njsClient = NarrativeJobService(URLS.job_service, token=token)
    wsClient = workspaceService(URLS.workspace, token=token)
    if method_job_id.startswith("method:"):
        method_job_id = method_job_id[7:]
        is_async = is_async_method(methodSpec)
        appState = None
        if is_async:
            # It's an SDK method, we use narrative proxy user to deal with sharing
            ujs_proxy = job_manager.proxy_client()
            appState = ujs_proxy.check_app_state(method_job_id)
        else:  # If it's NJS script method then we cannot use narrative proxy user
            appState = njsClient.check_app_state(method_job_id)
        for stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            appState['widget_outputs'] = app_state_output_into_method_output(
                workspace, token, wsClient, methodSpec, methodInputValues,
                rpcOut)
        appState['job_id'] = "method:" + appState['job_id']
        return appState
    else:
        input = {}
        rpcArgs = prepare_generic_method_input(token, workspace, methodSpec,
                                               methodInputValues, input)
        output = method_job_id
        methodOut = prepare_generic_method_output(token, workspace, methodSpec,
                                                  input, output)
        return methodOut
示例#4
0
def _app_get_state(workspace, token, URLS, job_manager, app_spec_json,
                   method_specs_json, param_values_json, app_job_id):
    appSpec = json.loads(app_spec_json)
    paramValues = json.loads(correct_method_specs_json(param_values_json))
    methIdToSpec = json.loads(correct_method_specs_json(method_specs_json))
    njsClient = NarrativeJobService(URLS.job_service, token=token)
    wsClient = workspaceService(URLS.workspace, token=token)
    if app_job_id.startswith("njs:"):
        app_job_id = app_job_id[4:]
    appState = njsClient.check_app_state(app_job_id)
    appState['widget_outputs'] = {}
    prevStepReady = True
    for stepSpec in appSpec['steps']:
        stepId = stepSpec['step_id']
        methodId = stepSpec['method_id']
        methodSpec = methIdToSpec[methodId]
        if stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            prevStepReady = True
        elif 'output_mapping' in methodSpec['behavior'] and prevStepReady:
            rpcOut = None
            prevStepReady = True
        else:
            prevStepReady = False
            continue
        methodInputValues = extract_param_values(paramValues, stepId)
        appState['widget_outputs'][
            stepId] = app_state_output_into_method_output(
                workspace, token, wsClient, methodSpec, methodInputValues,
                rpcOut)
    appState['job_id'] = "njs:" + appState['job_id']
    return appState
def _method_get_state(workspace, token, URLS, job_manager, method_spec_json, param_values_json, method_job_id):
    methodSpec = json.loads(method_spec_json)
    methodInputValues = json.loads(param_values_json)
    njsClient = NarrativeJobService(URLS.job_service, token = token)
    wsClient = workspaceService(URLS.workspace, token = token)
    if method_job_id.startswith("method:"):
        method_job_id = method_job_id[7:]
        appState = njsClient.check_app_state(method_job_id)
        for stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            appState['widget_outputs'] = app_state_output_into_method_output(workspace, token, wsClient, methodSpec, methodInputValues, rpcOut)
        appState['job_id'] = "method:" + appState['job_id']
        return appState
    else:
        input = {}
        rpcArgs = prepare_generic_method_input(token, workspace, methodSpec, methodInputValues, input);
        output = method_job_id
        methodOut = prepare_generic_method_output(token, workspace, methodSpec, input, output)
        return methodOut
示例#6
0
def _method_get_state(workspace, token, URLS, job_manager, method_spec_json,
                      param_values_json, method_job_id):
    methodSpec = json.loads(method_spec_json)
    methodInputValues = json.loads(param_values_json)
    njsClient = NarrativeJobService(URLS.job_service, token=token)
    wsClient = workspaceService(URLS.workspace, token=token)
    if method_job_id.startswith("method:"):
        method_job_id = method_job_id[7:]
        appState = njsClient.check_app_state(method_job_id)
        for stepId in appState['step_outputs']:
            rpcOut = appState['step_outputs'][stepId]
            appState['widget_output'] = app_state_output_into_method_output(
                workspace, token, wsClient, methodSpec, methodInputValues,
                rpcOut)
        appState['job_id'] = "method:" + appState['job_id']
        return appState
    else:
        input = {}
        rpcArgs = prepare_generic_method_input(token, workspace, methodSpec,
                                               methodInputValues, input)
        output = method_job_id
        methodOut = prepare_generic_method_output(token, workspace, methodSpec,
                                                  input, output)
        return methodOut