How to use partial_resolve method in lisa

Best Python code snippet using lisa_python

resolve_layouts.py

Source:resolve_layouts.py Github

copy

Full Screen

1#!/usr/bin/env python2from __future__ import print_function3from __future__ import division4import re5import sys6from collections import defaultdict7import argparse8gaf_path_pattern=re.compile(r"[<>][\w\-\_]+")9def transform_from_gaf(s):10 if s[0] == '>':11 return s[1:] + '+'12 elif s[0] == '<':13 return s[1:] + '-'14 assert(false)15def transform_to_gaf(s):16 if s[-1] == '+':17 return '>' + s[:-1]18 elif s[-1] == '-':19 return '<' + s[:-1]20 assert(false)21def process_path(l):22 if l[0] == '>' or l[0] == '<':23 return [transform_from_gaf(t) for t in gaf_path_pattern.findall(l)]24 else:25 return [t.strip() for t in l.split(',')]26parser = argparse.ArgumentParser(description="Recursive resolution of the layouts")27parser.add_argument("fragment_names", help="File with names of the fragments to resolve OR layout file OR .gfa file -- segment names will be extracted")28parser.add_argument("composition", help="File specifying composition of intermediate fragments")29parser.add_argument("--resolved-marker", help="String marking the nodes that got duplicated during repeat resolution (e.g. '_i'). Part of the name past the marker will be ignored.")30parser.add_argument("--partial-resolve", action="store_true", help="Allow 'partial' resolving of layout. By default fails if can't resolve down to path of <resolved-prefix>.* fragments")31parser.add_argument("--gaf-paths", action="store_true", help="Use GAF path format ([<>]-prefix instead of [+-]-suffix)")32parser.add_argument("--miniasm", help="File with miniasm layout via 'a' lines")33parser.add_argument("--resolved-prefix", default='read', help="Prefix of completely resolved elements")34args = parser.parse_args()35mapping=defaultdict(list)36usage=defaultdict(int)37if args.miniasm:38 print("Loading miniasm layout", file=sys.stderr)39 with open(args.miniasm, 'r') as miniasm_layout:40 for l in miniasm_layout:41 if not l.startswith('a'):42 continue43 s = l.split()44 assert s[0] == 'a'45 mapping[s[1]].append(s[3] + s[4])46 print("Loaded", file=sys.stderr)47print("Loading compression mappings", file=sys.stderr)48with open(args.composition, 'r') as compress_mapping:49 for l in compress_mapping:50 s = l.split()51 assert s[0] not in mapping52 mapping[s[0]] = process_path(s[1])53print("Loaded", file=sys.stderr)54names = []55if args.fragment_names.endswith('.gfa'):56 print("Loading fragment names from GFA file", file=sys.stderr)57 with open(args.fragment_names, 'r') as gfa_fn:58 for l in gfa_fn:59 if not l.startswith('S'):60 continue61 #TODO optimize for GFA with sequences62 s = l.split()63 assert s[0] == 'S'64 names.append(s[1])65 print("Loaded", file=sys.stderr)66else:67 print("Loading fragment info from text file", file=sys.stderr)68 with open(args.fragment_names, 'r') as fragment_handle:69 for l in fragment_handle:70 s = l.strip().split()71 names.append(s[0].strip())72 if len(s) > 1:73 mapping[s[0]] = process_path(s[1])74 print("Loaded", file=sys.stderr)75def opposite_sign(o):76 if o == '+':77 return '-'78 elif o == '-':79 return '+'80 assert False81def swap_sign(n_o):82 return n_o[:-1] + opposite_sign(n_o[-1])83def need_swap(n_o):84 if n_o[-1] == '+':85 return False86 elif n_o[-1] == '-':87 return True88 assert False89def resolve(n_o, resolved):90 if n_o.startswith(args.resolved_prefix):91 resolved.append(n_o)92 return93 name = n_o[:-1]94 if args.resolved_marker:95 pos=name.find(args.resolved_marker)96 assert pos != 097 if pos > 0:98 name=name[:pos]99 if not args.partial_resolve and name not in mapping:100 print("Problem with ", name, file=sys.stderr)101 assert args.partial_resolve or name in mapping102 if usage[name] > 0:103 print(name, "used multiple times", file=sys.stderr)104 usage[name] += 1105 if name not in mapping and args.partial_resolve:106 resolved.append(name + n_o[-1])107 return108 parts = mapping[name]109 if need_swap(n_o):110 for i in range(len(parts),0,-1):111 p = parts[i - 1]112 resolve(swap_sign(p), resolved)113 else:114 for p in parts:115 resolve(p, resolved)116print("Resolving segment composition", file=sys.stderr)117for s in names:118 resolved = []119 resolve(s + '+', resolved)120 if args.gaf_paths:121 print(s, ''.join([transform_to_gaf(s) for s in resolved]))122 else:123 print(s, ','.join(resolved))...

