How to use lock_targets method in yandex-tank

Best Python code snippet using yandex-tank

del_edited_branches.py

Source:del_edited_branches.py Github

copy

Full Screen

...30 child_species = set(tree.info[leaf]['taxon_name'] for leaf in child_leaves)31 species_counts.append(len(child_species))32 selected, least_species = min(enumerate(species_counts), key=lambda x: x[1])33 return nodedata[selected][0], selected34def lock_targets(node, tree, edited_node_id=EDITED_NODE_ID, infinite_dist=INFINITE_DIST,35 fromset=None):36 """Return which children to delete"""37 nodeinfo = tree.info[node]38 nodedata = tree.data[node]39 # Too long branches40 try:41 targets = {child: i for i,(child,dist) in enumerate(nodedata) if dist >= infinite_dist}42 except ValueError as err:43 err.args += (nodedata,)44 raise45 # Gene splits46 targets.update({child: i for i,(child,_) in enumerate(nodedata) \47 if tree.info[child]['Duplication'] == 10})48 # Gene edition49 if nodeinfo['Duplication'] == 3 or \50 (nodeinfo['Duplication'] > 0 and node >= edited_node_id):51 edited_child, edited = select_farthest(nodedata)52 targets[edited_child] = edited53 if fromset is not None:54 for i, (child, _) in enumerate(nodedata):55 if child in fromset:56 fromset.delete(child)57 targets[child] = i58 return targets59def lock_targets_filter(node, tree, filter):60 """Return which children to delete"""61 nodeinfo = tree.info[node]62 nodedata = tree.data[node]63 children_info = {}64 for child, dist in nodedata:65 children_info[child] = tree.info[child]66 children_info[child]['dist'] = dist67 # Gene splits68 targets = {child: i for i,(child,childinfo) in69 enumerate(children_info.items())70 if eval(filter.format(**childinfo))}71 # Gene edition72 return targets73def knock_targets(targets, tree, nodedata, nodeinfo):74 """Detach target nodes (i.e delete subtrees) from tree"""75 leaf_count = 076 for target, target_index in sorted(tuple(targets.items()),77 key=lambda item: -item[1]):78 tree.info.pop(target)79 try:80 tree.data.pop(target)81 except KeyError as err:82 leaf_count += 183 nodedata.pop(target_index)84 return leaf_count85def filterbranches(tree, node, edited_node_id=EDITED_NODE_ID,86 infinite_dist=INFINITE_DIST, filter=None, fromset=None):87 """Descend the tree from root to branches. Discard any anomalous node (and its descendants)"""88 del_count = 089 del_leaf_count = 090 #if node is None:91 # node = tree.root92 data = tree.data.get(node)93 if data:94 info = tree.info[node]95 targets = lock_targets(node, tree, edited_node_id, infinite_dist)96 if targets:97 del_count += len(targets)98 del_leaf_count += knock_targets(targets, tree, data, info)99 100 for child,_ in data:101 ch_dc, ch_dlc = filterbranches(tree, child, edited_node_id, infinite_dist)102 del_count += ch_dc103 del_leaf_count += ch_dlc104 return del_count, del_leaf_count105def main(treeforestfile, outfile, dryrun=False, edited_node_id=EDITED_NODE_ID,106 infinite_dist=INFINITE_DIST):107 total_deleted = 0108 total_leaves_deleted = 0109 if dryrun and outfile is not stdout: outfile.close()...

Full Screen

Full Screen

test_docs_gen.py

Source:test_docs_gen.py Github

copy

Full Screen

