Esempio n. 1
0
    def submit_model(self, featureset, model_name, model_payload):
        # Fetch feature metadata
        resp = requests.get('{}/tmdb/schema/feature-store/{}'.format(
            self.solr_base_ep, featureset))
        resp_msg(msg='Submit Model {} Ftr Set {}'.format(
            model_name, featureset),
                 resp=resp)
        metadata = resp.json()
        features = metadata['features']

        feature_dict = {}
        for idx, value in enumerate(features):
            feature_dict[idx + 1] = value['name']

        feature_mapping, _ = self.feature_set('tmdb', featureset)

        solr_model = convert(model_payload, model_name, featureset,
                             feature_mapping)

        url = '{}/tmdb/schema/model-store'.format(self.solr_base_ep)
        resp = requests.delete('{}/{}'.format(url, model_name))
        resp_msg(msg='Deleted Model {}'.format(model_name), resp=resp)

        resp = requests.put(url, json=solr_model)
        resp_msg(msg='Created Model {}'.format(model_name), resp=resp)
Esempio n. 2
0
    def submit_ranklib_model(self, featureset, index, model_name,
                             model_payload):
        """ Submits a Ranklib model, converting it to Solr representation """
        resp = requests.get('{}/{}/schema/feature-store/{}'.format(
            self.solr_base_ep, index, featureset))
        resp_msg(msg='Submit Model {} Ftr Set {}'.format(
            model_name, featureset),
                 resp=resp)
        metadata = resp.json()
        features = metadata['features']

        feature_dict = {}
        for idx, value in enumerate(features):
            feature_dict[idx + 1] = value['name']

        feature_mapping, _ = self.feature_set(index, featureset)

        solr_model = convert(model_payload, model_name, featureset,
                             feature_mapping)
        self.submit_model(featureset, index, model_name, solr_model)