How to use set_module_name method in Slash

Best Python code snippet using slash

downloader.py

Source:downloader.py Github

copy

Full Screen

...97 git_url = module.get('git_url')98 if not git_url:99 logger.error("git_url is undefined")100 sys.exit(1)101 module_name = set_module_name(module.get('name'), git_url)102 git_branch = module.get('git_branch')103 git_tag = module.get('git_tag')104 if git_tag:105 logger.info("Module {} will download by tag".format(module_name))106 downloaded_git_branchortag = git_tag107 elif git_branch:108 logger.info("Module {} will download by branch".format(module_name))109 downloaded_git_branchortag = git_branch110 module_dir = os.path.join(config.SRC_PATH, "modules", module_name)111 r = repo.clone_from(git_url, module_dir, branch=downloaded_git_branchortag)112 logger.info("-- Done: {}".format(module_name))113 if r.submodules:114 logger.info("-- Checking for {}/submodules...".format(module_name))115 for submodule in r.submodules:116 logger.info("-- Downloading: {}...".format(submodule))117 submodule.update(init=True)118 logger.info("---- Done: {}/{}".format(module_name, submodule))119 return module_name120def download_module_from_web(module):121 """122 Загрузка архива с модулем из web123 :param module:124 :return:125 """126 web_url = module.get('web_url')127 if not web_url:128 logger.error("web_url is undefined")129 sys.exit(1)130 module_name = set_module_name(module.get('name'), web_url)131 file_name = web_url[web_url.rfind("/") + 1:]132 logger.info("Module {} will downloading".format(module_name))133 with open(os.path.join(config.SRC_PATH, "modules", file_name), "wb") as file:134 response = get(web_url)135 file.write(response.content)136 module_name = common_utils.extract_archive(file_name, os.path.join(config.SRC_PATH, "modules"))137 return module_name138def download_module_from_local(module):139 """140 Загрузка модуля из локального архива141 :param module:142 :return:143 """144 local_url = module.get('local_url')145 if not local_url:146 logger.error("local_url is undefined")147 sys.exit(1)148 module_name = set_module_name(module.get('name'), local_url)149 file_name = local_url[local_url.rfind("/") + 1:]150 shutil.copy(local_url, os.path.join(config.SRC_PATH, "modules", file_name))151 module_name = common_utils.extract_archive(file_name, os.path.join(config.SRC_PATH, "modules"))152 return module_name153def download_module_embedded(module):154 """155 Установка втроенного модуля156 :param module:157 :return:158 """159 if module.get('name') is not None:160 config.DEFAULT_CONFIGURE_PARAMS.append("--with-{}".format(module.get('name')))161def download_package_scripts_deb(src_version):162 """163 Загрузка вспомогательных скриптов для сборки deb пакета164 :return file_name:165 """166 common_utils.ensure_directory(config.SRC_PATH)167 deb_package_scripts_filename = "nginx_{}-1~{}.debian.tar.xz".format(168 src_version,169 config.OS_RELEASE170 )171 deb_package_scripts_url = "{}/{}".format(172 config.DEB_PACKAGE_SCRIPTS_URL_MAINLINE,173 deb_package_scripts_filename174 )175 if version.parse(src_version).release[1] % 2 == 0:176 deb_package_scripts_url = "{}/{}".format(177 config.DEB_PACKAGE_SCRIPTS_URL_STABLE,178 deb_package_scripts_filename179 )180 logger.info("Download scripts for build deb package")181 with open(os.path.join(config.SRC_PATH, deb_package_scripts_filename), "wb") as file:182 response = get(deb_package_scripts_url)183 if 400 <= response.status_code < 500:184 logger.error(u"{} Client Error: {} for url: {}".format(response.status_code, response.reason, deb_package_scripts_url))185 sys.exit(1)186 elif 500 <= response.status_code < 600:187 logger.error(u"{} Server Error: {} for url: {}".format(response.status_code, response.reason, deb_package_scripts_url))188 sys.exit(1)189 file.write(response.content)190 return deb_package_scripts_filename191def download_package_scripts_rpm():192 """193 Загрузка вспомогательных скриптов для сборки rpm пакета194 :return file_name:195 """196 common_utils.ensure_directory(config.SRC_PATH)197 file_name = None198 logger.info("Download scripts for build rpm package")199 common_utils.execute_command("rpmdev-setuptree", os.getcwd())200 return file_name201def install_deb_packages(all_deps):202 """203 Установка deb пакетов204 :param all_deps:205 :return:206 """207 import apt208 cache = apt.cache.Cache()209 cache.update()210 cache.open(None)211 for dependency in all_deps:212 pkg = cache[dependency]213 if pkg.is_installed:214 logger.warning("'{}' already installed".format(dependency))215 continue216 pkg.mark_install()217 try:218 cache.commit()219 except SystemError as err:220 logger.error("Failed to download %s. Cause %s",221 (dependency, err))222def download_dependencies_deb(modules):223 """224 Установка зависимостей, если они есть225 :param modules:226 :return dependencies_all:227 """228 logger.info("Downloading dependencies")229 dependencies_all = set()230 if not modules:231 return list(dependencies_all)232 for module in modules:233 module = module.get('module', {})234 dependencies = module.get('dependencies', [])235 dependencies_all.update(dependencies)236 dependencies_list = list(dependencies_all)237 if dependencies_list:238 install_deb_packages(dependencies_list)239 return dependencies_list240def install_rpm_packages(all_deps):241 """242 Установка rpm пакетов243 :param all_deps:244 :return:245 """246 install_command = ['yum', 'install', '--assumeyes']247 install_command.extend(all_deps)248 common_utils.execute_command(249 " ".join(install_command),250 os.getcwd()251 )252def download_dependencies_rpm(modules):253 """254 Установка зависимостей255 :param modules:256 :return:257 """258 logger.info("Download dependencies")259 dependencies_all = set()260 if not modules:261 return list(dependencies_all)262 for module in modules:263 module = module.get('module', {})264 dependencies = module.get('dependencies', [])265 dependencies_all.update(dependencies)266 dependencies_list = list(dependencies_all)267 if dependencies_list:268 install_rpm_packages(dependencies_list)269 return dependencies_list270def set_module_name(module_name, url):271 """272 Установка имени модуля из имеющихся данных273 :param module_name:274 :param url:275 :return:276 """277 if not module_name:278 module_name = url[url.rfind("/") + 1:].rsplit(".", 1)[0]279 return module_name280def get_patches_list(modules):281 """282 Получение списка патчей283 :param modules:284 :return:...

Full Screen

Full Screen

conv_test.py

Source:conv_test.py Github

copy

Full Screen

...22class Conv1dBenchmark(op_bench.TorchBenchmarkBase):23 def init(self, in_c, out_c, kernel, stride, N, L):24 self.input = torch.rand(N, in_c, L) 25 self.conv1d = nn.Conv1d(in_c, out_c, kernel, stride=stride)26 self.set_module_name("Conv1d")27 def forward(self):28 return self.conv1d(self.input)29class ConvTranspose1dBenchmark(op_bench.TorchBenchmarkBase):30 def init(self, in_c, out_c, kernel, stride, N, L):31 self.input = torch.rand(N, in_c, L) 32 self.convtranpose1d = nn.ConvTranspose1d(in_c, out_c, kernel, stride=stride)33 self.set_module_name("ConvTranspose1d")34 def forward(self):35 return self.convtranpose1d(self.input)36op_bench.generate_pt_test(conv_1d_configs, Conv1dBenchmark)37op_bench.generate_pt_test(conv_1d_configs, ConvTranspose1dBenchmark)38"""39Microbenchmarks for Conv2d and ConvTranspose2d operators.40"""41# Configs for Conv2d and ConvTranspose1d42conv_2d_configs = op_bench.config_list(43 attrs=[44 [16, 33, 3, 1, 1, 32, 32],45 [16, 33, 3, 2, 16, 64, 64],46 ],47 attr_names=[48 "in_c", "out_c", "kernel", "stride", "N", "H", "W"49 ],50 tags=["short"]51)52class Conv2dBenchmark(op_bench.TorchBenchmarkBase):53 def init(self, in_c, out_c, kernel, stride, N, H, W):54 self.input = torch.rand(N, in_c, H, W) 55 self.conv2d = nn.Conv2d(in_c, out_c, kernel, stride=stride)56 self.set_module_name("Conv2d")57 def forward(self):58 return self.conv2d(self.input)59class ConvTranspose2dBenchmark(op_bench.TorchBenchmarkBase):60 def init(self, in_c, out_c, kernel, stride, N, H, W):61 self.input = torch.rand(N, in_c, H, W) 62 self.convtranpose2d = nn.ConvTranspose2d(in_c, out_c, kernel, stride=stride)63 self.set_module_name("ConvTranspose2d")64 def forward(self):65 return self.convtranpose2d(self.input)66op_bench.generate_pt_test(conv_2d_configs, Conv2dBenchmark)67op_bench.generate_pt_test(conv_2d_configs, ConvTranspose2dBenchmark)68"""69Microbenchmarks for Conv3d and ConvTranspose3d operators.70"""71# Configs for Conv3d and ConvTranspose3d72conv_3d_configs = op_bench.config_list(73 attrs=[74 [16, 33, 3, 1, 8, 4, 32, 32],75 [16, 33, 3, 2, 16, 8, 64, 64],76 ],77 attr_names=[78 "in_c", "out_c", "kernel", "stride", "N", "D", "H", "W"79 ],80 tags=["short"]81)82class Conv3dBenchmark(op_bench.TorchBenchmarkBase):83 def init(self, in_c, out_c, kernel, stride, N, D, H, W):84 self.input = torch.rand(N, in_c, D, H, W) 85 self.conv3d = nn.Conv3d(in_c, out_c, kernel, stride=stride)86 self.set_module_name("Conv3d")87 def forward(self):88 return self.conv3d(self.input)89class ConvTranspose3dBenchmark(op_bench.TorchBenchmarkBase):90 def init(self, in_c, out_c, kernel, stride, N, D, H, W):91 self.input = torch.rand(N, in_c, D, H, W) 92 self.convtranpose3d = nn.ConvTranspose3d(in_c, out_c, kernel, stride=stride)93 self.set_module_name("ConvTranspose3d")94 def forward(self):95 return self.convtranpose3d(self.input)96op_bench.generate_pt_test(conv_3d_configs, Conv3dBenchmark)97op_bench.generate_pt_test(conv_3d_configs, ConvTranspose3dBenchmark)98if __name__ == "__main__":...

Full Screen

Full Screen

product_api_helpers.py

Source:product_api_helpers.py Github

copy

Full Screen

...14 for item in serializer.data:15 new_item = {}16 new_item['id'] = item['id']17 new_item['name'] = item['name']18 new_item['primary'] = set_module_name(item,"primary_scoring")19 new_item['other'] = set_module_name(item, "other_scoring")20 items.append(new_item)21 return items22def get_product_name(product_id):23 queryset = Product.objects.get(id=product_id)24 return queryset.name25def get_product_id_for_individual(individual_id):26 module_id = 027 individual = Individual.objects.filter(id=individual_id)28 if individual.count()!=0:29 individual = Individual.objects.get(id=individual_id)30 client = individual.client31 product = Product.objects.get(id=client.product)32 if individual.primary == True:33 module_id = product.primary_scoring34 else:35 module_id = product.other_scoring36 return module_id37def set_module_name(where,name):38 module_id = where[name]39 if module_id != 0:40 queryset = Module.objects.get(id=module_id)41 return queryset.name42 else:...

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