Skip to content

Commit 2f54bd4

Browse files
committed
feat: Ease MPNN command line usage
There were checks which prevented people from omitting --checkpoint_path when not using --config_json. Additionally, simplify use of SolubleMPNN with the default parameter set.
1 parent d6c07df commit 2f54bd4

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

models/mpnn/src/mpnn/inference_engines/mpnn.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ def __init__(
5050
device: str | torch.device | None = None,
5151
):
5252
# Store raw configuration
53-
self.model_type = model_type
54-
self.is_legacy_weights = is_legacy_weights
5553
self.out_directory = out_directory
5654
self.write_fasta = write_fasta
5755
self.write_structures = write_structures
@@ -61,12 +59,23 @@ def __init__(
6159
self.checkpoint_path = (
6260
str(
6361
REGISTERED_CHECKPOINTS[
64-
self.model_type.replace("_", "")
62+
model_type.replace("_", "")
6563
].get_default_path()
6664
)
6765
if not checkpoint_path
6866
else checkpoint_path
6967
)
68+
# The default weights sets are all legacy types
69+
self.is_legacy_weights = (
70+
True
71+
if not checkpoint_path
72+
else is_legacy_weights
73+
)
74+
# the soluble_mpnn type just changes the default weights -- otherwise it behaves like regular protein_mpnn
75+
if model_type == "soluble_mpnn":
76+
self.model_type = "protein_mpnn"
77+
else:
78+
self.model_type = model_type
7079

7180
# Determine the device (supports XPU, CUDA, and CPU).
7281
if device is not None:

models/mpnn/src/mpnn/utils/inference.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def build_arg_parser() -> argparse.ArgumentParser:
139139
parser.add_argument(
140140
"--model_type",
141141
type=str,
142-
choices=["protein_mpnn", "ligand_mpnn"],
142+
choices=["protein_mpnn", "ligand_mpnn", "soluble_mpnn"],
143143
help="Model type to use.",
144144
default=MPNN_GLOBAL_INFERENCE_DEFAULTS["model_type"],
145145
)
@@ -593,15 +593,11 @@ def cli_to_json(args: argparse.Namespace) -> dict[str, Any]:
593593
# Build a single-input JSON object from CLI
594594
if (
595595
args.model_type is None
596-
or args.checkpoint_path is None
597-
or args.is_legacy_weights is None
598596
or args.structure_path is None
599597
):
600598
raise ValueError(
601599
"When --config_json is not provided, "
602600
"--model_type, "
603-
"--checkpoint_path, "
604-
"--is_legacy_weights, "
605601
"--structure_path "
606602
"must all be specified."
607603
)

0 commit comments

Comments
 (0)