Ejemplo n.º 1
0
 def get_config(self):
     return {
         'name': self.name,
         'url_prefix': self.url_prefix,
         'working_directory': self._working_dir,
         'data_set': plugin.to_plugin_config(self._data_set),
         'descr_generator': plugin.to_plugin_config(self._descriptor_generator),
         'nn_index': plugin.to_plugin_config(self._nn_index),
         'rel_index_config': self._rel_index_config,
     }
Ejemplo n.º 2
0
 def get_config(self):
     return {
         'name': self.name,
         'url_prefix': self.url_prefix,
         'working_directory': self._working_dir,
         'data_set': plugin.to_plugin_config(self._data_set),
         'descr_generator': plugin.to_plugin_config(self._descriptor_generator),
         'nn_index': plugin.to_plugin_config(self._nn_index),
         'rel_index_config': self._rel_index_config,
         'descriptor_factory': self._descr_elem_factory.get_config(),
     }
Ejemplo n.º 3
0
 def get_config(self):
     hi_conf = None
     if self.hash_index is not None:
         hi_conf = plugin.to_plugin_config(self.hash_index)
     return {
         "lsh_functor": plugin.to_plugin_config(self.lsh_functor),
         "descriptor_index": plugin.to_plugin_config(self.descriptor_index),
         "hash_index": hi_conf,
         "hash2uuids_kvstore":
             plugin.to_plugin_config(self.hash2uuids_kvstore),
         "distance_method": self.distance_method,
         "read_only": self.read_only,
     }
Ejemplo n.º 4
0
 def get_config(self):
     hi_conf = None
     if self.hash_index is not None:
         hi_conf = plugin.to_plugin_config(self.hash_index)
     return {
         "lsh_functor": plugin.to_plugin_config(self.lsh_functor),
         "descriptor_index": plugin.to_plugin_config(self.descriptor_index),
         "hash_index": hi_conf,
         "hash2uuids_kvstore":
             plugin.to_plugin_config(self.hash2uuids_kvstore),
         "distance_method": self.distance_method,
         "read_only": self.read_only,
     }
Ejemplo n.º 5
0
Archivo: itq.py Proyecto: Kitware/SMQTK
 def get_config(self):
     # If no cache elements (set to None), return default plugin configs.
     c = merge_dict(self.get_default_config(), {
         "bit_length": self.bit_length,
         "itq_iterations": self.itq_iterations,
         "normalize": self.normalize,
         "random_seed": self.random_seed,
     })
     if self.mean_vec_cache_elem:
         c['mean_vec_cache'] = \
             plugin.to_plugin_config(self.mean_vec_cache_elem)
     if self.rotation_cache_elem:
         c['rotation_cache'] = \
             plugin.to_plugin_config(self.rotation_cache_elem)
     return c
Ejemplo n.º 6
0
 def get_config(self):
     hi_conf = None
     if self.hash_index is not None:
         hi_conf = plugin.to_plugin_config(self.hash_index)
     return {
         "lsh_functor": plugin.to_plugin_config(self.lsh_functor),
         "descriptor_index": plugin.to_plugin_config(self.descriptor_index),
         "hash_index": hi_conf,
         "hash2uuid_cache_filepath": self.hash2uuid_cache_filepath,
         "distance_method": self.distance_method,
         "read_only": self.read_only,
         "live_reload": self.live_reload,
         "reload_mon_interval": self.reload_mon_interval,
         "reload_settle_window": self.reload_settle_window,
     }
Ejemplo n.º 7
0
 def get_config(self):
     hi_conf = None
     if self.hash_index is not None:
         hi_conf = plugin.to_plugin_config(self.hash_index)
     return {
         "lsh_functor": plugin.to_plugin_config(self.lsh_functor),
         "descriptor_index": plugin.to_plugin_config(self.descriptor_index),
         "hash_index": hi_conf,
         "hash2uuid_cache_filepath": self.hash2uuid_cache_filepath,
         "distance_method": self.distance_method,
         "read_only": self.read_only,
         "live_reload": self.live_reload,
         "reload_mon_interval": self.reload_mon_interval,
         "reload_settle_window": self.reload_settle_window,
     }
Ejemplo n.º 8
0
 def get_config(self):
     c = self.get_default_config()
     if self.cache_element:
         c['cache_element'] = merge_dict(c['cache_element'],
                                         plugin.to_plugin_config(
                                             self.cache_element))
     return c
