1
+ import os
1
2
import sys
2
3
from typing import Any , Dict , Generic , Type , TypeVar
3
4
4
5
import pytest
5
6
from polyfactory .factories import DataclassFactory
6
7
from polyfactory .pytest_plugin import register_fixture
7
-
8
+ import wandb_workspaces . reports . v2 . internal as _wr
8
9
import wandb_workspaces .expr
9
10
import wandb_workspaces .reports .v2 as wr
10
11
import wandb_workspaces .workspaces as ws
12
+ from tests .weave_panel_factory import WeavePanelFactory
11
13
from wandb_workspaces .utils .validators import (
12
14
validate_no_emoji ,
13
15
validate_spec_version ,
14
16
validate_url ,
15
17
)
16
18
from wandb_workspaces .workspaces .errors import SpecVersionError , UnsupportedViewError
17
19
20
+ ENTITY = os .getenv ("WANDB_ENTITY" )
21
+
18
22
T = TypeVar ("T" )
19
23
20
24
@@ -140,13 +144,13 @@ def test_filter_expr(expr, spec):
140
144
141
145
142
146
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 "
144
148
workspace = ws .Workspace .from_url (url ) # noqa: F841
145
149
146
150
147
151
@pytest .mark .xfail (reason = "Saving to the same workspace is currently bugged" )
148
152
def test_save_workspace ():
149
- workspace = ws .Workspace (entity = "megatruong" , project = "workspace-api-demo" )
153
+ workspace = ws .Workspace (entity = ENTITY , project = "workspace-api-demo" )
150
154
workspace .save ()
151
155
workspace_name = workspace ._internal_name
152
156
@@ -159,7 +163,7 @@ def test_save_workspace():
159
163
160
164
161
165
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" )
163
167
workspace .save_as_new_view ()
164
168
workspace_name = workspace ._internal_name
165
169
@@ -243,3 +247,24 @@ def test_validate_url(example, should_pass):
243
247
else :
244
248
with pytest .raises (UnsupportedViewError ):
245
249
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