def reify_centroid(self, resource_id): """ Extracts the REST API arguments from the centroid JSON structure: """ child = self.get_resource(resource_id) _, parent = u.get_origin_info(child) parent = self.get_resource(parent) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent, opts) # non-default create options u.non_default_opts(child, opts) opts['create'].update({'input_data': child['input_data']}) # name, exclude automatic naming alternatives u.non_automatic_name(child, opts) # non-default update options u.non_default_opts(child, opts, call="update") calls = u.build_calls(resource_id, [parent['resource']], opts) self.add(resource_id, calls)
def reify_evaluation(self, resource_id): """ Extracts the REST API arguments from the evaluation JSON structure: model/ensemble, dataset and args """ child = self.get_resource(resource_id) # evalutations have 2 different origins as arguments [(_, parent1), (_, parent2)] = u.get_origin_info(child) parent1 = self.get_resource(parent1) parent2 = self.get_resource(parent2) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent1, opts) # non-default create options u.non_default_opts(child, opts) u.fields_map_options(child, parent1, parent2, opts, call="create") # name, exclude automatic naming alternatives u.non_automatic_name(child, opts) # range in dataset if not child.get('range', []) in [[], None, \ [1, parent2.get('rows', None)]]: opts['create'].update({"range": child['range']}) calls = u.build_calls(resource_id, [parent1['resource'], parent2['resource']], opts) self.add(resource_id, calls)
def reify_prediction(self, resource_id): """ Extracts the REST API arguments from the prediction JSON structure: """ child = self.get_resource(resource_id) origin, parent = u.get_origin_info(child) if origin == 'models': model = self.get_resource(parent[0]) parent = self.get_resource('ensemble/%s' % model['ensemble_id']) else: parent = self.get_resource(parent) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent, opts) # non-default create options u.non_default_opts(child, opts) opts['create'].update({'input_data': child['input_data']}) # name, exclude automatic naming alternatives u.non_automatic_name( child, opts) calls = u.build_calls(resource_id, [parent['resource']], opts) self.add(resource_id, calls)
def reify_prediction(self, resource_id): """ Extracts the REST API arguments from the prediction JSON structure: """ child = self.get_resource(resource_id) origin, parent = u.get_origin_info(child) if origin == 'models': model = self.get_resource(parent[0]) parent = self.get_resource('ensemble/%s' % model['ensemble_id']) else: parent = self.get_resource(parent) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent, opts) # non-default create options u.non_default_opts(child, opts) opts['create'].update({'input_data': child['input_data']}) # name, exclude automatic naming alternatives u.non_automatic_name(child, opts) calls = u.build_calls(resource_id, [parent['resource']], opts) self.add(resource_id, calls)
def reify_centroid(self, resource_id): """ Extracts the REST API arguments from the centroid JSON structure: """ child = self.get_resource(resource_id) _, parent = u.get_origin_info(child) parent = self.get_resource(parent) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent, opts) # non-default create options u.non_default_opts(child, opts) opts['create'].update({'input_data': child['input_data']}) # name, exclude automatic naming alternatives u.non_automatic_name( child, opts) # non-default update options u.non_default_opts(child, opts, call="update") calls = u.build_calls(resource_id, [parent['resource']], opts) self.add(resource_id, calls)
def reify_prediction(self, resource_id): """ Extracts the REST API arguments from the prediction JSON structure: """ child = self.get_resource(resource_id) origin, parent = u.get_origin_info(child) if origin == "models": model = self.get_resource(parent[0]) parent = self.get_resource("ensemble/%s" % model["ensemble_id"]) else: parent = self.get_resource(parent) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent, opts) # non-default create options u.non_default_opts(child, opts) opts["create"].update({"input_data": child["input_data"]}) # name, exclude automatic naming alternatives u.non_automatic_name(child, opts, autoname=u"Prediction for %s" % child["objective_field_name"]) calls = u.build_calls(resource_id, [parent["resource"]], opts) self.add(resource_id, calls)
def reify_ensemble(self, resource_id): """Extracts the REST API arguments from the ensemble JSON structure """ child = self.get_resource(resource_id) _, parent_id = u.get_origin_info(child) # add options defined at model level _, opts = self._inspect_model(child['models'][0]) # the default value for replacement in models is the oposite, so # it will be added afterwards if 'replacement' in opts['create']: del opts['create']['replacement'] # create options u.non_default_opts(child, opts) calls = u.build_calls(resource_id, [parent_id], opts) self.add(resource_id, calls)
def reify_evaluation(self, resource_id): """ Extracts the REST API arguments from the evaluation JSON structure: model/ensemble, dataset and args """ child = self.get_resource(resource_id) # evalutations have 2 different origins as arguments [(_, parent1), (_, parent2)] = u.get_origin_info(child) parent1 = self.get_resource(parent1) parent2 = self.get_resource(parent2) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent1, opts) # non-default create options u.non_default_opts(child, opts) # model/ensemble to dataset mapping fields = parent2['fields'].keys() default_map = dict(zip(fields, fields)) opts['create'].update( u.default_setting(child, 'fields_map', default_map)) # name, exclude automatic naming alternatives u.non_automatic_name( child, opts, autoname=u'Evaluation of %s with %s' % \ (parent1.get('name', ''), parent2.get('name', ''))) # range in dataset if not child.get('range', []) in [[], [1, parent2.get('rows', None)]]: opts['create'].update({"range": child['range']}) calls = u.build_calls( resource_id, [parent1['resource'], parent2['resource']], opts) self.add(resource_id, calls)
def reify_evaluation(self, resource_id): """ Extracts the REST API arguments from the evaluation JSON structure: model/ensemble, dataset and args """ child = self.get_resource(resource_id) # evalutations have 2 different origins as arguments [(_, parent1), (_, parent2)] = u.get_origin_info(child) parent1 = self.get_resource(parent1) parent2 = self.get_resource(parent2) opts = {"create": {}, "update": {}} # non-inherited create options u.non_inherited_opts(child, parent1, opts) # non-default create options u.non_default_opts(child, opts) u.fields_map_options(child, parent1, parent2, opts, call="create") # name, exclude automatic naming alternatives u.non_automatic_name( child, opts) # range in dataset if not child.get('range', []) in [[], None, \ [1, parent2.get('rows', None)]]: opts['create'].update({"range": child['range']}) calls = u.build_calls( resource_id, [parent1['resource'], parent2['resource']], opts) self.add(resource_id, calls)