How to use legacy_from_config method in localstack

Best Python code snippet using localstack_python

models.py

Source:models.py Github

copy

Full Screen

...1041 return copy.deepcopy(config)1042 @classmethod1043 def from_config(cls, config, custom_objects=None):1044 if 'class_name' not in config[0] or config[0]['class_name'] == 'Merge':1045 return cls.legacy_from_config(config)1046 model = cls()1047 for conf in config:1048 layer = layer_module.deserialize(conf, custom_objects=custom_objects)1049 model.add(layer)1050 return model1051 def legacy_get_config(self):1052 """Retrieves the model configuration as a Python list.1053 # Returns1054 A list of dicts (each dict is a layer config).1055 """1056 config = []1057 if isinstance(self.layers[0], legacy_layers.Merge):1058 assert hasattr(self.layers[0], 'layers')1059 layers = []1060 for layer in self.layers[0].layers:1061 layer_config = {'class_name': layer.__class__.__name__,1062 'config': layer.get_config()}1063 layers.append(layer_config)1064 merge_config = self.layers[0].get_config()1065 merge_config['layers'] = layers1066 config.append({'class_name': 'Merge', 'config': merge_config})1067 else:1068 config.append({'class_name': self.layers[0].__class__.__name__,1069 'config': self.layers[0].get_config()})1070 for layer in self.layers[1:]:1071 config.append({'class_name': layer.__class__.__name__,1072 'config': layer.get_config()})1073 return copy.deepcopy(config)1074 @classmethod1075 def legacy_from_config(cls, config, layer_cache=None):1076 """Load a model from a legacy configuration.1077 # Arguments1078 config: dictionary with configuration.1079 layer_cache: cache to draw pre-existing layer.1080 # Returns1081 The loaded Model.1082 """1083 if not layer_cache:1084 layer_cache = {}1085 def normalize_legacy_config(conf):1086 if 'class_name' not in conf:1087 class_name = conf['name']1088 name = conf.get('custom_name')1089 conf['name'] = name...

Full Screen

Full Screen

test_cli.py

Source:test_cli.py Github

copy

Full Screen

...89 monkeypatch.setenv("DATA_DIR", str(data_dir))90 monkeypatch.setattr(config, "DATA_DIR", str(data_dir))91 monkeypatch.setattr(config, "TMP_FOLDER", str(tmp_folder))92 # reload directories from manipulated config93 monkeypatch.setattr(config, "dirs", config.Directories.legacy_from_config())94 runner.invoke(cli, ["start", "-d"])95 runner.invoke(cli, ["wait", "-t", "60"])96 # check that mounts were created correctly97 inspect = container_client.inspect_container(config.MAIN_CONTAINER_NAME)98 container_dirs = config.Directories.for_container()99 binds = inspect["HostConfig"]["Binds"]100 assert f"{tmp_folder}:{container_dirs.tmp}" in binds101 assert f"{data_dir}:{container_dirs.data}" in binds102 assert f"{DOCKER_SOCK}:{DOCKER_SOCK}" in binds103 @pytest.mark.skipif(104 condition=config.LEGACY_DIRECTORIES, reason="this test targets LEGACY_DIRECTORIES=0"105 )106 def test_volume_dir_mounted_correctly(self, runner, tmp_path, monkeypatch, container_client):107 volume_dir = tmp_path / "volume"...

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 localstack 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