Exemple #1
0
    def load_parameter_function(self, row):
        name = row['Name']
        ftype = row['Function Type']
        func_expr = row['Function']
        owner = row['Owner']
        args = ast.literal_eval(row['Args'])
        #kwargs    = row['Kwargs']
        descr = row['Description']

        data_process_management = DataProcessManagementServiceProcessClient(
            self)

        function_type = None
        if ftype == 'PythonFunction':
            function_type = PFT.PYTHON
        elif ftype == 'NumexprFunction':
            function_type = PFT.NUMEXPR
        else:
            raise Conflict('Unsupported Function Type: %s' % ftype)

        parameter_function = ParameterFunctionResource(
            name=name,
            function=func_expr,
            function_type=function_type,
            owner=owner,
            args=args,
            description=descr)
        parameter_function.alt_ids = ['PRE:' + row['ID']]

        parameter_function_id = self.create_parameter_function(
            parameter_function)

        dpd = DataProcessDefinition()
        dpd.name = name
        dpd.description = 'Parameter Function Definition for %s' % name
        dpd.data_process_type = DataProcessTypeEnum.PARAMETER_FUNCTION
        dpd.parameters = args

        data_process_management.create_data_process_definition(
            dpd, parameter_function_id)

        return parameter_function_id
    def load_parameter_function(self, row):
        name      = row['Name']
        ftype     = row['Function Type']
        func_expr = row['Function']
        owner     = row['Owner']
        args      = ast.literal_eval(row['Args'])
        #kwargs    = row['Kwargs']
        descr     = row['Description']

        data_process_management = DataProcessManagementServiceProcessClient(self)

        function_type=None
        if ftype == 'PythonFunction':
            function_type = PFT.PYTHON
        elif ftype == 'NumexprFunction':
            function_type = PFT.NUMEXPR
        else:
            raise Conflict('Unsupported Function Type: %s' % ftype)
        
        parameter_function = ParameterFunctionResource(
                    name=name, 
                    function=func_expr,
                    function_type=function_type,
                    owner=owner,
                    args=args,
                    description=descr)
        parameter_function.alt_ids = ['PRE:' + row['ID']]

        parameter_function_id = self.create_parameter_function(parameter_function)
        

        dpd = DataProcessDefinition()
        dpd.name = name
        dpd.description = 'Parameter Function Definition for %s' % name
        dpd.data_process_type = DataProcessTypeEnum.PARAMETER_FUNCTION
        dpd.parameters = args

        data_process_management.create_data_process_definition(dpd, parameter_function_id)

        return parameter_function_id