MCPcopy Create free account
hub / github.com/pytorch/executorch / server

Function server

devtools/visualization/visualization_utils_test.py:33–59  ·  view source on GitHub ↗

Mock relevant calls in visualization.visualize and check that parameters have their expected value.

()

Source from the content-addressed store, hash-verified

31
32@pytest.fixture
33def server():
34 """Mock relevant calls in visualization.visualize and check that parameters have their expected value."""
35 monkeypatch = pytest.MonkeyPatch()
36 with monkeypatch.context():
37 _called_reuse_server = False
38
39 def mock_set_reuse_server(self):
40 nonlocal _called_reuse_server
41 _called_reuse_server = True
42
43 def mock_add_model_from_pytorch(self, name, exported_program, settings):
44 assert isinstance(exported_program, ExportedProgram)
45
46 def mock_visualize_from_config(cur_config, no_open_in_browser):
47 pass
48
49 monkeypatch.setattr(
50 ModelExplorerConfig, "set_reuse_server", mock_set_reuse_server
51 )
52 monkeypatch.setattr(
53 ModelExplorerConfig, "add_model_from_pytorch", mock_add_model_from_pytorch
54 )
55 monkeypatch.setattr(
56 visualization_utils, "visualize_from_config", mock_visualize_from_config
57 )
58 yield monkeypatch.context
59 assert _called_reuse_server, "Did not call reuse_server"
60
61
62class Linear(torch.nn.Module):

Callers 6

test_visualize_to_edgeFunction · 0.85
test_visualize_partitionFunction · 0.85
test_visualize_graphFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected