Skip to content

Commit

Permalink
chore: remove wandb_init from sweep tests (#9008)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Duev <dmitryduev@users.noreply.github.com>
  • Loading branch information
kptkin and dmitryduev authored Dec 4, 2024
1 parent 4ba9be4 commit 0f914ea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 35 deletions.
4 changes: 2 additions & 2 deletions tests/system_tests/test_sweep/test_sweep_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def test_from_path(user):
assert isinstance(sweep, wandb.apis.public.Sweep)


def test_project_sweeps(user, wandb_init):
run = wandb_init(entity=user, project="testnosweeps")
def test_project_sweeps(user):
run = wandb.init(entity=user, project="testnosweeps")
run.finish()
sweep_id = wandb.sweep(SWEEP_CONFIG_BAYES, entity=user, project="test")
api = Api()
Expand Down
10 changes: 4 additions & 6 deletions tests/system_tests/test_sweep/test_sweep_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ def mock_run_complete_scheduler(self, *args, **kwargs):
assert scheduler.state == SchedulerState.FAILED


def test_sweep_scheduler_sweep_id_with_job(user, wandb_init, monkeypatch):
def test_sweep_scheduler_sweep_id_with_job(user, monkeypatch):
_patch_wandb_run(monkeypatch)
sweep_config = VALID_SWEEP_CONFIGS_MINIMAL[0]

# make a job
run = wandb_init()
run = wandb.init()
job_artifact = run._log_job_artifact_with_image("ljadnfakehbbr", args=[])
job_name = job_artifact.wait().name
sweep_config["job"] = job_name
Expand Down Expand Up @@ -626,13 +626,11 @@ def mock_stop_run(*args, **kwargs):
assert "mock-run-id-1" not in _scheduler._runs


def test_launch_sweep_scheduler_try_executable_works(
user, wandb_init, test_settings, monkeypatch
):
def test_launch_sweep_scheduler_try_executable_works(user, test_settings, monkeypatch):
_patch_wandb_run(monkeypatch)
_project = "test-project"
settings = test_settings({"project": _project})
run = wandb_init(settings=settings)
run = wandb.init(settings=settings)
job_artifact = run._log_job_artifact_with_image("lala-docker-123", args=[])
job_name = f"{user}/{_project}/{job_artifact.wait().name}"

Expand Down
12 changes: 6 additions & 6 deletions tests/system_tests/test_sweep/test_wandb_agent_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from wandb.apis.public import Api


def test_agent_basic(wandb_init):
def test_agent_basic(user):
sweep_ids = []
sweep_configs = []
sweep_resumed = []
Expand All @@ -19,7 +19,7 @@ def test_agent_basic(wandb_init):
}

def train():
run = wandb_init()
run = wandb.init()
sweep_ids.append(run.sweep_id)
sweep_configs.append(dict(run.config))
sweep_resumed.append(run.resumed)
Expand All @@ -35,11 +35,11 @@ def train():
assert sweep_resumed[0] is False


def test_agent_config_merge(wandb_init):
def test_agent_config_merge(user):
sweep_configs = []

def train():
run = wandb_init(config={"extra": 2})
run = wandb.init(config={"extra": 2})
sweep_configs.append(dict(run.config))
run.finish()

Expand All @@ -57,11 +57,11 @@ def train():
assert sweep_configs[0] == {"a": 1, "extra": 2}


def test_agent_config_ignore(wandb_init):
def test_agent_config_ignore(user):
sweep_configs = []

def train():
run = wandb_init(config={"a": "ignored", "extra": 2})
run = wandb.init(config={"a": "ignored", "extra": 2})
sweep_configs.append(dict(run.config))
run.finish()

Expand Down
21 changes: 0 additions & 21 deletions tests/unit_tests/test_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,27 +395,6 @@ def test_fail_to_make_file(
wb_image.bind_to_run(mock_run(), "my key: an identifier", 0)


# def test_cant_serialize_to_other_run(mock_run):
# """This isn't implemented yet. Should work eventually."""
# other_run = wandb.wandb_sdk.wandb_run.Run(settings=wandb_init)
# other_run._set_backend(mock_run._backend)
# wb_image = wandb.Image(image)

# wb_image.bind_to_run(mock_run, "stuff", 10)

# with pytest.raises(AssertionError):
# wb_image.to_json(other_run)


# meta_expected = {
# "_type": "images/separated",
# "count": 1,
# "height": 28,
# "width": 28,
# }
# assert utils.subdict(meta, meta_expected) == meta_expected


################################################################################
# Test wandb.Audio
################################################################################
Expand Down

0 comments on commit 0f914ea

Please sign in to comment.