From 5492f4b12338018fedb250f348e6abb8ad105454 Mon Sep 17 00:00:00 2001 From: Myungjin Lee Date: Tue, 10 Sep 2024 11:21:05 -0700 Subject: [PATCH] fix: error handle in initial configuration (#89) When post installation script is triggered during installation, the initialization check file (init.txt) is not present, which raises an exception. This leads to the failed installation. The issue is fixed by catching the error and suppressing it (which is okay because it is only happening during the installation). --- README.md | 8 -------- multiworld/post_setup.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 41cc0d7..a22684c 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ The framework is built on top of PyTorch, a widely-used deep learning framework, ## Installation -### Step 1: Install multiworld package - To use the latest official package, ```bash @@ -56,12 +54,6 @@ To install the package from source, pip install . ``` -### Step 2: Run post installation script - -```bash -m8d-post-setup -``` - ## Running Examples The list of all examples that are available can be found in the [`examples`](/examples) folder. diff --git a/multiworld/post_setup.py b/multiworld/post_setup.py index b3ccdd3..822e630 100644 --- a/multiworld/post_setup.py +++ b/multiworld/post_setup.py @@ -22,13 +22,21 @@ def configure_once(): + """Configure multiworld once when it is used for the first time.""" package_name = __name__.split(".")[0] path_to_sitepackages = site.getsitepackages()[0] init_file_path = os.path.join(path_to_sitepackages, package_name, "init.txt") - with open(init_file_path, "r") as file: - patch_applied = file.read() + try: + with open(init_file_path, "r") as file: + patch_applied = file.read() + except FileNotFoundError: + message = "WARNING: initialization check file not found; " + message += f"{package_name} is not installed correctly; " + message += "please reinstall." + print(message) + return if patch_applied == "true": return