Skip to content

Commit 8d83333

Browse files
d4l3kfacebook-github-bot
authored andcommitted
ray_driver: switch import ordering to prefer local file over pip installed TorchX (#490)
Summary: This fixes the case where there's an old version of TorchX installed in ray `requirements.txt` Pull Request resolved: #490 Test Plan: pyre Reviewed By: msaroufim Differential Revision: D36487346 Pulled By: d4l3k fbshipit-source-id: b8406a7a3e10fcc7797717ab732640e28b77aa85
1 parent 5647c46 commit 8d83333

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

torchx/schedulers/ray/ray_driver.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@
99
import os
1010
import subprocess
1111
import sys
12-
from typing import Dict, List, Optional, Tuple
12+
from typing import Dict, List, Optional, Tuple, TYPE_CHECKING
1313

1414
import ray
1515
from ray.train.utils import get_address_and_port
1616
from ray.util.placement_group import PlacementGroup
1717

18+
if TYPE_CHECKING:
19+
from torchx.schedulers.ray.ray_common import RayActor, TORCHX_RANK0_HOST
20+
1821
# Hack to make code work for tests as well as running ray job.
1922
# For tests the `torchx.schedulers.ray.ray_common` import must be used
2023
# For running ray jobs `ray_common` import must be used
2124
try:
22-
from torchx.schedulers.ray.ray_common import RayActor, TORCHX_RANK0_HOST
25+
# pyre-fixme[21]: Could not find a module corresponding to import `ray_common`.
26+
from ray_common import RayActor, TORCHX_RANK0_HOST # noqa: F811
2327
except ModuleNotFoundError:
24-
# pyre-ignore[21]: Could not find a module corresponding to import `ray_common`
25-
from ray_common import RayActor, TORCHX_RANK0_HOST
28+
from torchx.schedulers.ray.ray_common import RayActor, TORCHX_RANK0_HOST
2629

2730
_logger: logging.Logger = logging.getLogger(__name__)
2831
_logger.setLevel(logging.getLevelName(os.environ.get("LOGLEVEL", "INFO")))

0 commit comments

Comments
 (0)