Skip to content
Snippets Groups Projects
Commit ec4f75e4 authored by s2870355's avatar s2870355
Browse files

embed part into graph

parent 598f4d22
No related branches found
No related tags found
No related merge requests found
Pipeline #76747 canceled
......@@ -149,13 +149,58 @@ def get_stages(compile_info : list[job_data]) -> list[str]:
stages.append(i.stage)
return sorted(stages)
def create_dot(compile_info : list[job_data]) -> None:
output = "digraph G {rankdir=\"LR\"\n"
def add_to_dict(job_data, xdict) -> None:
location = job_data.location
parts = location.split('/')
current_dict = xdict
for part in parts[0:-1]:
if part not in current_dict:
current_dict[part] = {}
current_dict = current_dict[part]
current_dict[parts[-1]] = job_data
def list_to_dict(compile_info : list[job_data]) -> dict:
output = {}
for j in compile_info:
output = output + "\t" + j.location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + "[label=\"" + j.location.replace('\\', '\\\\') + "\"]" ";\n"
for d in j.depends:
output = output + "\t\t" + d.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + " -> " + j.location.replace(os.sep, "_").replace("-", "_").replace(".", "_") + ";\n"
return output + "}"
add_to_dict(j, output)
return output
def dict_to_nodes(dictionary) -> str:
if isinstance(dictionary, dict):
output_str = ""
for k in dictionary.keys():
if isinstance(dictionary[k], dict):
output_str += "\n\tsubgraph cluster_" + k + "{" + "\n\t\tlabel=\"" + k + "\""
output_str += dict_to_nodes(dictionary[k]).replace('\n', "\n\t")
output_str += "\n\t}"
else:
output_str += "\n\t" + dictionary[k].location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + "[label=\"" + dictionary[k].location.split('/')[-1] + "\"];"
return output_str
return ""
def dict_to_edges(dictionary) -> str:
if isinstance(dictionary, dict):
output = ""
for k in dictionary.keys():
output += dict_to_edges(dictionary[k])
return output
if isinstance(dictionary, job_data):
job = dictionary
location = job.location
depends = job.depends
output_str = ""
for depend in depends:
d_location = depend
output_str += "\t" + d_location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + " -> " + location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + ";\n"
return output_str
def create_dot(compile_info : list[job_data]) -> None:
dictionary = list_to_dict(compile_info)
output = "digraph G {rankdir=\"LR\""
output += dict_to_nodes(dictionary)
output += dict_to_edges(dictionary)
output += "}"
return output
def generate_ci(compile_info : list[job_data]) -> str:
output = ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment