Skip to content

Commit 34e4080

Browse files
fix: Use generic weave panel when a defined panel cannot be found (#38)
* fix: Use generic weave panel when a defined panel cannot be found * chore: bump version to 1.0.10 * test: Change references to entity and project
1 parent 056ebb5 commit 34e4080

File tree

5 files changed

+466
-13
lines changed

5 files changed

+466
-13
lines changed

examples/workspaces/01_loading_and_cloning_workspaces.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import wandb_workspaces.workspaces as ws
44

5-
# !! edit to your entity and project !!
5+
# !! edit to your entity, project, and saved view !!
66
entity = os.getenv("WANDB_ENTITY")
7-
project = os.getenv("WANDB_PROJECT")
7+
project = "workspace-api-demo2"
8+
saved_view = "oydw4wx21l"
89

910
# 1. Load a workspace from URL
10-
url = "https://wandb.ai/megatruong/workspace-api-demo2?nw=vnizqj6vq3"
11+
url = f"https://wandb.ai/{entity}/{project}?nw={saved_view}"
1112
workspace = ws.Workspace.from_url(url)
1213

1314
# 2a. Edit the workspace and save to the same view

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
license = "Apache-2.0"
33
name = "wandb-workspaces"
4-
version = "0.1.9"
4+
version = "0.1.10"
55
description = "A library for programatically working with the Weights & Biases UI."
66
authors = ["Weights & Biases <[email protected]>"]
77
readme = "README.md"

tests/test_workspaces.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
import os
12
import sys
23
from typing import Any, Dict, Generic, Type, TypeVar
34

45
import pytest
56
from polyfactory.factories import DataclassFactory
67
from polyfactory.pytest_plugin import register_fixture
7-
8+
import wandb_workspaces.reports.v2.internal as _wr
89
import wandb_workspaces.expr
910
import wandb_workspaces.reports.v2 as wr
1011
import wandb_workspaces.workspaces as ws
12+
from tests.weave_panel_factory import WeavePanelFactory
1113
from wandb_workspaces.utils.validators import (
1214
validate_no_emoji,
1315
validate_spec_version,
1416
validate_url,
1517
)
1618
from wandb_workspaces.workspaces.errors import SpecVersionError, UnsupportedViewError
1719

20+
ENTITY = os.getenv("WANDB_ENTITY")
21+
1822
T = TypeVar("T")
1923

2024

@@ -140,13 +144,13 @@ def test_filter_expr(expr, spec):
140144

141145

142146
def test_load_workspace_from_url():
143-
url = "https://wandb.ai/megatruong/workspace-api-demo?nw=vs71wsgdvrz"
147+
url = f"https://wandb.ai/{ENTITY}/workspace-api-demo?nw=tkdujz254ke"
144148
workspace = ws.Workspace.from_url(url) # noqa: F841
145149

146150

147151
@pytest.mark.xfail(reason="Saving to the same workspace is currently bugged")
148152
def test_save_workspace():
149-
workspace = ws.Workspace(entity="megatruong", project="workspace-api-demo")
153+
workspace = ws.Workspace(entity=ENTITY, project="workspace-api-demo")
150154
workspace.save()
151155
workspace_name = workspace._internal_name
152156

@@ -159,7 +163,7 @@ def test_save_workspace():
159163

160164

161165
def test_save_workspace_as_new_view():
162-
workspace = ws.Workspace(entity="megatruong", project="workspace-api-demo")
166+
workspace = ws.Workspace(entity=ENTITY, project="workspace-api-demo")
163167
workspace.save_as_new_view()
164168
workspace_name = workspace._internal_name
165169

@@ -243,3 +247,24 @@ def test_validate_url(example, should_pass):
243247
else:
244248
with pytest.raises(UnsupportedViewError):
245249
validate_url(example)
250+
251+
252+
@pytest.mark.parametrize(
253+
"panel_config, should_return_instance",
254+
[
255+
(
256+
WeavePanelFactory.build_summary_table_panel(),
257+
wr.interface.WeavePanelSummaryTable,
258+
),
259+
(WeavePanelFactory.build_artifact_panel(), wr.interface.WeavePanelArtifact),
260+
(
261+
WeavePanelFactory.build_artifact_version_panel(),
262+
wr.interface.WeavePanelArtifactVersionedFile,
263+
),
264+
(WeavePanelFactory.build_run_var_panel(), wr.interface.WeavePanel),
265+
(_wr.UnknownPanel(), wr.interface.UnknownPanel),
266+
],
267+
)
268+
def test_panel_lookup(panel_config, should_return_instance):
269+
panel = wr.interface._lookup_panel(panel_config)
270+
assert isinstance(panel, should_return_instance)

0 commit comments

Comments
 (0)