Ejemplo n.º 9
0
 def get_config(self):
     # If no cache elements (set to None), return default plugin configs.
     c = merge_dict(
         self.get_default_config(), {
             "bit_length": self.bit_length,
             "itq_iterations": self.itq_iterations,
             "normalize": self.normalize,
             "random_seed": self.random_seed,
         })
     if self.mean_vec_cache_elem:
         c['mean_vec_cache'] = \
             plugin.to_plugin_config(self.mean_vec_cache_elem)
     if self.rotation_cache_elem:
         c['rotation_cache'] = \
             plugin.to_plugin_config(self.rotation_cache_elem)
     return c
Ejemplo n.º 10
0
    def get_default_config(cls):
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        By default, we observe what this class's constructor takes as arguments,
        turning those argument names into configuration dictionary keys. If any
        of those arguments have defaults, we will add those values into the
        configuration dictionary appropriately. The dictionary returned should
        only contain JSON compliant value types.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        :rtype: dict

        """
        default = super(ITQNearestNeighborsIndex, cls).get_default_config()

        # replace ``code_index`` with nested plugin configuration
        index_conf = plugin.make_config(get_code_index_impls)
        if default['code_index'] is not None:
            # Only overwrite default config if there is a default value
            index_conf.update(plugin.to_plugin_config(default['code_index']))
        default['code_index'] = index_conf

        return default
Ejemplo n.º 11
0
 def get_config(self):
     c = self.get_default_config()
     if self.cache_element:
         c['cache_element'] = merge_dict(c['cache_element'],
                                         plugin.to_plugin_config(
                                             self.cache_element))
     return c
Ejemplo n.º 12
0
 def get_config(self):
     # Recursively get config from data element if we have one.
     if hasattr(self._cache_element, 'get_config'):
         elem_config = to_plugin_config(self._cache_element)
     else:
         elem_config = None
     return {'cache_element': elem_config}
Ejemplo n.º 13
0
 def get_config(self):
     c = merge_dict(self.get_default_config(), {
         "pickle_protocol": self.pickle_protocol,
     })
     if self.cache_element:
         merge_dict(c['cache_element'],
                    plugin.to_plugin_config(self.cache_element))
     return c
Ejemplo n.º 14
0
 def get_config(self):
     # Recursively get config from data element if we have one.
     if hasattr(self._cache_element, 'get_config'):
         elem_config = to_plugin_config(self._cache_element)
     else:
         # No cache element, output default config with no type.
         elem_config = make_config(get_data_element_impls())
     return {'cache_element': elem_config}
Ejemplo n.º 15
0
 def get_config(self):
     c = merge_dict(self.get_default_config(), {
         "pickle_protocol": self.pickle_protocol,
     })
     if self.cache_element:
         merge_dict(c['cache_element'],
                    plugin.to_plugin_config(self.cache_element))
     return c
Ejemplo n.º 16
0
    def test_to_config(self):
        i = DummyAlgo1()
        d1 = i.get_config()
        c = to_plugin_config(i)
        self.assertEqual(c, {
            'type': 'DummyAlgo1',
            'DummyAlgo1': d1,
        })

        # return should update with updates to
        i.foo = 8
        d2 = i.get_config()
        self.assertNotEqual(d1, d2)
        c = to_plugin_config(i)
        self.assertEqual(c, {
            'type': 'DummyAlgo1',
            'DummyAlgo1': d2,
        })
Ejemplo n.º 17
0
    def test_to_config(self):
        i = DummyAlgo1()
        d1 = i.get_config()
        c = to_plugin_config(i)
        self.assertEqual(c, {
            'type': 'DummyAlgo1',
            'DummyAlgo1': d1,
        })

        # return should update with updates to
        i.foo = 8
        d2 = i.get_config()
        self.assertNotEqual(d1, d2)
        c = to_plugin_config(i)
        self.assertEqual(c, {
            'type': 'DummyAlgo1',
            'DummyAlgo1': d2,
        })
Ejemplo n.º 18
0
 def get_config(self):
     return {
         "descriptor_set": plugin.to_plugin_config(self._descriptor_set),
         "exhaustive": self.exhaustive,
         "read_only": self.read_only,
         "random_seed": self.random_seed,
         "pickle_protocol": self.pickle_protocol,
         "use_multiprocessing": self.use_multiprocessing,
     }
Ejemplo n.º 19
0
 def get_config(self):
     # Recursively get config from data element if we have one.
     if hasattr(self._cache_element, 'get_config'):
         elem_config = to_plugin_config(self._cache_element)
     else:
         # No cache element, output default config with no type.
         elem_config = make_config(get_data_element_impls())
     return {
         'cache_element': elem_config
     }
Ejemplo n.º 20
0
 def get_config(self):
     c = merge_dict(self.get_default_config(), {
         'leaf_size': self.leaf_size,
         'random_seed': self.random_seed,
     })
     if self.cache_element:
         c['cache_element'] = merge_dict(
             c['cache_element'],
             plugin.to_plugin_config(self.cache_element))
     return c
Ejemplo n.º 21
0
 def get_config(self):
     return {
         "mean_vec_filepath": self._mean_vec_cache_filepath,
         "rotation_filepath": self._rotation_cache_filepath,
         "code_index": plugin.to_plugin_config(self._code_index),
         "bit_length": self._bit_len,
         "itq_iterations": self._itq_iter_num,
         "distance_method": self._dist_method,
         'random_seed': self._rand_seed,
     }
Ejemplo n.º 22
0
    def get_config(self):
        config = {
            "descriptor_set": plugin.to_plugin_config(self._descriptor_set),
            "uid2idx_kvs": plugin.to_plugin_config(self._uid2idx_kvs),
            "idx2uid_kvs": plugin.to_plugin_config(self._idx2uid_kvs),
            "factory_string": self.factory_string,
            "read_only": self.read_only,
            "random_seed": self.random_seed,
            "use_multiprocessing": self.use_multiprocessing,
            "use_gpu": self._use_gpu,
            "gpu_id": self._gpu_id,
        }
        if self._index_element:
            config['index_element'] = plugin.to_plugin_config(
                self._index_element)
        if self._index_param_element:
            config['index_param_element'] = plugin.to_plugin_config(
                self._index_param_element)

        return config
Ejemplo n.º 23
0
 def get_config(self):
     return {
         "descriptor_set": plugin.to_plugin_config(self._descriptor_set),
         "index_filepath": self._index_filepath,
         "parameters_filepath": self._index_param_filepath,
         "read_only": self._read_only,
         "random_seed": self._rand_seed,
         "pickle_protocol": self._pickle_protocol,
         "use_multiprocessing": self._use_multiprocessing,
         "depth": self._depth,
         "num_trees": self._num_trees,
     }
Ejemplo n.º 24
0
 def get_config(self):
     return {
         "descriptor_set": plugin.to_plugin_config(self._descriptor_set),
         "index_filepath": self._index_filepath,
         "parameters_filepath": self._index_param_filepath,
         "read_only": self._read_only,
         "random_seed": self._rand_seed,
         "pickle_protocol": self._pickle_protocol,
         "use_multiprocessing": self._use_multiprocessing,
         "depth": self._depth,
         "num_trees": self._num_trees,
     }
Ejemplo n.º 25
0
    def get_default_config(cls):
        """
        Generate and return a default configuration dictionary for this class.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        :rtype: dict
        """
        c = super(KVSDataSet, cls).get_default_config()
        c['kvstore'] = merge_dict(
            plugin.make_config(get_key_value_store_impls()),
            plugin.to_plugin_config(c['kvstore']))
        return c
Ejemplo n.º 26
0
    def get_config(self):
        """
        This implementation has no configuration properties.

        :return: JSON type compliant configuration dictionary.
        :rtype: dict

        """
        c = merge_dict(self.get_default_config(), {
            "pickle_protocol": self.pickle_protocol,
        })
        if self.cache_element:
            c['cache_element'] = merge_dict(
                c['cache_element'],
                plugin.to_plugin_config(self.cache_element))
        return c
Ejemplo n.º 27
0
    def get_default_config(cls):
        """
        Generate and return a default configuration dictionary for this class.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        :rtype: dict
        """
        c = super(KVSDataSet, cls).get_default_config()
        c['kvstore'] = merge_dict(
            plugin.make_config(get_key_value_store_impls()),
            plugin.to_plugin_config(c['kvstore'])
        )
        return c
Ejemplo n.º 28
0
 def get_config(self):
     with self._label_to_classifier_lock:
         c = dict((label, plugin.to_plugin_config(classifier))
                  for label, classifier
                  in six.iteritems(self._label_to_classifier))
     return c
Ejemplo n.º 29
0
 def get_config(self):
     return {'kvstore': plugin.to_plugin_config(self._kvstore)}
Ejemplo n.º 30
0
 def get_config(self):
     return {
         'iqr_service_url': self._iqr_service.url,
         'working_directory': self._working_dir,
         'data_set': plugin.to_plugin_config(self._data_set),
     }
Ejemplo n.º 31
0
 def get_config(self):
     return {
         'iqr_service_url': self._iqr_service.url,
         'working_directory': self._working_dir,
         'data_set': plugin.to_plugin_config(self._data_set),
     }
Ejemplo n.º 32
0
 def get_config(self):
     return {
         'kvstore': plugin.to_plugin_config(self._kvstore)
     }