Skip to content

Commit cb472d8

Browse files
committed
/* PR_START p/misc 01 */Rename Metricflow* -> MetricFlow*
1 parent d1425e3 commit cb472d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+282
-282
lines changed

metricflow-semantics/metricflow_semantics/experimental/dsi/manifest_object_lookup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
ModelObjectLookup,
1818
)
1919
from metricflow_semantics.experimental.dsi.simple_metric_model_object_lookup import SimpleMetricModelObjectLookup
20-
from metricflow_semantics.experimental.metricflow_exception import MetricflowInternalError
20+
from metricflow_semantics.experimental.metricflow_exception import MetricFlowInternalError
2121
from metricflow_semantics.experimental.ordered_set import FrozenOrderedSet, MutableOrderedSet, OrderedSet
2222
from metricflow_semantics.experimental.semantic_graph.model_id import SemanticModelId
2323
from metricflow_semantics.mf_logging.attribute_pretty_format import AttributeMapping, AttributePrettyFormattable
@@ -67,7 +67,7 @@ def _semantic_model_and_simple_metrics_pairs(self) -> Sequence[Pair[SemanticMode
6767
if metric_type is MetricType.SIMPLE:
6868
metric_aggregation_params = metric.type_params.metric_aggregation_params
6969
if metric_aggregation_params is None:
70-
raise MetricflowInternalError(
70+
raise MetricFlowInternalError(
7171
LazyFormat("A simple metric is missing `metric_aggregation_params`", metric=metric)
7272
)
7373
model_name_to_simple_metrics[metric_aggregation_params.semantic_model].append(metric)

metricflow-semantics/metricflow_semantics/experimental/dsi/simple_metric_model_object_lookup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from metricflow_semantics.experimental.dataclass_helpers import fast_frozen_dataclass
1414
from metricflow_semantics.experimental.dsi.model_object_lookup import ModelObjectLookup
15-
from metricflow_semantics.experimental.metricflow_exception import InvalidManifestException, MetricflowInternalError
15+
from metricflow_semantics.experimental.metricflow_exception import InvalidManifestException, MetricFlowInternalError
1616
from metricflow_semantics.mf_logging.attribute_pretty_format import AttributeMapping
1717
from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat
1818
from metricflow_semantics.model.semantics.simple_metric_input import (
@@ -45,20 +45,20 @@ def __init__( # noqa: D107
4545
model_name = semantic_model.name
4646
# Sanity checks.
4747
if not simple_metrics:
48-
raise MetricflowInternalError(
48+
raise MetricFlowInternalError(
4949
LazyFormat(
5050
"Can't initialize with empty `simple_metrics`",
5151
simple_metrics=simple_metrics,
5252
)
5353
)
5454
for metric in simple_metrics:
5555
if metric.type is not MetricType.SIMPLE:
56-
raise MetricflowInternalError(
56+
raise MetricFlowInternalError(
5757
LazyFormat("Can't initialize with a metric that is not a simple metric", metric=metric)
5858
)
5959
metric_aggregation_params = metric.type_params.metric_aggregation_params
6060
if metric_aggregation_params is None or metric_aggregation_params.semantic_model != model_name:
61-
raise MetricflowInternalError(
61+
raise MetricFlowInternalError(
6262
LazyFormat(
6363
"Can't initialize with a metric that is not associated with this semantic model",
6464
metric=metric,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from __future__ import annotations
22

33

4-
class MetricflowException(Exception):
4+
class MetricFlowException(Exception):
55
"""Base class for custom exceptions in MF."""
66

77
pass
88

99

10-
class MetricflowInternalError(MetricflowException):
10+
class MetricFlowInternalError(MetricFlowException):
1111
"""A non-recoverable error due to an issue within MF and not caused by the user.."""
1212

1313
pass
1414

1515

16-
class InvalidManifestException(MetricflowException):
16+
class InvalidManifestException(MetricFlowException):
1717
"""Raised when an invalid manifest is detected.
1818
1919
Generally, a semantic manifest is validated before it is passed into the engine. This is useful to raise in
@@ -23,5 +23,5 @@ class InvalidManifestException(MetricflowException):
2323
pass
2424

2525

26-
class GraphvizException(MetricflowException):
26+
class GraphvizException(MetricFlowException):
2727
"""Raised when there is an error when calling `graphviz` methods."""

metricflow-semantics/metricflow_semantics/experimental/mf_graph/formatting/graph_formatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from abc import ABC, abstractmethod
66

77
if typing.TYPE_CHECKING:
8-
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricflowGraph
8+
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricFlowGraph
99

1010
logger = logging.getLogger(__name__)
1111

1212

13-
class MetricflowGraphFormatter(ABC):
13+
class MetricFlowGraphFormatter(ABC):
1414
"""Interface for a graph-to-text formatter."""
1515

1616
@abstractmethod
17-
def format_graph(self, graph: MetricflowGraph) -> str:
17+
def format_graph(self, graph: MetricFlowGraph) -> str:
1818
"""Format the given graph to text."""
1919
raise NotImplementedError

metricflow-semantics/metricflow_semantics/experimental/mf_graph/formatting/pretty_graph_formatter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
from typing_extensions import override
77

8-
from metricflow_semantics.experimental.mf_graph.formatting.graph_formatter import MetricflowGraphFormatter
8+
from metricflow_semantics.experimental.mf_graph.formatting.graph_formatter import MetricFlowGraphFormatter
99
from metricflow_semantics.mf_logging.pretty_print import mf_pformat
1010

1111
if typing.TYPE_CHECKING:
12-
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricflowGraph
12+
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricFlowGraph
1313

1414
logger = logging.getLogger(__name__)
1515

1616

17-
class PrettyFormatGraphFormatter(MetricflowGraphFormatter):
17+
class PrettyFormatGraphFormatter(MetricFlowGraphFormatter):
1818
"""Formats a graph using `mf_pformat()`."""
1919

2020
@override
21-
def format_graph(self, graph: MetricflowGraph) -> str:
21+
def format_graph(self, graph: MetricFlowGraph) -> str:
2222
return mf_pformat(graph)

metricflow-semantics/metricflow_semantics/experimental/mf_graph/graph_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
from abc import ABC, abstractmethod
55
from typing import Generic, TypeVar
66

7-
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricflowGraph
7+
from metricflow_semantics.experimental.mf_graph.mf_graph import MetricFlowGraph
88

99
logger = logging.getLogger(__name__)
1010

1111

1212
OutputGraphT = TypeVar("OutputGraphT")
1313

1414

15-
class MetricflowGraphConverter(Generic[OutputGraphT], ABC):
15+
class MetricFlowGraphConverter(Generic[OutputGraphT], ABC):
1616
"""Base class for a class that converts graphs."""
1717

1818
@abstractmethod
19-
def convert_graph(self, graph: MetricflowGraph) -> OutputGraphT:
19+
def convert_graph(self, graph: MetricFlowGraph) -> OutputGraphT:
2020
"""Convert the graph to the given output type."""
2121
raise NotImplementedError()

metricflow-semantics/metricflow_semantics/experimental/mf_graph/graph_element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def displayed_properties(self) -> AnyLengthTuple[DisplayedProperty]:
1515
return ()
1616

1717

18-
class MetricflowGraphElement(HasDisplayedProperty, ABC):
18+
class MetricFlowGraphElement(HasDisplayedProperty, ABC):
1919
"""An element in a graph (e.g. node)."""
2020

2121
pass

metricflow-semantics/metricflow_semantics/experimental/mf_graph/graph_id.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
logger = logging.getLogger(__name__)
1616

1717

18-
class MetricflowGraphId(ABC):
18+
class MetricFlowGraphId(ABC):
1919
"""Interface for an object to identify different graphs."""
2020

2121
@property
@@ -25,7 +25,7 @@ def str_value(self) -> str:
2525
raise NotImplementedError
2626

2727

28-
class SequentialGraphId(MetricflowGraphId, MetricFlowPrettyFormattable):
28+
class SequentialGraphId(MetricFlowGraphId, MetricFlowPrettyFormattable):
2929
"""Graph IDs that are generated sequentially."""
3030

3131
# `itertools.count()` returns an iterable that is thread-safe, so this is a way of generating sequential

metricflow-semantics/metricflow_semantics/experimental/mf_graph/graph_labeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from metricflow_semantics.experimental.mf_graph.comparable import Comparable, ComparisonKey
99

1010

11-
class MetricflowGraphLabel(Comparable, ABC):
11+
class MetricFlowGraphLabel(Comparable, ABC):
1212
"""Base class for objects that can be used to lookup nodes / edges in a graph."""
1313

1414
@cached_property

metricflow-semantics/metricflow_semantics/experimental/mf_graph/mf_graph.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
DotGraphAttributeSet,
2121
DotNodeAttributeSet,
2222
)
23-
from metricflow_semantics.experimental.mf_graph.formatting.graph_formatter import MetricflowGraphFormatter
23+
from metricflow_semantics.experimental.mf_graph.formatting.graph_formatter import MetricFlowGraphFormatter
2424
from metricflow_semantics.experimental.mf_graph.formatting.pretty_graph_formatter import PrettyFormatGraphFormatter
2525
from metricflow_semantics.experimental.mf_graph.graph_element import (
26-
MetricflowGraphElement,
26+
MetricFlowGraphElement,
2727
)
28-
from metricflow_semantics.experimental.mf_graph.graph_id import MetricflowGraphId
29-
from metricflow_semantics.experimental.mf_graph.graph_labeling import MetricflowGraphLabel
30-
from metricflow_semantics.experimental.mf_graph.node_descriptor import MetricflowGraphNodeDescriptor
28+
from metricflow_semantics.experimental.mf_graph.graph_id import MetricFlowGraphId
29+
from metricflow_semantics.experimental.mf_graph.graph_labeling import MetricFlowGraphLabel
30+
from metricflow_semantics.experimental.mf_graph.node_descriptor import MetricFlowGraphNodeDescriptor
3131
from metricflow_semantics.experimental.ordered_set import FrozenOrderedSet, MutableOrderedSet, OrderedSet
3232
from metricflow_semantics.mf_logging.format_option import PrettyFormatOption
3333
from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat
@@ -39,17 +39,17 @@
3939

4040
logger = logging.getLogger(__name__)
4141

42-
NodeT = TypeVar("NodeT", bound="MetricflowGraphNode")
43-
EdgeT = TypeVar("EdgeT", bound="MetricflowGraphEdge")
42+
NodeT = TypeVar("NodeT", bound="MetricFlowGraphNode")
43+
EdgeT = TypeVar("EdgeT", bound="MetricFlowGraphEdge")
4444

45-
NodeT_co = TypeVar("NodeT_co", bound="MetricflowGraphNode", covariant=True)
46-
EdgeT_co = TypeVar("EdgeT_co", bound="MetricflowGraphEdge", covariant=True)
45+
NodeT_co = TypeVar("NodeT_co", bound="MetricFlowGraphNode", covariant=True)
46+
EdgeT_co = TypeVar("EdgeT_co", bound="MetricFlowGraphEdge", covariant=True)
4747

4848

49-
class MetricflowGraphNode(MetricflowGraphElement, MetricFlowPrettyFormattable, Comparable, ABC):
49+
class MetricFlowGraphNode(MetricFlowGraphElement, MetricFlowPrettyFormattable, Comparable, ABC):
5050
"""Base class for nodes in a directed graph."""
5151

52-
_DEFAULT_NODE_LABELS: ClassVar[OrderedSet[MetricflowGraphLabel]] = FrozenOrderedSet()
52+
_DEFAULT_NODE_LABELS: ClassVar[OrderedSet[MetricFlowGraphLabel]] = FrozenOrderedSet()
5353

5454
def as_dot_node(self, include_graphical_attributes: bool) -> DotNodeAttributeSet:
5555
"""Return this as attributes for a DOT node.
@@ -65,13 +65,13 @@ def as_dot_node(self, include_graphical_attributes: bool) -> DotNodeAttributeSet
6565

6666
@property
6767
@abstractmethod
68-
def node_descriptor(self) -> MetricflowGraphNodeDescriptor: # noqa: D102
68+
def node_descriptor(self) -> MetricFlowGraphNodeDescriptor: # noqa: D102
6969
raise NotImplementedError
7070

7171
@property
72-
def labels(self) -> OrderedSet[MetricflowGraphLabel]:
72+
def labels(self) -> OrderedSet[MetricFlowGraphLabel]:
7373
"""Return the labels that can be used for lookups to get this node."""
74-
return MetricflowGraphNode._DEFAULT_NODE_LABELS
74+
return MetricFlowGraphNode._DEFAULT_NODE_LABELS
7575

7676
@override
7777
def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
@@ -89,13 +89,13 @@ def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
8989

9090

9191
@fast_frozen_dataclass(order=False)
92-
class MetricflowGraphEdge(MetricflowGraphElement, MetricFlowPrettyFormattable, Comparable, Generic[NodeT_co], ABC):
92+
class MetricFlowGraphEdge(MetricFlowGraphElement, MetricFlowPrettyFormattable, Comparable, Generic[NodeT_co], ABC):
9393
"""Base class for edges in a directed graph.
9494
9595
An edge can be visualized as an arrow that points from the tail node to the head node.
9696
"""
9797

98-
_DEFAULT_EDGE_LABELS: ClassVar[OrderedSet[MetricflowGraphLabel]] = FrozenOrderedSet()
98+
_DEFAULT_EDGE_LABELS: ClassVar[OrderedSet[MetricFlowGraphLabel]] = FrozenOrderedSet()
9999

100100
tail_node: NodeT_co
101101
head_node: NodeT_co
@@ -125,9 +125,9 @@ def as_dot_edge(self, include_graphical_attributes: bool) -> DotEdgeAttributeSet
125125
)
126126

127127
@property
128-
def labels(self) -> OrderedSet[MetricflowGraphLabel]:
128+
def labels(self) -> OrderedSet[MetricFlowGraphLabel]:
129129
"""Return the labels that can be used for lookups to get this edge."""
130-
return MetricflowGraphEdge._DEFAULT_EDGE_LABELS
130+
return MetricFlowGraphEdge._DEFAULT_EDGE_LABELS
131131

132132
@override
133133
def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
@@ -144,15 +144,15 @@ def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
144144
)
145145

146146
@cached_property
147-
def labels_for_path_addition(self) -> OrderedSet[MetricflowGraphLabel]:
147+
def labels_for_path_addition(self) -> OrderedSet[MetricFlowGraphLabel]:
148148
"""Return the labels for this edge and the head node.
149149
150150
This is useful for collecting labels while building a path by adding an edge.
151151
"""
152152
return self.labels.union(self.head_node.labels)
153153

154154

155-
class MetricflowGraph(MetricFlowPrettyFormattable, Generic[NodeT_co, EdgeT_co], ABC):
155+
class MetricFlowGraph(MetricFlowPrettyFormattable, Generic[NodeT_co, EdgeT_co], ABC):
156156
"""Base class for a directed graph."""
157157

158158
@property
@@ -162,11 +162,11 @@ def nodes(self) -> OrderedSet[NodeT_co]:
162162
raise NotImplementedError()
163163

164164
@abstractmethod
165-
def nodes_with_labels(self, *graph_labels: MetricflowGraphLabel) -> OrderedSet[NodeT_co]:
165+
def nodes_with_labels(self, *graph_labels: MetricFlowGraphLabel) -> OrderedSet[NodeT_co]:
166166
"""Return nodes in the graph with any one of the given labels."""
167167
raise NotImplementedError()
168168

169-
def node_with_label(self, label: MetricflowGraphLabel) -> NodeT_co:
169+
def node_with_label(self, label: MetricFlowGraphLabel) -> NodeT_co:
170170
"""Finds the node with the given label. If not exactly one if found, an error is raised."""
171171
nodes = self.nodes_with_labels(label)
172172
matching_node_count = len(nodes)
@@ -187,34 +187,34 @@ def edges(self) -> OrderedSet[EdgeT_co]:
187187
raise NotImplementedError()
188188

189189
@abstractmethod
190-
def edges_with_tail_node(self, tail_node: MetricflowGraphNode) -> OrderedSet[EdgeT_co]:
190+
def edges_with_tail_node(self, tail_node: MetricFlowGraphNode) -> OrderedSet[EdgeT_co]:
191191
"""Returns edges with the given tail node."""
192192
raise NotImplementedError()
193193

194194
@abstractmethod
195-
def edges_with_head_node(self, tail_node: MetricflowGraphNode) -> OrderedSet[EdgeT_co]:
195+
def edges_with_head_node(self, tail_node: MetricFlowGraphNode) -> OrderedSet[EdgeT_co]:
196196
"""Returns edges with the given head node."""
197197
raise NotImplementedError()
198198

199199
@abstractmethod
200-
def edges_with_label(self, label: MetricflowGraphLabel) -> OrderedSet[EdgeT_co]:
200+
def edges_with_label(self, label: MetricFlowGraphLabel) -> OrderedSet[EdgeT_co]:
201201
"""Return the set of edges in a graph that have the given label."""
202202
raise NotImplementedError()
203203

204-
def format(self, formatter: MetricflowGraphFormatter = PrettyFormatGraphFormatter()) -> str:
204+
def format(self, formatter: MetricFlowGraphFormatter = PrettyFormatGraphFormatter()) -> str:
205205
"""Return a representation of this graph using the given formatter."""
206206
return formatter.format_graph(self)
207207

208208
@abstractmethod
209-
def successors(self, node: MetricflowGraphNode) -> OrderedSet[NodeT_co]:
209+
def successors(self, node: MetricFlowGraphNode) -> OrderedSet[NodeT_co]:
210210
"""Returns successors of the given node.
211211
212212
Raises `UnknownNodeException` if the node does not exist in the graph.
213213
"""
214214
return FrozenOrderedSet(edge.head_node for edge in self.edges_with_tail_node(node))
215215

216216
@abstractmethod
217-
def predecessors(self, node: MetricflowGraphNode) -> OrderedSet[NodeT_co]:
217+
def predecessors(self, node: MetricFlowGraphNode) -> OrderedSet[NodeT_co]:
218218
"""Returns predecessors of the given node.
219219
220220
Raises `UnknownNodeException` if the node does not exist in the graph.
@@ -233,7 +233,7 @@ def as_sorted(self) -> Self:
233233
"""Return a copy of this graph with the nodes and edges sorted."""
234234
raise NotImplementedError
235235

236-
def _intersect_edges(self, other: MetricflowGraph[NodeT_co, EdgeT_co]) -> OrderedSet[EdgeT_co]:
236+
def _intersect_edges(self, other: MetricFlowGraph[NodeT_co, EdgeT_co]) -> OrderedSet[EdgeT_co]:
237237
return self.edges.intersection(other.edges)
238238

239239
@abstractmethod
@@ -267,7 +267,7 @@ def as_dot_graph(self, include_graphical_attributes: bool) -> DotGraphAttributeS
267267

268268
@property
269269
@abstractmethod
270-
def graph_id(self) -> MetricflowGraphId:
270+
def graph_id(self) -> MetricFlowGraphId:
271271
"""Return a graph ID.
272272
273273
This ID will be used for caching cases.

0 commit comments

Comments
 (0)