File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 2
2
Example script showing how one might setup a generic model training pipeline that is quickly configurable.
3
3
"""
4
4
5
+ import importlib
6
+
5
7
# Required import to register adapters
6
8
import data_loaders
7
9
import model_training
8
10
9
11
from hamilton import base , driver
10
12
from hamilton .io .materialization import to
11
13
14
+ importlib .import_module ("custom_materializers" )
15
+
12
16
13
17
def get_model_config (model_type : str ) -> dict :
14
18
"""Returns model type specific configuration"""
@@ -71,5 +75,5 @@ def get_model_config(model_type: str) -> dict:
71
75
* materializers ,
72
76
additional_vars = ["classification_report" ],
73
77
)
74
- print (materialization_results ["classification_report" ])
75
- print (additional_vars )
78
+ # print(materialization_results["classification_report"])
79
+ # print(additional_vars)
Original file line number Diff line number Diff line change @@ -997,9 +997,9 @@ def materialize(
997
997
def visualize_materialization (
998
998
self ,
999
999
* materializers : materialization .MaterializerFactory ,
1000
- additional_vars : List [Union [str , Callable , Variable ]],
1001
1000
output_file_path : str ,
1002
1001
render_kwargs : dict ,
1002
+ additional_vars : List [Union [str , Callable , Variable ]] = None ,
1003
1003
inputs : Dict [str , Any ] = None ,
1004
1004
graphviz_kwargs : dict = None ,
1005
1005
) -> Optional ["graphviz.Digraph" ]: # noqa F821
@@ -1014,11 +1014,13 @@ def visualize_materialization(
1014
1014
:param graphviz_kwargs: Arguments to pass to graphviz
1015
1015
:return: The graphviz graph, if you want to do something with it
1016
1016
"""
1017
+ if additional_vars is None :
1018
+ additional_vars = []
1017
1019
function_graph = materialization .modify_graph (self .graph , materializers )
1018
1020
_final_vars = self ._create_final_vars (additional_vars ) + [
1019
1021
materializer .id for materializer in materializers
1020
1022
]
1021
- Driver ._visualize_execution_helper (
1023
+ return Driver ._visualize_execution_helper (
1022
1024
function_graph ,
1023
1025
self .adapter ,
1024
1026
_final_vars ,
Original file line number Diff line number Diff line change @@ -63,8 +63,10 @@ def add_dependency(
63
63
required_node = node .Node (param_name , param_type , node_source = node .NodeType .EXTERNAL )
64
64
nodes [param_name ] = required_node
65
65
# add edges
66
- func_node .dependencies .append (required_node )
67
- required_node .depended_on_by .append (func_node )
66
+ if required_node not in func_node .dependencies :
67
+ func_node .dependencies .append (required_node )
68
+ if func_node not in required_node .depended_on_by :
69
+ required_node .depended_on_by .append (func_node )
68
70
69
71
70
72
def update_dependencies (
You can’t perform that action at this time.
0 commit comments