Skip to content

Commit

Permalink
helper method for manipulating the TestRun object directly
Browse files Browse the repository at this point in the history
  • Loading branch information
srivatsankrishnan committed Jan 11, 2025
1 parent d5d1e14 commit 96ab055
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/cloudai/cli/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:

for action in agent.get_all_combinations():
for key, value in action.items():
tr.test.test_definition.cmd_args_dict[key] = value
update_nested_attr(tr.test.test_definition.cmd_args, key, value)
runner = Runner(args.mode, system, test_scenario)
asyncio.run(runner.run())

Expand All @@ -158,6 +158,21 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:
return 0


def update_nested_attr(obj, attr_path, value):
"""Update a nested attribute of an object."""
attrs = attr_path.split(".")
# hot fix. Will be removed after the issue is fixed in the codebase
prefix = "Grok"
if attrs[0] == prefix:
attrs = attrs[1:]
for attr in attrs[:-1]:
if hasattr(obj, attr):
obj = getattr(obj, attr)
else:
raise AttributeError(f"{type(obj).__name__!r} object has no attribute {attr!r}")
setattr(obj, attrs[-1], value)


def handle_generate_report(args: argparse.Namespace) -> int:
"""
Generate a report based on the existing configuration and test results.
Expand Down

0 comments on commit 96ab055

Please sign in to comment.