1# coding=utf-82import pytest3from yandextank.validator.docs_gen import RSTRenderer, format_option4@pytest.mark.parametrize('option_schema, expected', [5 ({'report_file': {6 'description': 'path to file to store autostop report',7 'type': 'string',8 'default': 'autostop_report.txt'}},9 r"""``report_file`` (string)10------------------------11*\- path to file to store autostop report. Default:* ``autostop_report.txt``"""),12 ({'gun_type': {13 'type': 'string',14 'description': 'gun type',15 'allowed': ['custom', 'http', 'scenario', 'ultimate'],16 # 'values_description': {17 # 'custom': 'custom gun', 'http': 'http gun', 'scenario': 'scenario gun', 'ultimate': 'ultimate gun'18 # },19 'required': 'true'}},20 r"""``gun_type`` (string)21---------------------22*\- gun type.* **Required.**23:one of: [``custom``, ``http``, ``scenario``, ``ultimate``]"""),24 ({'gun_type': {25 'type': 'string',26 'description': 'gun type',27 'allowed': ['custom', 'http', 'scenario', 'ultimate'],28 'values_description': {29 'custom': 'custom gun', 'http': 'http gun', 'scenario': 'scenario gun', 'ultimate': 'ultimate gun'30 },31 'required': 'true'}},32 r"""``gun_type`` (string)33---------------------34*\- gun type.* **Required.**35:one of:36 :``custom``: custom gun37 :``http``: http gun38 :``scenario``: scenario gun39 :``ultimate``: ultimate gun"""),40 ({"load_profile": {41 "type": "dict",42 'description': 'specify parameters of your load',43 'schema': {44 'load_type': {45 'type': 'string',46 'required': 'true',47 'description': 'choose your load type',48 'allowed': ['rps', 'instances', 'stpd_file'],49 'values_description': {50 'instances': 'fix number of instances',51 'rps': 'fix rps rate',52 'stpd_file': 'use ready schedule file'}53 },54 'schedule': {55 'type': 'string',56 'required': True,57 'description': 'load schedule or path to stpd file',58 'examples': {59 'line(100,200,10m)': 'linear growth from 100 to 200 instances/rps during 10 minutes',60 'const(200,90s)': 'constant load of 200 instances/rps during 90s',61 'test_dir/test_backend.stpd': 'path to ready schedule file'}62 }63 },64 'required': True}},65 r"""``load_profile`` (dict)66-----------------------67*\- specify parameters of your load.* **Required.**68:``load_type`` (string):69 *\- choose your load type.* **Required.**70 71 :one of:72 :``instances``: fix number of instances73 :``rps``: fix rps rate74 :``stpd_file``: use ready schedule file75:``schedule`` (string):76 *\- load schedule or path to stpd file.* **Required.**77 78 :examples:79 ``const(200,90s)``80 constant load of 200 instances/rps during 90s81 ``line(100,200,10m)``82 linear growth from 100 to 200 instances/rps during 10 minutes83 ``test_dir/test_backend.stpd``84 path to ready schedule file"""), # noqa: W29385 ({'lock_targets': {86 'default': 'auto',87 'description': 'targets to lock',88 'values_description': {89 'auto': 'automatically identify target host',90 '[ya.ru, ...]': 'list of targets to lock'91 },92 'anyof': [93 {'type': 'list'},94 {'type': 'string', 'allowed': ['auto']}95 ],96 'tutorial_link': 'http://yandextank.readthedocs.io'}},97 r"""``lock_targets`` (list or string)98---------------------------------99*\- targets to lock. Default:* ``auto``100:one of:101 :``[ya.ru, ...]``: list of targets to lock102 :``auto``: automatically identify target host103:tutorial_link:104 http://yandextank.readthedocs.io"""),105 ({'autostop': {106 'description': 'list of autostop constraints',107 'type': 'list',108 'schema': {109 'type': 'string',110 'description': 'autostop constraint',111 'examples': {'http(4xx,50%,5)': 'stop when rate of 4xx http codes is 50% or more during 5 seconds'}112 },113 'default': []}},114 r"""``autostop`` (list of string)115-----------------------------116*\- list of autostop constraints. Default:* ``[]``117:[list_element] (string):118 *\- autostop constraint.*119 120 :examples:121 ``http(4xx,50%,5)``122 stop when rate of 4xx http codes is 50% or more during 5 seconds""") # noqa: W293123])124def test_format_option(option_schema, expected):...

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 yandex-tank 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