How to use merge_configs method in autotest

Best Python code snippet using autotest_python

configurations.py

Source:configurations.py Github

copy

Full Screen

...39 incfiles = [incfiles]40 for predfile in incfiles:41 confpath = os.path.join(self.tailseeker_dir, 'conf', predfile)42 predconf = self.load_config(open(confpath))43 confdict = self.merge_configs(confdict, predconf)44 confdict = self.merge_configs(confdict, usersettings)45 return confdict46 else:47 return usersettings48 def merge_configs(self, conf1, conf2):49 merged = {}50 for conf1only in set(conf1) - set(conf2):51 merged[conf1only] = conf1[conf1only]52 for conf2only in set(conf2) - set(conf1):53 merged[conf2only] = conf2[conf2only]54 for shared in set(conf1) & set(conf2):55 if isinstance(conf1[shared], dict) != isinstance(conf1[shared], dict):56 raise ValueError('Layout is different between overriding configurations.')57 if isinstance(conf1[shared], dict):58 merged[shared] = self.merge_configs(conf1[shared], conf2[shared])59 else:60 merged[shared] = conf2[shared] # conf2 is overriding conf1.61 return merged62 def __getitem__(self, name):63 return self.confdata[name]64 def __contains__(self, name):65 return name in self.confdata66 def get(self, name, default=None):67 return self.confdata.get(name, default)68 def expand_sample_settings(self, node):69 predefined = {70 '_all': self.all_samples,71 '_exp': self.exp_samples,72 '_spk': self.spikein_samples,...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...50 args = parser.parse_args()51 if 'LOCAL_RANK' not in os.environ:52 os.environ['LOCAL_RANK'] = str(args.local_rank)53 return args54def merge_configs(cfg1, cfg2):55 # Merge cfg2 into cfg156 # Overwrite cfg1 if repeated, ignore if value is None.57 cfg1 = {} if cfg1 is None else cfg1.copy()58 cfg2 = {} if cfg2 is None else cfg259 for k, v in cfg2.items():60 if v:61 cfg1[k] = v62 return cfg163def main():64 args = parse_args()65 cfg = mmcv.Config.fromfile(args.config)66 # Load output_config from cfg67 output_config = cfg.get('output_config', {})68 # Overwrite output_config from args.out69 output_config = merge_configs(output_config, dict(out=args.out))70 # Load eval_config from cfg71 eval_config = cfg.get('eval_config', {})72 # Overwrite eval_config from args.eval73 eval_config = merge_configs(eval_config, dict(metrics=args.eval))74 # Add options from args.option75 eval_config = merge_configs(eval_config, args.options)76 assert output_config or eval_config, \77 ('Please specify at least one operation (save or eval the '78 'results) with the argument "--out" or "--eval"')79 # set cudnn benchmark80 if cfg.get('cudnn_benchmark', False):81 torch.backends.cudnn.benchmark = True82 cfg.data.test.test_mode = True83 if cfg.test_cfg is None:84 cfg.test_cfg = dict(average_clips=args.average_clips)85 else:86 cfg.test_cfg.average_clips = args.average_clips87 # init distributed env first, since logger depends on the dist info.88 if args.launcher == 'none':89 distributed = False...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...11 tiny_db: TinyDbConfig = TinyDbConfig()12class Config(AConfig):13 db: DbDriverConfigOptions = DbDriverConfigOptions()14DEFAULT_CONFIGS = Config()15def merge_configs(config: AConfig, custom_config: Optional[Dict[str, Any]] = None) -> AConfig:16 """Examples:17 >>> default_config_value = "bar"18 >>> class TestConfigClass(AConfig):19 ... class TestConfigClassEmbedded(AConfig):20 ... foo = default_config_value21 ... sub_config = TestConfigClassEmbedded()22 ... foo = default_config_value23 ...24 ... def __str__(self):25 ... return f'foo: {self.foo}, sub_config: foo: {self.sub_config.foo}'26 ...27 >>> def get_test_config():28 ... return TestConfigClass()29 1. merge_configs: returns base config without changes if no custom configs are supplied30 >>> test_config = get_test_config()31 >>> result_config = merge_configs(test_config)32 >>> test_config.foo == result_config.foo == default_config_value33 True34 >>> test_config.sub_config.foo == result_config.sub_config.foo == default_config_value35 True36 2. merge_configs: returns partially merged config values if a partial custom config is given37 >>> test_config = get_test_config()38 >>> custom_config = {'foo': 'zed'}39 >>> result_config = merge_configs(test_config, custom_config)40 >>> result_config.foo == custom_config['foo']41 True42 >>> test_config.sub_config.foo == result_config.sub_config.foo == default_config_value43 True44 3. merge_configs: returns fully merged config values if full custom config is given45 >>> test_config = get_test_config()46 >>> custom_config = {'foo': 'zed', 'sub_config': {'foo': 'zar'}}47 >>> result_config = merge_configs(test_config, custom_config)48 >>> result_config.foo == custom_config['foo']49 True50 >>> result_config.sub_config.foo == custom_config['sub_config']['foo']51 True52 """53 def _update_config(base_config: AConfig, custom_config: Dict[str, Any]) -> AConfig:54 members = getmembers(base_config)55 for (key, value) in members:56 if isinstance(value, AConfig) and key in custom_config:57 _update_config(value, custom_config[key])58 elif key in custom_config and not hasattr(value, '__dict__'):59 setattr(base_config, key, custom_config[key])60 return base_config61 return _update_config(config, custom_config) if custom_config else config62def initialize_custom_configs(config_path: str) -> AConfig:63 with open(config_path) as file:64 custom_config: Dict[str, Any] = json.load(file)65 base_configs = Config()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful