def __init__(self, compressor_id, early_config, compressor_config, name): """wrapper for a libpressio compressor object params: compressor_id: str - the compressor_id for the underlying compressor early_config: dict - converted to pressio_options to configure the structure of the compressor compressor_config: dict - converted to pressio_options to configure the compressor name: str - name to use for the compressor when used in a hierarchical mode """ try: library = pressio.instance() self._compressor = pressio.get_compressor(library, compressor_id.encode()) if self._compressor is None: raise PressioException.from_library(library) if name is not None: pressio.compressor_set_name(self._compressor, name.encode()) early_config_lp = _python_to_pressio(early_config) pressio.compressor_set_options(self._compressor, early_config_lp) pressio.options_free(early_config_lp) config_lp = pressio.compressor_get_options(self._compressor) config_lp = _python_to_pressio(compressor_config, config_lp) pressio.compressor_set_options(self._compressor, config_lp) pressio.options_free(config_lp) finally: pressio.release(library)
def __init__(self, ids, early_config, metrics_config, name): try: config_lp = None library = pressio.instance() metrics_ids = pressio.vector_string([i.encode() for i in ids]) self._metric = pressio.new_metrics(library, metrics_ids) self._metric_id = "composite" if not self._metric: raise PressioException.from_library(library) if name is not None: pressio.metrics_set_name(self._metric, name.encode()) early_config_lp = _python_to_pressio(early_config) pressio.metrics_set_options(self._metric, early_config_lp) pressio.options_free(early_config_lp) config_lp_template = pressio.metrics_get_options(self._metric) config_lp = _python_to_pressio(metrics_config, config_lp_template) pressio.metrics_set_options(self._metric, config_lp) finally: pressio.release(library) pressio.options_free(config_lp) pressio.options_free(config_lp_template)
def __init__(self, io, early_config, io_config, name): try: config_lp = None library = pressio.instance() self._io = pressio.get_io(library, io.encode()) if not self._io: raise PressioException.from_library(library) if name is not None: pressio.compressor_set_name(self._io, name.encode()) early_config_lp = _python_to_pressio(early_config) pressio.io_set_options(self._io, early_config_lp) pressio.options_free(early_config_lp) config_lp = pressio.io_get_options(self._io) config_lp = _python_to_pressio(io_config, config_lp) pressio.io_set_options(self._io, config_lp) finally: pressio.release(library) pressio.options_free(config_lp)