Best Python code snippet using lettuce_webdriver_python
configs.py
Source:configs.py
...223 print("parse_blocks_into_model: Error on layer idx", layer_idx, ": Unrecognized block type:", block_type)224 return parsed_layer, out_channels225##### BLOCK PARSING #####226# find_option227def find_option(block, key, type, default, loud=False, layer_name=None, layer_idx=-1):228 """229 ----------230 Author: Damon Gwinn (gwinndr)231 ----------232 - Finds the option specified by key and sets the value according to type233 - If option not found, uses default234 - If default is used and loud is True, prints that the default is being used235 - layer_name (str) and layer_idx (int) further specify layer details when printing with loud236 ----------237 """238 if(key in block.keys()):239 val = block[key]240 else:241 val = default242 if(loud):243 if(layer_name is None):244 label = ""245 else:246 label = "%s at idx %d:" % (layer_name, layer_idx)247 print(label, "Using default:", default, "for key:", key)248 if(val is not None):249 val = type(val)250 return val251# find_option_list252def find_option_list(block, key, type, default, loud=False, layer_name=None, layer_idx=-1):253 """254 ----------255 Author: Damon Gwinn (gwinndr)256 ----------257 - Finds the option specified by key and creates a list of values according to type258 - Value is parsed according to a ','. Default is assumed to be a list.259 - If option not found, uses default260 - If default is used and loud is True, prints that the default is being used261 - layer_name (str) and layer_idx (int) further specify layer details when printing with loud262 ----------263 """264 if(key in block.keys()):265 val = block[key]266 val = val.split(",")267 val = [s.strip() for s in val]268 else:269 val = default270 if(loud):271 if(layer_name is None):272 label = ""273 else:274 label = "%s at idx %d:" % (layer_name, layer_idx)275 print(label, "Using default:", default, "for key:", key)276 if(val is not None):277 val = [type(v) for v in val]278 return val279# parse_net_block280def parse_net_block(block):281 """282 ----------283 Author: Damon Gwinn (gwinndr)284 ----------285 - Parses network block into a NetBlock286 ----------287 """288 layer_name = "NetworkBlock"289 layer_idx = -1290 batch = find_option(block, "batch", int, NET_BATCH_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)291 subdiv = find_option(block, "subdivisions", int, NET_SUBDIV_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)292 width = find_option(block, "width", int, NET_W_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)293 height = find_option(block, "height", int, NET_H_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)294 channels = find_option(block, "channels", int, NET_CH_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)295 momentum = find_option(block, "momentum", float, NET_MOMEN_DEF)296 decay = find_option(block, "decay", float, NET_DECAY_DEF)297 angle = find_option(block, "angle", float, NET_ANG_DEF)298 saturation = find_option(block, "saturation", float, NET_SATUR_DEF)299 exposure = find_option(block, "exposure", float, NET_EXPOS_DEF)300 hue = find_option(block, "hue", float, NET_HUE_DEF)301 flip = find_option(block, "flip", int, NET_FLIP_DEF);302 lr = find_option(block, "learning_rate", float, NET_LR_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)303 burn_in = find_option(block, "burn_in", int, NET_BURN_DEF)304 power = find_option(block, "power", float, NET_POW_DEF)305 max_batches = find_option(block, "max_batches", int, NET_MAX_BAT_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)306 policy = find_option(block, "policy", str, NET_POL_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)307 steps = find_option_list(block, "steps", int, NET_STEP_DEF)308 scales = find_option_list(block, "scales", float, NET_SCALE_DEF)309 mosaic = find_option(block, "mosaic", int, NET_MOSAIC_DEF)310 resize_step = find_option(block, "resize_step", int, NET_RESIZE_STEP_DEF)311 net_block = NetBlock(312 batch=batch, subdivisions=subdiv, width=width, height=height, channels=channels,313 momentum=momentum, decay=decay, angle=angle, saturation=saturation, exposure=exposure,314 hue=hue, flip=flip, lr=lr, burn_in=burn_in, power=power, max_batches=max_batches,315 policy=policy, steps=steps, scales=scales, mosaic=mosaic, resize_step=resize_step316 )317 return net_block318# parse_convolutional_block319def parse_convolutional_block(block, in_channels, layer_idx):320 """321 ----------322 Author: Damon Gwinn (gwinndr)323 ----------324 - Parses convolutional block into a ConvolutionalLayer325 ----------326 """327 layer_name = "ConvolutionalLayer"328 filters = find_option(block, "filters", int, CONV_FILT_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)329 size = find_option(block, "size", int, CONV_SIZE_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)330 stride = find_option(block, "stride", int, CONV_STRIDE_DEF)331 batch_normalize = find_option(block, "batch_normalize", int, CONV_BN_DEF)332 pad = find_option(block, "pad", int, CONV_PAD_DEF)333 activation = find_option(block, "activation", str, CONV_ACTIV_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)334 conv_layer = ConvolutionalLayer(335 in_channels, filters=filters, size=size, stride=stride, batch_normalize=batch_normalize,336 pad=pad, activation=activation337 )338 return conv_layer, filters339# parse_maxpool_block340def parse_maxpool_block(block, layer_idx):341 """342 ----------343 Author: Damon Gwinn (gwinndr)344 ----------345 - Parses maxpool block into a MaxpoolLayer346 ----------347 """348 layer_name = "MaxpoolLayer"349 size = find_option(block, "size", int, MAXPL_SIZE_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)350 stride = find_option(block, "stride", int, MAXPL_STRIDE_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)351 padding = find_option(block, "padding", int, default=size-1)352 maxpool_layer = MaxpoolLayer(size=size, stride=stride, padding=padding)353 return maxpool_layer354# parse_route_block355def parse_route_block(block, layer_output_channels, layer_idx):356 """357 ----------358 Author: Damon Gwinn (gwinndr)359 ----------360 - Parses route block into a RouteLayer361 - layer_output_channels should be a list containing all output channels up to this current layer362 ----------363 """364 layer_name = "RouteLayer"365 out_channels = 0366 layers = find_option_list(block, "layers", int, default=None)367 error_state = False368 # Validation369 if(layers is None):370 print("route: Error on layer_idx", layer_idx, ": Missing required 'layers' entry")371 error_state = True372 # Setting up RouteLayer373 if(not error_state):374 route_layer = RouteLayer(layers)375 for l in layers:376 out_channels += layer_output_channels[l]377 else:378 route_layer = None379 return route_layer, out_channels380# parse_shortcut_block381def parse_shortcut_block(block, layer_idx):382 """383 ----------384 Author: Damon Gwinn (gwinndr)385 ----------386 - Parses shortcut block into a ShortcutLayer387 ----------388 """389 layer_name = "ShortcutLayer"390 from_layer = find_option(block, "from", int, default=None)391 activation = find_option(block, "activation", str, SHCT_ACTIV_DEF)392 error_state = False393 # Validation394 if(from_layer is None):395 print("shortcut: Error on layer_idx", layer_idx, ": Missing required 'from' entry")396 error_state = True397 # Setting up ShortcutLayer398 if(not error_state):399 shortcut_layer = ShortcutLayer(from_layer, activation=activation)400 else:401 shortcut_layer = None402 return shortcut_layer403# parse_upsample_block404def parse_upsample_block(block, layer_idx):405 """406 ----------407 Author: Damon Gwinn (gwinndr)408 ----------409 - Parses upsample block into a UpsampleLayer410 ----------411 """412 layer_name = "UpsampleLayer"413 stride = find_option(block, "stride", int, UPSAMP_STRIDE_DEF)414 upsample_layer = UpsampleLayer(stride=stride)415 return upsample_layer416# parse_yolo_block417def parse_yolo_block(block, layer_idx):418 """419 ----------420 Author: Damon Gwinn (gwinndr)421 ----------422 - Parses yolo block into a YoloLayer423 ----------424 """425 layer_name = "YoloLayer"426 yolo_layer = None427 mask = find_option_list(block, "mask", int, default=None)428 anchors = find_option_list(block, "anchors", int, default=None)429 classes = find_option(block, "classes", int, YOLO_NCLS_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)430 num = find_option(block, "num", int, YOLO_NUM_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)431 jitter = find_option(block, "jitter", float, YOLO_JITTER_DEF)432 resize = find_option(block, "resize", float, YOLO_RESIZE_DEF)433 ignore_thresh = find_option(block, "ignore_thresh", float, YOLO_IGNORE_DEF, loud=True, layer_name=layer_name, layer_idx=layer_idx)434 truth_thresh = find_option(block, "truth_thresh", float, YOLO_TRUTH_DEF)435 random = find_option(block, "random", float, YOLO_RANDOM_DEF)436 scale_xy = find_option(block, "scale_x_y", float, YOLO_SCALEXY_DEF)437 iou_thresh = find_option(block, "iou_thresh", float, YOLO_IOU_THRESH_DEF)438 cls_norm = find_option(block, "cls_normalizer", float, YOLO_CLS_NORM_DEF)439 iou_norm = find_option(block, "iou_normalizer", float, YOLO_IOU_NORM_DEF)440 iou_loss = find_option(block, "iou_loss", str, YOLO_IOU_LOSS_DEF)441 nms_kind = find_option(block, "nms_kind", str, YOLO_NMS_KIND_DEF)442 beta_nms = find_option(block, "beta_nms", float, YOLO_BETA_NMS_DEF)443 max_delta = find_option(block, "max_delta", float, YOLO_MAX_DELTA_DEF)444 error_state = False445 # Validation446 if(mask is None):447 print("yolo: Error on layer_idx", layer_idx, ": Missing 'mask' entry")448 error_state = True449 if(anchors is None):450 print("yolo: Error on layer_idx", layer_idx, ": Missing 'anchors' entry")451 error_state = True452 # Validating anchors453 if(not error_state):454 if(len(anchors) % 2 != 0):455 print("yolo: Error on layer_idx", layer_idx, ": All anchors must have width and height")456 error_state = True457 else:...
config.py
Source:config.py
...13 def __init__(self, pytest_config):14 """Initialize required attributes."""15 self.rp_rerun = (pytest_config.option.rp_rerun or16 pytest_config.getini('rp_rerun'))17 self.rp_endpoint = self.find_option(pytest_config, 'rp_endpoint')18 self.rp_hierarchy_code = self.find_option(pytest_config,19 'rp_hierarchy_code')20 self.rp_dir_level = int(self.find_option(pytest_config,21 'rp_hierarchy_dirs_level'))22 self.rp_hierarchy_dirs = self.find_option(pytest_config,23 'rp_hierarchy_dirs')24 self.rp_dir_path_separator = \25 self.find_option(pytest_config, 'rp_hierarchy_dir_path_separator')26 ignore_attributes = self.find_option(pytest_config,27 'rp_ignore_attributes')28 self.rp_ignore_attributes = set(ignore_attributes) \29 if ignore_attributes else set()30 self.rp_is_skipped_an_issue = self.find_option(31 pytest_config,32 'rp_is_skipped_an_issue'33 )34 self.rp_issue_id_marks = self.find_option(pytest_config,35 'rp_issue_id_marks')36 self.rp_issue_system_url = self.find_option(pytest_config,37 'rp_issue_system_url')38 self.rp_bts_project = self.find_option(pytest_config, 'rp_bts_project')39 self.rp_bts_url = self.find_option(pytest_config, 'rp_bts_url')40 self.rp_launch = self.find_option(pytest_config, 'rp_launch')41 self.rp_launch_id = self.find_option(pytest_config, 'rp_launch_id')42 self.rp_launch_attributes = self.find_option(pytest_config,43 'rp_launch_attributes')44 self.rp_launch_description = self.find_option(pytest_config,45 'rp_launch_description')46 self.rp_log_batch_size = int(self.find_option(pytest_config,47 'rp_log_batch_size'))48 batch_payload_size = self.find_option(49 pytest_config, 'rp_log_batch_payload_size')50 if batch_payload_size:51 self.rp_log_batch_payload_size = int(batch_payload_size)52 else:53 self.rp_log_batch_payload_size = MAX_LOG_BATCH_PAYLOAD_SIZE54 self.rp_log_level = get_actual_log_level(pytest_config, 'rp_log_level')55 self.rp_log_format = self.find_option(pytest_config, 'rp_log_format')56 self.rp_mode = self.find_option(pytest_config, 'rp_mode')57 self.rp_parent_item_id = self.find_option(pytest_config,58 'rp_parent_item_id')59 self.rp_project = self.find_option(pytest_config,60 'rp_project')61 self.rp_rerun_of = self.find_option(pytest_config,62 'rp_rerun_of')63 self.rp_retries = int(self.find_option(pytest_config,64 'retries'))65 self.rp_skip_connection_test = str(66 self.find_option(pytest_config,67 'rp_skip_connection_test')).lower() in (68 'true', '1', 'yes', 'y')69 self.rp_uuid = getenv('RP_UUID') or self.find_option(pytest_config,70 'rp_uuid')71 rp_verify_ssl = self.find_option(pytest_config, 'rp_verify_ssl', True)72 try:73 self.rp_verify_ssl = bool(strtobool(rp_verify_ssl))74 except (ValueError, AttributeError):75 self.rp_verify_ssl = rp_verify_ssl76 # noinspection PyMethodMayBeStatic77 def find_option(self, pytest_config, option_name, default=None):78 """79 Find a single configuration setting from multiple places.80 The value is retrieved in the following places in priority order:81 1. From `self.pconfig.option.[option_name]`.82 2. From `self.pconfig.getini(option_name)`.83 :param pytest_config: config object of PyTest84 :param option_name: name of the option85 :param default: value to be returned if not found86 :return: option value87 """88 value = (89 getattr(pytest_config.option, option_name, None) or90 pytest_config.getini(option_name)91 )...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!