Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] quickrun result error inspection #491

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions openfecli/commands/inspect_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import click
from openfecli import OFECommandPlugin

import json
import warnings

def unit_summary(unit_label, unit):
qualname = unit['__qualname__']
if qualname == "ProtocolUnitResult":
yield f"Unit {unit_label} ran successfully."
elif qualname == "ProtocolUnitFailure":
yield f"Unit {unit_label} failed with an error:"
yield f"{unit['exception'][0]}: {unit['exception'][1][0]}"
yield f"{unit['traceback']}"
else:
warnings.warn(f"Unexpected result type '{aqualname}' from unit "
f"{unit_label}")

def result_summary(result_dict):
import math
# we were success or failurea
estimate = result_dict['estimate']['magnitude']
success = "FAILURE" if math.isnan(estimate) else "SUCCESS"
yield f"This edge was a {success}."
units = result_dict['unit_results']
yield f"This edge consists of {len(units)} units."
yield ""
for unit_label, unit in units.items():
yield from unit_summary(unit_label, unit)
yield ""


@click.command(
'inspect-result',
short_help="Inspect result to show errors.",
)
@click.argument('result_json', type=click.Path(exists=True, readable=True))
def inspect_result(result_json):
with open(result_json, mode='r') as f:
result_dict = json.loads(f.read())

for line in result_summary(result_dict):
print(line)

PLUGIN = OFECommandPlugin(
command=inspect_result,
section="Quickrun Executor",
requires_ofe=(0, 10)
)

if __name__ == "__main__":
inspect_result()
21 changes: 14 additions & 7 deletions openfecli/commands/plan_rbfe_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from openfecli import OFECommandPlugin
from openfecli.parameters import (
MOL_DIR, PROTEIN, MAPPER, OUTPUT_DIR, COFACTORS,
NEW_STORAGE_OUTPUT, # separate line for easy delete later
)
from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output

Expand Down Expand Up @@ -82,9 +83,11 @@ def plan_rbfe_network_main(
help=OUTPUT_DIR.kwargs["help"] + " Defaults to `./alchemicalNetwork`.",
default="alchemicalNetwork",
)
@NEW_STORAGE_OUTPUT.parameter()
@print_duration
def plan_rbfe_network(
molecules: List[str], protein: str, cofactors: tuple[str], output_dir: str
molecules: List[str], protein: str, cofactors: tuple[str],
output_dir: str, new_storage: bool,
):
"""
Plan a relative binding free energy network, saved as JSON files for
Expand Down Expand Up @@ -175,12 +178,16 @@ def plan_rbfe_network(

# OUTPUT
write("Output:")
write("\tSaving to: " + str(output_dir))
plan_alchemical_network_output(
alchemical_network=alchemical_network,
ligand_network=ligand_network,
folder_path=OUTPUT_DIR.get(output_dir),
)
if new_storage:
write("Got new storage!")
...
else:
write("\tSaving to: " + str(output_dir))
plan_alchemical_network_output(
alchemical_network=alchemical_network,
ligand_network=ligand_network,
folder_path=OUTPUT_DIR.get(output_dir),
)


PLUGIN = OFECommandPlugin(
Expand Down
2 changes: 1 addition & 1 deletion openfecli/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .mol import MOL
from .mapper import MAPPER
from .output import OUTPUT_FILE_AND_EXT
from .output_dir import OUTPUT_DIR
from .output_dir import OUTPUT_DIR, NEW_STORAGE_OUTPUT
from .protein import PROTEIN
from .molecules import MOL_DIR, COFACTORS
7 changes: 7 additions & 0 deletions openfecli/parameters/output_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ def get_dir(user_input, context):
getter=get_dir,
type=click.Path(file_okay=False, resolve_path=True),
)

NEW_STORAGE_OUTPUT = Option(
"--new-storage",
help="use the new storage",
is_flag=True,
hidden=True,
)
Loading