Beispiel #1
0
def update_execution(filename: str) -> jsonify:
    service_type = request.args.get(Constants.TYPE_PARAM_NAME)
    description = request.json[Constants.DESCRIPTION_FIELD_NAME]
    class_method_name = request.json[Constants.METHOD_FIELD_NAME]
    method_parameters = request.json[Constants.METHOD_PARAMETERS_FIELD_NAME]

    storage = None
    if service_type == Constants.EXPLORE_TENSORFLOW_TYPE or \
            service_type == Constants.EXPLORE_SCIKITLEARN_TYPE:
        storage = explore_storage
    elif service_type == Constants.TRANSFORM_TENSORFLOW_TYPE or \
            Constants.TRANSFORM_SCIKITLEARN_TYPE:
        storage = transform_storage

    data = Data(database, storage)

    request_errors = analyse_patch_request_errors(request_validator, data,
                                                  filename, class_method_name,
                                                  method_parameters)

    if request_errors is not None:
        return request_errors

    module_path, class_name = data.get_module_and_class(filename)
    class_parameters = data.get_class_parameters(filename)

    parameters = Parameters(database, data)
    metadata_creator = Metadata(database)

    execution = Execution(database, filename, service_type, storage,
                          metadata_creator, module_path, class_name,
                          class_parameters, parameters)

    execution.update(class_method_name, method_parameters, description)

    response_params = None
    if service_type == Constants.TRANSFORM_TENSORFLOW_TYPE or \
            service_type == Constants.TRANSFORM_SCIKITLEARN_TYPE:
        response_params = Constants.MICROSERVICE_URI_GET_PARAMS

    return (
        jsonify({
            Constants.MESSAGE_RESULT:
            f'{Constants.MICROSERVICE_URI_SWITCHER[service_type]}'
            f'{filename}{response_params}'
        }),
        Constants.HTTP_STATUS_CODE_SUCCESS_CREATED,
    )