コード例 #1
0
    def __init__(self, config):
        if not set(must_have).issubset(set(config.keys())):
            raise RuntimeError(
                'SourceProxy misconfigured. Must have {} defined'.format(must_have))
        self.source_channel = config['channel_name']
        self.data_keys = translate_all(config['Dataproducts'])
        self.retries = config.get('retries', RETRIES)
        self.retry_to = config.get('retry_timeout', RETRY_TO)
        self.logger = logging.getLogger()

        # Hack - it is possible for a subclass to declare @produces,
        #        in which case, we do not want to override that.
        if not self._produces:
            self._produces = {new_name: Any for new_name in self.data_keys.values()}
コード例 #2
0
    def __init__(self, config):
        super().__init__(config)

        if not set(must_have).issubset(set(config.keys())):
            raise RuntimeError(
                f"SourceProxy misconfigured. Must have {must_have} defined")
        self.source_channel = config["source_channel"]
        self.data_keys = translate_all(config["Dataproducts"])
        self.max_attempts = config.get("max_attempts", MAX_ATTEMPTS)
        self.retry_interval = config.get("retry_interval", RETRY_INTERVAL)

        self._produces = {
            new_name: Any
            for new_name in self.data_keys.values()
        }
コード例 #3
0
def test_translate_all():
    specs = ["old", "old1 -> new1"]
    assert translate_all(specs) == {"old": "old", "old1": "new1"}