Skip to content

Commit dc97201

Browse files
authored
Move fake wandb hook to air test file (#51303)
Breaking core -> libraries dependencies. --------- Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
1 parent d1ed514 commit dc97201

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

python/ray/_private/test_utils.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,17 +2143,6 @@ def get_gcs_memory_used():
21432143
return sum(m.values())
21442144

21452145

2146-
def wandb_populate_run_location_hook():
2147-
"""
2148-
Example external hook to populate W&B project and group env vars in
2149-
WandbIntegrationTest.testWandbLoggerConfig
2150-
"""
2151-
from ray.air.integrations.wandb import WANDB_GROUP_ENV_VAR, WANDB_PROJECT_ENV_VAR
2152-
2153-
os.environ[WANDB_PROJECT_ENV_VAR] = "test_project"
2154-
os.environ[WANDB_GROUP_ENV_VAR] = "test_group"
2155-
2156-
21572146
def safe_write_to_results_json(
21582147
result: dict,
21592148
default_file_name: str = "/tmp/release_test_output.json",

python/ray/air/tests/test_integration_wandb.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ def wandb_env():
100100
del os.environ[WANDB_ENV_VAR]
101101

102102

103+
def fake_wandb_populate_run_location_hook():
104+
"""Fake user-provided hook to populate W&B environment variables."""
105+
os.environ[WANDB_PROJECT_ENV_VAR] = "test_project"
106+
os.environ[WANDB_GROUP_ENV_VAR] = "test_group"
107+
108+
109+
FAKE_WANDB_POPULATE_RUN_LOCATION_HOOK_IMPORT_PATH = (
110+
"ray.air.tests.test_integration_wandb.fake_wandb_populate_run_location_hook"
111+
)
112+
113+
103114
class TestWandbLogger:
104115
def test_wandb_logger_project_group(self, monkeypatch):
105116
monkeypatch.setenv(WANDB_PROJECT_ENV_VAR, "test_project_from_env_var")
@@ -211,7 +222,7 @@ def test_wandb_logger_run_location_external_hook(self, monkeypatch):
211222
# Project and group env vars from external hook
212223
monkeypatch.setenv(
213224
WANDB_POPULATE_RUN_LOCATION_HOOK,
214-
"ray._private.test_utils.wandb_populate_run_location_hook",
225+
FAKE_WANDB_POPULATE_RUN_LOCATION_HOOK_IMPORT_PATH,
215226
)
216227
logger = WandbTestExperimentLogger(api_key="1234")
217228
logger.setup()

0 commit comments

Comments
 (0)