fix: clarify missing reme launcher env#43
fix: clarify missing reme launcher env#43haosenwang1018 wants to merge 1 commit intomodelscope:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request primarily focuses on code formatting improvements and the addition of environment variable validation for service launching. Key changes include standardizing string quotes, improving line-wrapping for readability, and updating the pty_launch function to raise a RuntimeError if required path or script environment variables are missing. New unit tests were added to verify this validation logic. Review feedback identifies a potential AttributeError when parsing the YAML configuration if the trainer key is missing, and points out a copy-paste error in the help text for the --db command-line argument.
| exp_name = config.get("trainer").get("experiment_name") | ||
| if exp_name is None or exp_name == "read_yaml_name": | ||
| if exp_name is not None: | ||
| exp_name = exp_name.replace("|", "-") | ||
| exp_name = os.path.basename(yaml_path).replace(".yaml", "") | ||
| else: | ||
| exp_name = exp_name.replace('|', '-') | ||
| exp_name = exp_name.replace("|", "-") |
There was a problem hiding this comment.
This block has a potential AttributeError on line 310. If the trainer key is missing or null in the YAML config, config.get("trainer") can be None, and None.get("experiment_name") will crash the program. The logic to determine exp_name is also unnecessarily complex and contains redundant code. The suggested change fixes the crash and simplifies the logic.
| exp_name = config.get("trainer").get("experiment_name") | |
| if exp_name is None or exp_name == "read_yaml_name": | |
| if exp_name is not None: | |
| exp_name = exp_name.replace("|", "-") | |
| exp_name = os.path.basename(yaml_path).replace(".yaml", "") | |
| else: | |
| exp_name = exp_name.replace('|', '-') | |
| exp_name = exp_name.replace("|", "-") | |
| trainer_config = config.get("trainer") or {} | |
| exp_name = trainer_config.get("experiment_name") | |
| if exp_name is None or exp_name == "read_yaml_name": | |
| exp_name = os.path.basename(yaml_path).replace(".yaml", "") | |
| else: | |
| exp_name = exp_name.replace("|", "-") |
| required=False, | ||
| help='Path to configuration file' | ||
| parser.add_argument( | ||
| "--db", type=str, default="", required=False, help="Path to configuration file" |
There was a problem hiding this comment.
The help text for the --db argument is "Path to configuration file", which appears to be a copy-paste error from the --conf argument. Based on its usage, this argument is for setting debug tags. Please update the help text to reflect its actual purpose.
| "--db", type=str, default="", required=False, help="Path to configuration file" | |
| "--db", type=str, default="", required=False, help="Enable debug mode and set debug tags", |
Summary
--with-remeis used withoutREME_PATH/REME_SCRIPTTesting
uv run python -m pytest tests/test_launcher.py -quv run ruff check launcher.py tests/test_launcher.pyuv run ruff format --check launcher.py tests/test_launcher.pygit diff --check