Skip to content

Commit

Permalink
checking if the input of the tool comes as action_input first. improv…
Browse files Browse the repository at this point in the history
…e results message in setup and run and rdf tool
  • Loading branch information
Jgmedina95 committed Feb 20, 2024
1 parent bbdac2f commit a4012ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions mdagent/tools/base_tools/analysis_tools/rdf_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RDFTool(BaseTool):
args_schema = RDFToolInput
path_registry: Optional[PathRegistry]

def _run(self, **input):
def _run(self, input):
try:
inputs = self.validate_input(input)
except ValueError as e:
Expand All @@ -60,6 +60,9 @@ def _run(self, **input):
elif "Invalid file extension" in str(e):
print("File Extension Not Supported in RDF tool: ", str(e))
return ("File Extension Not Supported", str(e))
elif "Missing Inputs" in str(e):
print("Missing Inputs in RDF tool: ", str(e))
return ("Missing Inputs", str(e))
else:
raise ValueError(f"Error during inputs in RDF tool {e}")

Expand Down Expand Up @@ -108,6 +111,9 @@ def _arun(self, input):
pass

def validate_input(self, input):
if "action_input" in input:
input = input["action_input"]

trajectory_id = input.get("trajectory_fileid", None)

topology_id = input.get("topology_fileid", None)
Expand All @@ -117,11 +123,11 @@ def validate_input(self, input):
selections = input.get("selections", [])

if not trajectory_id:
raise ValueError("Incorrect Inputs: Trajectory file ID is required")
raise ValueError("Missing Inputs: Trajectory file ID is required")

# check if trajectory id is valid
fileids = self.path_registry.list_path_names()

print("fileids: ", fileids)
if trajectory_id not in fileids:
raise ValueError("Trajectory File ID not in path registry")

Expand All @@ -132,7 +138,7 @@ def validate_input(self, input):
# requires topology
if not topology_id:
raise ValueError(
"Incorrect Inputs: "
"Missing Inputs: "
"Topology file is required for trajectory "
"file with extension {}".format(ending)
)
Expand Down
6 changes: 3 additions & 3 deletions mdagent/tools/base_tools/simulation_tools/setup_and_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,11 @@ def _run(self, **input_args):
self.path_registry.map_path(*record)
return (
"Simulation done! \n Summary: \n"
"Record files written to files/records/ with IDs: "
f"{[record[0] for record in records]}\n"
"Record files written to files/records/ with IDs and descriptions: "
f"{[(record[0],record[2]) for record in records]}\n"
"Standalone script written to files/simulations/ with ID: "
f"{sim_id}.\n"
f"The topology file is saved as top_{sim_id} in files/pdb/"
f"The initial topology file ID is top_{sim_id} saved in files/pdb/"
)
except Exception as e:
print(f"An exception was found: {str(e)}.")
Expand Down

0 comments on commit a4012ef

Please sign in to comment.