-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(launch): Creates a
--build
flag for building an image then pus…
…hing to a queue (#4061)
- Loading branch information
1 parent
a0ae755
commit 3d1d06b
Showing
13 changed files
with
867 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,98 @@ | ||
import os | ||
|
||
import pytest | ||
import wandb | ||
from wandb.errors import LaunchError | ||
from wandb.sdk.internal.internal_api import Api as InternalApi | ||
from wandb.sdk.launch.launch_add import launch_add | ||
from wandb.sdk.launch.launch import run | ||
|
||
|
||
def test_launch_delete_queued_run(relay_server, runner, user, monkeypatch): | ||
def test_launch_repository( | ||
relay_server, runner, user, monkeypatch, wandb_init, test_settings | ||
): | ||
queue = "default" | ||
proj = "test" | ||
proj = "test1" | ||
repo = "testing123" | ||
uri = "https://github.com/wandb/examples.git" | ||
entry_point = ["python", "/examples/examples/launch/launch-quickstart/train.py"] | ||
|
||
settings = test_settings({"project": proj}) | ||
api = InternalApi() | ||
os.environ["WANDB_PROJECT"] = proj # required for artifact query | ||
|
||
# create project | ||
run = wandb.init(project=proj) | ||
run.finish() | ||
monkeypatch.setattr( | ||
wandb.sdk.launch.builder.build, | ||
"validate_docker_installation", | ||
lambda: None, | ||
) | ||
|
||
monkeypatch.setattr( | ||
wandb.docker, | ||
"build", | ||
lambda tags, file, context_path: None, | ||
) | ||
|
||
def patched_docker_push(reg, tag): | ||
assert reg == repo | ||
|
||
monkeypatch.setattr( | ||
wandb.docker, | ||
"push", | ||
lambda reg, tag: patched_docker_push(reg, tag), | ||
) | ||
|
||
with relay_server(): | ||
wandb_init(settings=settings).finish() | ||
api.create_run_queue( | ||
entity=user, project=proj, queue_name=queue, access="PROJECT" | ||
) | ||
|
||
queued_run = launch_add( | ||
uri=uri, | ||
entity=user, | ||
project=proj, | ||
queue_name=queue, | ||
entry_point=entry_point, | ||
) | ||
with pytest.raises(LaunchError) as e_info: | ||
run( | ||
api, | ||
uri=uri, | ||
entity=user, | ||
project=proj, | ||
entry_point=entry_point, | ||
repository=repo, | ||
) | ||
|
||
assert "Failed to push image to repository" in str(e_info) | ||
|
||
|
||
def test_launch_incorrect_backend( | ||
relay_server, runner, user, monkeypatch, wandb_init, test_settings | ||
): | ||
proj = "test1" | ||
uri = "https://github.com/wandb/examples.git" | ||
entry_point = ["python", "/examples/examples/launch/launch-quickstart/train.py"] | ||
settings = test_settings({"project": proj}) | ||
api = InternalApi() | ||
|
||
monkeypatch.setattr( | ||
"wandb.sdk.launch.launch.fetch_and_validate_project", | ||
lambda _1, _2: "something", | ||
) | ||
|
||
monkeypatch.setattr( | ||
wandb.sdk.launch.builder.build, | ||
"validate_docker_installation", | ||
lambda: None, | ||
) | ||
|
||
monkeypatch.setattr( | ||
"wandb.docker", | ||
lambda: None, | ||
) | ||
|
||
with relay_server(): | ||
r = wandb_init(settings=settings) | ||
|
||
assert queued_run.state == "pending" | ||
with pytest.raises(LaunchError) as e_info: | ||
run( | ||
api, | ||
uri=uri, | ||
entity=user, | ||
project=proj, | ||
entry_point=entry_point, | ||
resource="testing123", | ||
) | ||
|
||
queued_run.delete() | ||
assert "Resource name not among available resources" in str(e_info) | ||
r.finish() |
Oops, something went wrong.