Skip to content

Commit 2f67275

Browse files
zdevitometa-codesync[bot]
authored andcommitted
Small fix so kill works the same as apply (#3360)
Summary: Pull Request resolved: #3360 previously you could end up with a job where `apply` can find the Job object but `kill` could not because the `monarch` command does not naturally have `.` in its path. This just makes sure it does. ghstack-source-id: 362426015 exported-using-ghexport Reviewed By: dulinriley Differential Revision: D99494215 fbshipit-source-id: dff20661a90d8a1754ddfb2bba470fe10c997611
1 parent 4d31835 commit 2f67275

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

python/monarch/_src/job/job.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,6 @@ def _import_job_from_spec(module_path: str) -> JobTrait:
737737

738738
if "." not in module_path:
739739
raise ValueError(f"module_path must be 'module.attr', got {module_path!r}")
740-
cwd = os.getcwd()
741-
if cwd not in sys.path:
742-
sys.path.insert(0, cwd)
743740
mod_name, attr_name = module_path.rsplit(".", 1)
744741
mod = importlib.import_module(mod_name)
745742
job = getattr(mod, attr_name, None)

python/monarch/tools/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import argparse
99
import importlib.resources
1010
import json
11+
import os
1112
import sys
1213

1314
from monarch.tools.commands import (
@@ -387,6 +388,9 @@ def get_parser() -> argparse.ArgumentParser:
387388

388389

389390
def main(argv: list[str] = sys.argv[1:]) -> None:
391+
cwd = os.getcwd()
392+
if cwd not in sys.path:
393+
sys.path.insert(0, cwd)
390394
parser = get_parser()
391395
args = parser.parse_args(argv)
392396
if not hasattr(args, "func"):

0 commit comments

Comments
 (0)