Full Screen

Full Screen

commands.py

Source:commands.py Github

copy

Full Screen

...15_get_init_logger = functools.partial(get_logger, "init")16def run(args: Namespace) -> int:17 enable_console_timestamp()18 builder = RunbookBuilder.from_path(args.runbook, args.variables)19 notifier_data = builder.partial_resolve(constants.NOTIFIER)20 if notifier_data:21 notifier_runbook = schema.load_by_type_many(schema.Notifier, notifier_data)22 notifier.initialize(runbooks=notifier_runbook)23 run_message = messages.TestRunMessage(24 runbook_name=builder.partial_resolve(constants.NAME),25 test_project=builder.partial_resolve(constants.TEST_PROJECT),26 test_pass=builder.partial_resolve(constants.TEST_PASS),27 run_name=constants.RUN_NAME,28 tags=builder.partial_resolve(constants.TAGS),29 )30 notifier.notify(run_message)31 run_status = messages.TestRunStatus.FAILED32 run_timer = create_timer()33 run_error_message = ""34 try:35 runner = RootRunner(runbook_builder=builder)36 asyncio.run(runner.start())37 run_status = messages.TestRunStatus.SUCCESS38 except Exception as identifier:39 run_error_message = str(identifier)40 raise identifier41 finally:42 run_message.status = run_status43 run_message.elapsed = run_timer.elapsed()44 run_message.message = run_error_message45 notifier.notify(run_message)46 notifier.finalize()47 run_finalize()48 return runner.exit_code49def run_finalize() -> None:50 try:51 plugin_manager.hook.on_run_finalize()52 except Exception as exception:53 log = _get_init_logger("run_finalize")54 log.info(f"run_finalize failed with error {exception}")55# check runbook56def check(args: Namespace) -> int:57 RunbookBuilder.from_path(args.runbook, args.variables)58 return 059def list_start(args: Namespace) -> int:60 builder = RunbookBuilder.from_path(args.runbook, args.variables)61 list_all = cast(Optional[bool], args.list_all)62 log = _get_init_logger("list")63 if args.type == constants.LIST_CASE:64 if list_all:65 cases: Iterable[TestCaseRuntimeData] = select_testcases()66 else:67 cases = select_testcases(builder.partial_resolve(constants.TESTCASE))68 for case_data in cases:69 log.info(70 f"case: {case_data.name}, suite: {case_data.metadata.suite.name}, "71 f"area: {case_data.suite.area}, "72 f"category: {case_data.suite.category}, "73 f"tags: {','.join(case_data.suite.tags)}, "74 f"priority: {case_data.priority}"75 )76 else:77 raise LisaException(f"unknown list type '{args.type}'")78 log.info("list information here")79 return 080class CommandHookSpec:81 @hookspec...

Full Screen

Full Screen

plot.py

Source:plot.py Github

copy

Full Screen

1#!/usr/bin/python32import numpy as np3import matplotlib.pyplot as plt4resolve = np.genfromtxt('resolve', delimiter=',', names=['size', 'time'])5plt.plot(resolve['size'], resolve['time'], label='Execution time for resolve_indirect_jumps on synthetic BIR programs')6plt.xlabel('Program size (middle blocks)')7plt.ylabel('Time (seconds)')8plt.title('Experiment 1')9plt.legend()10plt.savefig('resolve.png')11plt.figure()12partial_resolve = np.genfromtxt('partial_resolve', delimiter=',', names=['size', 'time'])13plt.plot(partial_resolve['size'], partial_resolve['time'], label='Execution time for resolve_indirect_jumps on synthetic BIR programs')14plt.xlabel('Program size (middle blocks)')15plt.ylabel('Time (seconds)')16plt.title('Experiment 2')17plt.legend()18plt.savefig('partial_resolve.png')19plt.figure()20constant_resolve = np.genfromtxt('constant_resolve', delimiter=',', names=['size', 'time'])21plt.plot(constant_resolve['size'], constant_resolve['time'], label='Execution time for resolve_indirect_jumps on synthetic BIR programs')22plt.xlabel('Program size (middle blocks)')23plt.ylabel('Time (seconds)')24plt.title('Experiment 3')25plt.legend()26plt.savefig('constant_resolve.png')27plt.figure()28transfer = np.genfromtxt('transfer', delimiter=',', names=['size', 'time'])29plt.plot(transfer['size'], transfer['time'], label='Execution time for transfer_contract on synthetic BIR programs')30plt.xlabel('Program size (middle blocks)')31plt.ylabel('Time (seconds)')32plt.title('Experiment 4')33plt.legend()34plt.savefig('transfer.png')...

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