def meta_parameters(): meta_parameters = { "meta_parameters": { "start_year": { "title": "Start Year", "type": "int", "default": 2017, "validators": { "range": { "min": 2013, "max": 2028 } }, }, "data_source": { "title": "Data Source", "type": "str", "default": "PUF", "validators": { "choice": { "choices": ["PUF", "CPS"] } }, }, "use_full_sample": { "title": "Use full sample", "type": "bool", "default": True, "validators": {}, }, } } return translate_to_django(meta_parameters)
def meta_param(): return translate_to_django( { "meta_parameters": { "metaparam": { "title": "Meta-Param", "type": "int", "default": 1, "validators": {}, } } } )
def pt_metaparam(TestParams): return translate_to_django( { "meta_parameters": { "dim0": { "title": "dim 0", "type": "str", "default": "zero", "validators": {"choice": {"choices": ["zero", "one"]}}, } } } )
def test_translate(): metaparameters = { "use_full_data": { "title": "Use full data", "description": "use full data...", "value": True, "type": "bool", "validators": {}, } } result = translate_to_django(metaparameters) mp = next(v for v in result.parameters.values()) assert mp.title == "Use full data" assert next(k for k in result.parameters.keys()) == "use_full_data" assert mp.value == True assert isinstance(mp.field, forms.TypedChoiceField)
def test_translate(): metaparameters = { "meta_parameters": { "use_full_data": { "title": "Use full data", "default": True, "type": "bool", "validators": {}, } } } result = translate_to_django(metaparameters) mp = result.parameters[0] assert mp.title == "Use full data" assert mp.name == "use_full_data" assert mp.default == True assert isinstance(mp.field, forms.TypedChoiceField)
def meta_param(meta_param_dict): return translate_to_django(meta_param_dict)
def parsed_meta_parameters(self): if isinstance(self.meta_parameters, str): meta_params = json.loads(self.meta_parameters) else: meta_params = self.meta_parameters return translate_to_django(meta_params)
def parsed_meta_parameters(self): res = self.package_defaults() return translate_to_django(res["meta_parameters"])