-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc2299b
commit 1a98445
Showing
14 changed files
with
159 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
import argparse | ||
|
||
from .formatter import CustomHelpFormatter | ||
|
||
|
||
def _add_export_model_parser(subparser: argparse._SubParsersAction) -> None: | ||
if export_model.__doc__ is not None: | ||
description = export_model.__doc__.split(r":param")[0] | ||
description = export_model.__doc__.split(":param")[0] | ||
else: | ||
description = None | ||
|
||
parser = subparser.add_parser( | ||
"export", | ||
description=description, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
formatter_class=CustomHelpFormatter, | ||
) | ||
parser.set_defaults(callable="export_model") | ||
|
||
parser.add_argument( | ||
"-m", | ||
"--model", | ||
dest="model_path", | ||
"model", | ||
type=str, | ||
required=True, | ||
help="Path to a saved model", | ||
help="Saved model which should be exprted", | ||
) | ||
parser.add_argument( | ||
"-o", | ||
"--output", | ||
dest="output_path", | ||
dest="output", | ||
type=str, | ||
required=False, | ||
default="exported.pt", | ||
help="Export path for the model.", | ||
help="Filename of the exported model (default: %(default)s).", | ||
) | ||
|
||
|
||
def export_model(model_path: str, output_path: str) -> None: | ||
def export_model(model: str, output: str) -> None: | ||
"""Export a pretrained model to run MD simulations | ||
:param model_path: Path to a saved model | ||
:param output_path: Path to save the exported model | ||
:param model: Path to a saved model | ||
:param output: Path to save the exported model | ||
""" | ||
raise NotImplementedError("model exporting is not implemented yet.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import argparse | ||
|
||
|
||
class CustomHelpFormatter(argparse.RawDescriptionHelpFormatter): | ||
"""Descriptions formatter showing positional arguments before optionals.""" | ||
|
||
def _format_usage(self, usage, actions, groups, prefix): | ||
if usage is None: | ||
# split optionals from positionals | ||
optionals = [] | ||
positionals = [] | ||
for action in actions: | ||
if action.option_strings: | ||
optionals.append(action) | ||
else: | ||
positionals.append(action) | ||
|
||
prog = "%(prog)s" % dict(prog=self._prog) | ||
|
||
# build full usage string | ||
format = self._format_actions_usage | ||
action_usage = format(positionals + optionals, groups) | ||
usage = " ".join([s for s in [prog, action_usage] if s]) | ||
|
||
# Call the superclass method to format the usage | ||
return super()._format_usage(usage, actions, groups, prefix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.