Skip to content

Commit 1d9a56a

Browse files
committed
observatory: toggle default lenses with config
1 parent 21896af commit 1d9a56a

5 files changed

Lines changed: 23 additions & 1 deletion

File tree

devtools/observatory/lenses/accuracy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,19 @@ def _clear_state(cls) -> None:
479479

480480
@classmethod
481481
def observe(cls, artifact: Any, context: ObservationContext) -> Any:
482+
483+
acc_config = context.config.get("accuracy", {})
484+
if not acc_config.get("enabled", True):
485+
return None
486+
482487
record_name = context.shared_state.get("record_name", "")
483488

484489
# Lazily configure evaluator on first "Exported Float" record
485490
if record_name == "Exported Float" and cls._evaluator is None:
486491
cls._configure_from_float_model(artifact)
487492

488-
acc_config = context.config.get("accuracy", {})
489493
evaluator = acc_config.get("evaluator") or cls._evaluator
494+
490495
if not evaluator:
491496
return None
492497

devtools/observatory/lenses/graph.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def _to_graph_module(cls, artifact: Any) -> Optional[torch.fx.GraphModule]:
4747

4848
@classmethod
4949
def observe(cls, artifact: Any, context: ObservationContext) -> Any:
50+
51+
graph_config = context.config.get("graph", {})
52+
if not graph_config.get("enabled", True):
53+
return None
54+
5055
graph_module = cls._to_graph_module(artifact)
5156
if graph_module is None:
5257
return None

devtools/observatory/lenses/metadata.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def get_name(cls) -> str:
3636

3737
@classmethod
3838
def observe(cls, artifact: Any, context: ObservationContext) -> Any:
39+
metadata_config = context.config.get("metadata", {})
40+
if not metadata_config.get("enabled", True):
41+
return None
42+
3943
artifact_type = str(type(artifact).__name__)
4044
node_count: Any = "N/A"
4145

devtools/observatory/lenses/per_layer_accuracy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ def _values(k: str) -> List[float]:
430430

431431
@classmethod
432432
def observe(cls, artifact: Any, context: ObservationContext) -> Any:
433+
acc_config = context.config.get("accuracy", {})
434+
if not acc_config.get("enabled", True):
435+
return None
436+
433437
graph_module = cls._to_graph_module(artifact)
434438
if graph_module is None:
435439
return None

devtools/observatory/lenses/stack_trace.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def _get_stack_trace(cls) -> List[Dict[str, Any]]:
6363

6464
@classmethod
6565
def observe(cls, artifact: Any, context: ObservationContext) -> Any:
66+
stacktrace_config = context.config.get("stacktrace", {})
67+
if not stacktrace_config.get("enabled", True):
68+
return None
69+
6670
try:
6771
return cls._get_stack_trace()
6872
except Exception as exc:

0 commit comments

Comments
 (0)