Beispiel #1
0
    def resurrect_app(self, app_name):
        """
        Return the 'live' encoder and decoder objects corresponding to the app with
        name 'app_name' in the database. They are deserialized from the states
        previously stored in the database.

        Parameters
        ----------
        app_name: string
            Name of the app to resurrect

        Returns
        -------
        BaseEncoder, BaseDecoder, BaseCollationElement
            The 'live' encoder, decoder and collation objects associated with this app

        """

        if not self._app:
            message = 'No app in JSON database'
            logger.critical(message)
            raise RuntimeError(message)

        if self._app['name'] != app_name:
            message = (f"JSON database does not contain app {app_name}"
                       f"App found was {self._app['name']}")
            logger.critical(message)
            raise RuntimeError(message)

        encoder = BaseEncoder.deserialize(self._app['input_encoder'])
        decoder = BaseDecoder.deserialize(self._app['output_decoder'])
        collater = BaseCollationElement.deserialize(self._app['collater'])
        return encoder, decoder, collater
Beispiel #2
0
    def resurrect_app(self, app_name):
        """
        Return the 'live' encoder, decoder and collation objects corresponding to the app with
        name 'app_name' in the database. They are deserialized from the states previously
        stored in the database.

        Parameters
        ----------
        app_name: string
            Name of the app to resurrect

        Returns
        -------
        BaseEncoder, BaseDecoder, BaseCollationElement
            The 'live' encoder and decoder objects associated with this app

        """

        app_info = self.app(app_name)

        encoder = BaseEncoder.deserialize(app_info['input_encoder'])
        decoder = BaseDecoder.deserialize(app_info['output_decoder'])
        return encoder, decoder