From 29738a78013cf89b72630e13d9369b3ce96fea2c Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Tue, 22 Dec 2020 02:16:39 +0100 Subject: [PATCH] Switch finetune and smiles app to use entrypoints --- README.md | 6 +++--- molbert/apps/finetune.py | 6 +++++- molbert/apps/smiles.py | 6 +++++- setup.py | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cab2a11..40e036a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ After downloading the weights, you can follow `scripts/featurize.py` to load the ## Train model from scratch: You can use the guacamol dataset (links at the [bottom](#data)) ```shell script -python molbert/apps/smiles.py \ +molbert_smiles \ --train_file data/guacamol_baselines/guacamol_v1_train.smiles \ --valid_file data/guacamol_baselines/guacamol_v1_valid.smiles \ --max_seq_length 128 \ @@ -52,7 +52,7 @@ After you have trained a model, and you would like to finetune on a certain trai For classification you can set can set the mode to `classification` and the `output_size` to 2. ```shell script -python molbert/apps/finetune.py \ +molbert_finetune \ --train_file path/to/train.csv \ --valid_file path/to/valid.csv \ --test_file path/to/test.csv \ @@ -63,7 +63,7 @@ python molbert/apps/finetune.py \ ``` For regression set the mode to `regression` and the `output_size` to 1. ```shell script -python molbert/apps/finetune.py \ +molbert_finetune \ --train_file path/to/train.csv \ --valid_file path/to/valid.csv \ --test_file path/to/test.csv \ diff --git a/molbert/apps/finetune.py b/molbert/apps/finetune.py index 3e31956..172f583 100644 --- a/molbert/apps/finetune.py +++ b/molbert/apps/finetune.py @@ -153,5 +153,9 @@ def parse_args(self, args) -> Namespace: return parsed_args +def main(): + FinetuneSmilesMolbertApp().run() + + if __name__ == '__main__': - trainer = FinetuneSmilesMolbertApp().run() + main() diff --git a/molbert/apps/smiles.py b/molbert/apps/smiles.py index 11e9486..e7ba5ec 100644 --- a/molbert/apps/smiles.py +++ b/molbert/apps/smiles.py @@ -27,5 +27,9 @@ def add_parser_arguments(parser: ArgumentParser) -> ArgumentParser: return parser -if __name__ == '__main__': +def main(): SmilesMolbertApp().run() + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index c8a9b2a..b6ea527 100644 --- a/setup.py +++ b/setup.py @@ -44,4 +44,10 @@ 'Programming Language :: Python :: 3', 'Operating System :: OS Independent', ), + entry_points={ + 'console_scripts': [ + 'molbert_smiles = molbert.apps.smiles:main', + 'molbert_finetune = molbert.apps.finetune:main', + ], + }, )