How to use the batchflow.config.Config function in batchflow

To help you get started, we’ve selected a few batchflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github analysiscenter / batchflow / batchflow / config.py View on Github external
variable = variable.strip('/')
        if '/' in variable:
            var = variable.split('/')
            prefix = var[:-1]
            var_name = var[-1]
        else:
            prefix = []
            var_name = variable

        for i, p in enumerate(prefix):
            if p not in config:
                config[p] = dict()
            if isinstance(config[p], dict):
                config = config[p]
            else: # for example, we put value with key 'a/b' into `{a: c}`
                value = Config({'/'.join(prefix[i+1:] + [var_name]): value})
                var_name = p
                break
        if var_name in config and isinstance(config[var_name], dict) and isinstance(value, Config):
            config[var_name] = Config(config[var_name])
            config[var_name].update(value)
            config[var_name] = config[var_name].config
        else:
            if isinstance(value, Config):
                config[var_name] = value.config
            else:
                config[var_name] = value
github analysiscenter / batchflow / batchflow / config.py View on Github external
""" Put a new variable into config

        Parameters
        ----------
        variable : str
            variable to add. '/' is used to put value into nested dict
        value : masc
        config : dict, Config or None
            if None value will be putted into self.config else from config
        """
        if config is None:
            config = self.config
        elif isinstance(config, Config):
            config = config.config
        if isinstance(value, dict):
            value = Config(value)
        variable = variable.strip('/')
        if '/' in variable:
            var = variable.split('/')
            prefix = var[:-1]
            var_name = var[-1]
        else:
            prefix = []
            var_name = variable

        for i, p in enumerate(prefix):
            if p not in config:
                config[p] = dict()
            if isinstance(config[p], dict):
                config = config[p]
            else: # for example, we put value with key 'a/b' into `{a: c}`
                value = Config({'/'.join(prefix[i+1:] + [var_name]): value})
github analysiscenter / batchflow / batchflow / models / base.py View on Github external
def pop(cls, variables, config, **kwargs):
        """ Return variables and remove them from config"""
        return Config().pop(variables, config, **kwargs)
github analysiscenter / batchflow / batchflow / config.py View on Github external
var_name = var[-1]
        else:
            prefix = []
            var_name = variable

        for i, p in enumerate(prefix):
            if p not in config:
                config[p] = dict()
            if isinstance(config[p], dict):
                config = config[p]
            else: # for example, we put value with key 'a/b' into `{a: c}`
                value = Config({'/'.join(prefix[i+1:] + [var_name]): value})
                var_name = p
                break
        if var_name in config and isinstance(config[var_name], dict) and isinstance(value, Config):
            config[var_name] = Config(config[var_name])
            config[var_name].update(value)
            config[var_name] = config[var_name].config
        else:
            if isinstance(value, Config):
                config[var_name] = value.config
            else:
                config[var_name] = value
github analysiscenter / batchflow / batchflow / models / base.py View on Github external
def put(cls, variable, value, config):
        """ Put a new variable into config """
        return Config().put(variable, value, config)
github analysiscenter / batchflow / batchflow / config.py View on Github external
for i, p in enumerate(prefix):
            if p not in config:
                config[p] = dict()
            if isinstance(config[p], dict):
                config = config[p]
            else: # for example, we put value with key 'a/b' into `{a: c}`
                value = Config({'/'.join(prefix[i+1:] + [var_name]): value})
                var_name = p
                break
        if var_name in config and isinstance(config[var_name], dict) and isinstance(value, Config):
            config[var_name] = Config(config[var_name])
            config[var_name].update(value)
            config[var_name] = config[var_name].config
        else:
            if isinstance(value, Config):
                config[var_name] = value.config
            else:
                config[var_name] = value
github analysiscenter / batchflow / batchflow / models / base.py View on Github external
def pop(cls, variables, config, **kwargs):
        """ Return variables and remove them from config"""
        return Config().pop(variables, config, **kwargs)
github analysiscenter / batchflow / batchflow / config.py View on Github external
def __add__(self, other):
        if isinstance(other, dict):
            other = Config(other)
        return Config([*self.flatten().items(), *other.flatten().items()])
github analysiscenter / batchflow / batchflow / pipeline.py View on Github external
def __lshift__(self, other):
        new_p = self.from_pipeline(self)
        if isinstance(other, Baseset):
            new_p.dataset = other
            return new_p
        if isinstance(other, (Config, dict)):
            new_p.set_config(other)
            return new_p
        raise TypeError("Pipeline might take only Dataset or Config. Use as pipeline << dataset or pipeine << config")