Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 0af3bf2

Browse files
committed
df: types: Add update method to DataFlow
Signed-off-by: John Andersen <[email protected]>
1 parent 9e58307 commit 0af3bf2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

dffml/df/types.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,16 @@ def __init__(
448448
self.implementations = {}
449449
self.validators = {} # Maps `validator` ops instance_name to op
450450

451+
self.update(auto_flow=bool(self.flow is None))
452+
453+
def update(self, auto_flow: bool = False):
454+
self.update_operations()
455+
self.update_definitions()
456+
if auto_flow:
457+
self.flow = self.auto_flow()
458+
self.update_by_origin()
459+
460+
def update_operations(self):
451461
# Allow callers to pass in functions decorated with op. Iterate over the
452462
# given operations and replace any which have been decorated with their
453463
# operation. Add the implementation to our dict of implementations.
@@ -479,6 +489,8 @@ def __init__(
479489
self.operations[instance_name] = value
480490
if value.validator:
481491
self.validators[instance_name] = value
492+
493+
def update_definitions(self):
482494
# Grab all definitions from operations
483495
operations = list(self.operations.values())
484496
definitions = list(
@@ -499,10 +511,6 @@ def __init__(
499511
definition.name: definition for definition in definitions
500512
}
501513
self.definitions = definitions
502-
# Determine the dataflow if not given
503-
if self.flow is None:
504-
self.flow = self.auto_flow()
505-
self.update_by_origin()
506514

507515
def update_by_origin(self):
508516
# Create by_origin which maps operation instance names to the sources
@@ -601,6 +609,7 @@ def auto(cls, *operations):
601609
)
602610

603611
def auto_flow(self):
612+
# Determine the dataflow if not given
604613
flow_dict = {}
605614
# Create output_dict, which maps all of the definitions to the
606615
# operations that create them.

0 commit comments

Comments
 (0)