Skip to content

Commit cc6e633

Browse files
committed
revert changes
1 parent 7c53b19 commit cc6e633

File tree

2 files changed

+7
-300
lines changed

2 files changed

+7
-300
lines changed

codeflash/code_utils/instrument_existing_tests.py

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ def inject_profiling_into_existing_test(
345345
tree = InjectPerfOnly(func, test_module_path, test_framework, call_positions, mode=mode).visit(tree)
346346
new_imports = [
347347
ast.Import(names=[ast.alias(name="time")]),
348-
ast.Import(names=[ast.alias(name="inspect")]),
349348
ast.Import(names=[ast.alias(name="gc")]),
350349
ast.Import(names=[ast.alias(name="os")]),
351350
]
@@ -355,7 +354,7 @@ def inject_profiling_into_existing_test(
355354
)
356355
if test_framework == "unittest":
357356
new_imports.append(ast.Import(names=[ast.alias(name="timeout_decorator")]))
358-
tree.body = [*new_imports, create_wrapper_function(mode), create_async_wrapper_inner(), *tree.body]
357+
tree.body = [*new_imports, create_wrapper_function(mode), *tree.body]
359358
return True, isort.code(ast.unparse(tree), float_to_top=True)
360359

361360

@@ -535,39 +534,13 @@ def create_wrapper_function(mode: TestingMode = TestingMode.BEHAVIOR) -> ast.Fun
535534
),
536535
lineno=lineno + 11,
537536
),
538-
ast.If(
539-
test=ast.Call(
540-
func=ast.Attribute(
541-
value=ast.Name(id="inspect", ctx=ast.Load()), attr="iscoroutinefunction", ctx=ast.Load()
542-
),
543-
args=[ast.Name(id="wrapped", ctx=ast.Load())],
544-
keywords=[],
537+
ast.Assign(
538+
targets=[ast.Name(id="return_value", ctx=ast.Store())],
539+
value=ast.Call(
540+
func=ast.Name(id="wrapped", ctx=ast.Load()),
541+
args=[ast.Starred(value=ast.Name(id="args", ctx=ast.Load()), ctx=ast.Load())],
542+
keywords=[ast.keyword(arg=None, value=ast.Name(id="kwargs", ctx=ast.Load()))],
545543
),
546-
body=[
547-
ast.Assign(
548-
targets=[ast.Name(id="return_value", ctx=ast.Store())],
549-
value=ast.Call(
550-
func=ast.Name(id="codeflash_async_wrap_inner", ctx=ast.Load()),
551-
args=[
552-
ast.Name(id="wrapped", ctx=ast.Load()),
553-
ast.Starred(value=ast.Name(id="args", ctx=ast.Load()), ctx=ast.Load()),
554-
],
555-
keywords=[ast.keyword(arg=None, value=ast.Name(id="kwargs", ctx=ast.Load()))],
556-
),
557-
lineno=lineno + 12,
558-
)
559-
],
560-
orelse=[
561-
ast.Assign(
562-
targets=[ast.Name(id="return_value", ctx=ast.Store())],
563-
value=ast.Call(
564-
func=ast.Name(id="wrapped", ctx=ast.Load()),
565-
args=[ast.Starred(value=ast.Name(id="args", ctx=ast.Load()), ctx=ast.Load())],
566-
keywords=[ast.keyword(arg=None, value=ast.Name(id="kwargs", ctx=ast.Load()))],
567-
),
568-
lineno=lineno + 12,
569-
)
570-
],
571544
lineno=lineno + 12,
572545
),
573546
ast.Assign(
@@ -756,32 +729,3 @@ def create_wrapper_function(mode: TestingMode = TestingMode.BEHAVIOR) -> ast.Fun
756729
decorator_list=[],
757730
returns=None,
758731
)
759-
760-
761-
def create_async_wrapper_inner() -> ast.AsyncFunctionDef:
762-
return ast.AsyncFunctionDef(
763-
name="codeflash_async_wrap_inner",
764-
args=ast.arguments(
765-
args=[ast.arg(arg="wrapped", annotation=None)],
766-
vararg=ast.arg(arg="args"),
767-
kwarg=ast.arg(arg="kwargs"),
768-
posonlyargs=[],
769-
kwonlyargs=[],
770-
kw_defaults=[],
771-
defaults=[],
772-
),
773-
body=[
774-
ast.Return(
775-
value=ast.Await(
776-
value=ast.Call(
777-
func=ast.Name(id="wrapped", ctx=ast.Load()),
778-
args=[ast.Starred(value=ast.Name(id="args", ctx=ast.Load()), ctx=ast.Load())],
779-
keywords=[ast.keyword(arg=None, value=ast.Name(id="kwargs", ctx=ast.Load()))],
780-
)
781-
)
782-
)
783-
],
784-
decorator_list=[],
785-
returns=None,
786-
lineno=1,
787-
)

tests/test_async_instrumentation.py

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)