3
3
from os .path import dirname ,splitext ,basename ,join
4
4
import state
5
5
from datetime import datetime
6
+ import graph_utils as gutl
7
+ from containers import run
6
8
7
9
class ArtifactError (Exception ):
8
10
"""Custom exception for artifact management errors."""
@@ -34,12 +36,14 @@ def set_artifact(data,filepath,type="generic"):
34
36
abs_filepath = join ("cache" ,filepath )
35
37
if (ext == ".json" ):
36
38
utl .save_json (data ,abs_filepath )
39
+ gutl .add_edge (state .job ,id )
37
40
return
38
41
39
42
def get_artifact (id ):
40
43
if (id not in state .artifacts ):
41
44
raise ArtifactError (f"Artifact with ID '{ id } ' does not exist" )
42
45
artifact = state .artifacts [id ]
46
+ gutl .add_edge (id ,state .job )
43
47
if (artifact ["ext" ] == ".json" ):
44
48
return utl .load_json (join ("cache" ,artifact ["filepath" ]))
45
49
return None
@@ -64,7 +68,9 @@ def run_pipeline(pipeline):
64
68
run_stage (stage , jobs )
65
69
utl .save_json (state .artifacts ,"cache/artifacts.json" )
66
70
utl .save_json (state .pipe ,"cache/pipeline.json" )
67
-
71
+ utl .save_json (gutl .get_graph (),"cache/dependencies.json" )
72
+ utl .save_text (gutl .get_dot_graph (),"cache/dependencies.dot" )
73
+ run .graphviz ("dependencies.dot" )
68
74
69
75
if __name__ == '__main__' :
70
76
manifest = utl .load_yaml ("manifest.yaml" )
0 commit comments