Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
hollandjg committed Oct 8, 2024
1 parent 1f272e4 commit dcc8480
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions norms/wsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ async def main():
async with serve(echo, "localhost", 8765):
await asyncio.Future() # run forever


if __name__ == "__main__":
asyncio.run(main())
17 changes: 6 additions & 11 deletions src/social_norms_trees/atomic_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ def exchange(
--> A
"""

node0_parent, node0_index = node0.parent, node0.parent.children.index(
node0)
node1_parent, node1_index = node1.parent, node1.parent.children.index(
node1)
node0_parent, node0_index = node0.parent, node0.parent.children.index(node0)
node1_parent, node1_index = node1.parent, node1.parent.children.index(node1)

move(node0, (node1_parent, node1_index))
move(node1, (node0_parent, node0_index))
Expand Down Expand Up @@ -527,7 +525,7 @@ def prompt_identify_composite(
tree: py_trees.behaviour.Behaviour,
message: str = "Which composite node?",
display_nodes: bool = True,
skip_label: str = "_"
skip_label: str = "_",
) -> Tuple[py_trees.composites.Composite, int]:
"""
Example:
Expand Down Expand Up @@ -655,8 +653,7 @@ def format_library_with_indices(library: List[py_trees.behaviour.Behaviour]):


# Wrapper functions for the atomic operations which give them a UI.
MutationResult = namedtuple(
"MutationResult", ["result", "tree", "function", "kwargs"])
MutationResult = namedtuple("MutationResult", ["result", "tree", "function", "kwargs"])


def mutate_chooser(*fs: Union[Callable], message="Which action?"):
Expand Down Expand Up @@ -723,14 +720,12 @@ def prompt_get_mutate_arguments(annotation: GenericAlias, tree, library):
return node
elif annotation_ == str(CompositeIndex):
_logger.debug("in CompositeIndex")
composite_node = prompt_identify_composite(
tree, message="Which parent?")
composite_node = prompt_identify_composite(tree, message="Which parent?")
index = prompt_identify_child_index(composite_node)
return composite_node, index
elif annotation_ == str(NewNode):
_logger.debug("in NewNode")
new_node = prompt_identify_library_node(
library, "Which node from the library?")
new_node = prompt_identify_library_node(library, "Which node from the library?")
return new_node
else:
_logger.debug("in 'else'")
Expand Down
25 changes: 14 additions & 11 deletions src/social_norms_trees/ui_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def experiment_setup(db, origin_tree):
print("\n")
participant_id = participant_login()

experiment_id = initialize_experiment_record(
db, participant_id, origin_tree)
experiment_id = initialize_experiment_record(db, participant_id, origin_tree)

print("\nSetup Complete.\n")

Expand All @@ -61,8 +60,7 @@ def participant_login():

def load_resources(file_path):
try:
print(
f"\nLoading behavior tree and behavior library from {file_path}...\n")
print(f"\nLoading behavior tree and behavior library from {file_path}...\n")
with open(file_path, "r") as file:
resources = json.load(file)

Expand Down Expand Up @@ -137,8 +135,7 @@ def run_experiment(db, origin_tree, experiment_id, behavior_library):
db[experiment_id]["action_history"].append(action_log)

elif action == 4:
origin_tree, action_log = add_node(
origin_tree, behavior_library)
origin_tree, action_log = add_node(origin_tree, behavior_library)
db[experiment_id]["action_history"].append(action_log)

else:
Expand Down Expand Up @@ -167,9 +164,16 @@ def run_experiment(db, origin_tree, experiment_id, behavior_library):

@app.command()
def main(
resources_file: Annotated[pathlib.Path, typer.Argument(help="file with the experimental context, behavior tree, and behavior library")],
db_file: Annotated[pathlib.Path, typer.Option(
help="file where the experimental results will be written")] = "db.json",
resources_file: Annotated[
pathlib.Path,
typer.Argument(
help="file with the experimental context, behavior tree, and behavior library"
),
],
db_file: Annotated[
pathlib.Path,
typer.Option(help="file where the experimental results will be written"),
] = "db.json",
):
print("AIT Prototype #1 Simulator")

Expand All @@ -179,8 +183,7 @@ def main(

# load tree to run experiment on, and behavior library

original_tree, behavior_library, context_paragraph = load_resources(
resources_file)
original_tree, behavior_library, context_paragraph = load_resources(resources_file)
print(f"\nContext of this experiment: {context_paragraph}")

participant_id, experiment_id = experiment_setup(db, original_tree)
Expand Down

0 comments on commit dcc8480

Please sign in to comment.