Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sweeps): Move run configs from entrypoint into params #4164

Merged
merged 5 commits into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion wandb/sdk/launch/sweeps/scheduler.py
Expand Up @@ -207,8 +207,9 @@ def _update_run_states(self) -> None:

def _add_to_launch_queue(
self,
entry_point: Optional[List[str]] = None,
run_id: Optional[str] = None,
entry_point: Optional[List[str]] = None,
config: Optional[Dict[str, Any]] = None,
) -> "public.QueuedRun":
"""Add a launch job to the Launch RunQueue."""
run_id = run_id or generate_id()
Expand All @@ -223,6 +224,7 @@ def _add_to_launch_queue(
queued_run = launch_add(
run_id=run_id,
entry_point=entry_point,
config=config,
uri=_uri,
job=_job,
project=self._project,
Expand Down
19 changes: 2 additions & 17 deletions wandb/sdk/launch/sweeps/scheduler_sweep.py
@@ -1,6 +1,5 @@
"""Scheduler for classic wandb Sweeps."""
import logging
import os
import pprint
import queue
import socket
Expand All @@ -9,7 +8,6 @@
from typing import Any, Dict, List

import wandb
from wandb import wandb_lib # type: ignore
from wandb.sdk.launch.sweeps import SchedulerError
from wandb.sdk.launch.sweeps.scheduler import (
LOG_PREFIX,
Expand All @@ -18,7 +16,6 @@
SimpleRunState,
SweepRun,
)
from wandb.wandb_agent import Agent as LegacySweepAgent

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -144,22 +141,10 @@ def _run(self) -> None:
wandb.termlog(
f"{LOG_PREFIX}Converting Sweep Run (RunID:{run.id}) to Launch Job"
)
# This is actually what populates the wandb config
# since it is used in wandb.init()
sweep_param_path = os.path.join(
os.environ.get(wandb.env.DIR, os.getcwd()),
"wandb",
f"sweep-{self._sweep_id}",
f"config-{run.id}.yaml",
)
wandb.termlog(f"{LOG_PREFIX}Saving params to {sweep_param_path}")
wandb_lib.config_util.save_config_file_from_dict(sweep_param_path, run.args)
# Construct entry point using legacy sweeps utilities
command_args = LegacySweepAgent._create_command_args({"args": run.args})["args"]
entry_point = ["python", run.program] + command_args
_ = self._add_to_launch_queue(
entry_point=entry_point,
run_id=run.id,
entry_point=["python", run.program] if run.program else None,
config={"overrides": {"run_config": run.args}},
)

def _exit(self) -> None:
Expand Down