Esempio n. 1
0
 def test_get_rule_args(self):
     expected_param_names = [
         'project_id', 'dataset_id', 'sandbox_dataset_id'
     ]
     actual_rule_args = ce.get_rule_args(fake_rule_func)
     actual_param_names = [arg['name'] for arg in actual_rule_args]
     self.assertListEqual(expected_param_names, actual_param_names)
Esempio n. 2
0
def get_required_params(rules):
    """
    Get the full set of parameters required to run specified rules
    :param rules: list of cleaning rules
    :return: set of parameter names
    """
    result = dict()
    for rule in rules:
        clazz = rule[0]
        rule_args = clean_engine.get_rule_args(clazz)
        for rule_arg in rule_args:
            if rule_arg['required']:
                param_name = rule_arg['name']
                if param_name not in result.keys():
                    result[param_name] = list()
                result[param_name].append(clazz.__name__)
    return result