Best Python code snippet using yandex-tank
gnn_architectures.py
Source: gnn_architectures.py
...40 x = self.conv1(x, edge_index)41 for conv in self.convs:42 x = conv(x, edge_index)43 if self.add_pool:44 x = global_add_pool(x, batch)45 else:46 x = global_mean_pool(x, batch)47 x = F.relu(self.lin1(x))48 x = F.dropout(x, p=0.5, training=self.training)49 x = self.lin2(x)50 return F.log_softmax(x, dim=-1)51 def __repr__(self):52 return self.__class__.__name__53class GIN0(torch.nn.Module):54 def __init__(self, dataset, num_layers, hidden, add_pool=False):55 super(GIN0, self).__init__()56 self.conv1 = GINConv(Sequential(57 Linear(dataset.num_features, hidden),58 ReLU(),59 Linear(hidden, hidden),60 ReLU(),61 BN(hidden),62 ),63 train_eps=False)64 self.convs = torch.nn.ModuleList()65 for i in range(num_layers - 1):66 self.convs.append(67 GINConv(Sequential(68 Linear(hidden, hidden),69 ReLU(),70 Linear(hidden, hidden),71 ReLU(),72 BN(hidden),73 ),74 train_eps=False))75 self.lin1 = Linear(hidden, hidden)76 self.lin2 = Linear(hidden, dataset.num_classes)77 self.add_pool = add_pool78 def reset_parameters(self):79 self.conv1.reset_parameters()80 for conv in self.convs:81 conv.reset_parameters()82 self.lin1.reset_parameters()83 self.lin2.reset_parameters()84 def forward(self, data):85 x, edge_index, batch = data.x, data.edge_index, data.batch86 x = self.conv1(x, edge_index)87 for conv in self.convs:88 x = conv(x, edge_index)89 if self.add_pool:90 x = global_add_pool(x, batch)91 else:92 x = global_mean_pool(x, batch)93 x = F.relu(self.lin1(x))94 x = F.dropout(x, p=0.5, training=self.training)95 x = self.lin2(x)96 return F.log_softmax(x, dim=-1)97 def __repr__(self):98 return self.__class__.__name__99class GINE0Conv(MessagePassing):100 def __init__(self, edge_dim, dim_init, dim):101 super(GINE0Conv, self).__init__(aggr="add")102 self.edge_encoder = Sequential(Linear(edge_dim, dim_init), ReLU(), Linear(dim_init, dim_init), ReLU(),103 BN(dim_init))104 self.mlp = Sequential(Linear(dim_init, dim), ReLU(), Linear(dim, dim), ReLU(), BN(dim))...
add_dhcppool.py
Source: add_dhcppool.py
1import requests2import yaml3import json4def main():5 6 # The IOS-XE sandbox uses a self-signed cert at present, so let's7 # ignore any obvious security warnings for now.8 requests.packages.urllib3.disable_warnings()9 # The API path below is what the sandbox uses for API testing,10 api_path = "https://ios-xe-mgmt-latest.cisco.com:9443/restconf"11 # Create 2-tuple for "basic" authentication using Cisco credentials.12 auth = ('root', 'D_Vay!_10&')13 # Read YAML declarative state with list of DHCP pools to add14 with open('config_state.yml', 'r') as handle:15 config_state = yaml.safe_load(handle)16 print(config_state)17 print("#################################################")18 # Create JSON structure to add a new pool along with the HTTP POST19 # headers needed to add it.20 add_pool = {"Cisco-IOS-XE-dhcp:pool": config_state["add_pools"]}21 print(add_pool)22 print("###################################################")23 add_headers = {"Content-Type": "application/yang-data+json",24 "Accept": "application/yang-data+json, application/yang-data.errors+json",}25 26 # Can double-check our HTTP body using this debug; great for learning27 print(json.dumps(add_pool, indent=2))28 29 add_pool_resp = requests.post(30 f"{api_path}/data/Cisco-IOS-XE-native:native/ip/dhcp",31 headers=add_headers,32 auth=auth,33 json=add_pool,34 verify=False,35 )36 37 print(add_pool_resp)38 # HTTP 201 means "created", implying a new resource was added. The39 # response will tell us the URL of the newly-created resource, simplifying40 # future removal.41 if add_pool_resp.status_code == 201:42 print(f"Added DHCP pool at: {add_pool_resp.headers['Location']}")43 # Save configuration whenever the DHCP pool is added. This ensures44 # the configuration will persist across reboots.45 save_config_resp = requests.post(46 f"{api_path}/operations/cisco-ia:save-config",47 headers=add_headers,48 auth=auth,49 verify=False,50 )51 # Optionally print the JSON response, along with success message52 # import json; print(json.dumps(save_config_resp.json(), indent=2))53 if save_config_resp.ok:54 print("Saved configuration")55if __name__=='__main__':...
mutation.py
Source: mutation.py
2def add_convblock(part: str):3 conv_1 = str(random.randint(1, 512))4 conv_2 = str(random.randint(1, 512))5 return f'{conv_1}-{conv_2}-{part}'6def add_pool(part: str):7 return f'{round(random.uniform(0., 1.), 1)}-{part}'8def remove_layer(part: str):9 return ''10MUTATION_OPERATIONS = []11MUTATION_OPERATIONS.append(add_convblock)12MUTATION_OPERATIONS.append(add_pool)...
Check out the latest blogs from LambdaTest on this topic:
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
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!!