Skip to content

Commit 6990cbf

Browse files
committed
added groups in timeline
added interactivity
1 parent 09b3bd1 commit 6990cbf

13 files changed

+187
-65
lines changed

cache/assets/dependencies.dot

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
digraph G {
2-
A [label="fetch-data-1", class="job", shape="box"];
3-
B [label="content", class="artifact", shape="ellipse"];
4-
C [label="calculate-functions", class="job", shape="box"];
5-
D [label="stats", class="artifact", shape="ellipse"];
6-
E [label="compute-statistics", class="job", shape="box"];
7-
F [label="result", class="artifact", shape="ellipse"];
8-
G [label="generate-website", class="job", shape="box"];
9-
H [label="website", class="artifact", shape="ellipse"];
2+
A [id="fetch-data-1", label="fetch-data-1", class="job", shape="box"];
3+
B [id="content", label="content", class="artifact", shape="ellipse"];
4+
C [id="calculate-functions", label="calculate-functions", class="job", shape="box"];
5+
D [id="stats", label="stats", class="artifact", shape="ellipse"];
6+
E [id="compute-statistics", label="compute-statistics", class="job", shape="box"];
7+
F [id="result", label="result", class="artifact", shape="ellipse"];
8+
G [id="generate-website", label="generate-website", class="job", shape="box"];
9+
H [id="website", label="website", class="artifact", shape="ellipse"];
1010
A -> B;
1111
B -> C;
1212
C -> D;

cache/assets/dependencies.dot.svg

+8-8
Loading

cache/assets/pipeline.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22
{
33
"stage": "fetch",
44
"job": "fetch-data-1",
5-
"start": "2024-04-21 15:06:16.087712",
6-
"stop": "2024-04-21 15:06:16.188543",
7-
"duration": "0:00:00.100831",
8-
"duration_text": "100 ms"
5+
"start": "2024-04-21 17:05:48.090399",
6+
"stop": "2024-04-21 17:05:48.191794",
7+
"duration": "0:00:00.101395",
8+
"duration_text": "101 ms"
99
},
1010
{
1111
"stage": "process",
1212
"job": "calculate-functions",
13-
"start": "2024-04-21 15:06:16.188543",
14-
"stop": "2024-04-21 15:06:16.490527",
15-
"duration": "0:00:00.301984",
13+
"start": "2024-04-21 17:05:48.191794",
14+
"stop": "2024-04-21 17:05:48.493691",
15+
"duration": "0:00:00.301897",
1616
"duration_text": "301 ms"
1717
},
1818
{
1919
"stage": "process",
2020
"job": "compute-statistics",
21-
"start": "2024-04-21 15:06:16.490527",
22-
"stop": "2024-04-21 15:06:16.891631",
23-
"duration": "0:00:00.401104",
21+
"start": "2024-04-21 17:05:48.493691",
22+
"stop": "2024-04-21 17:05:48.894970",
23+
"duration": "0:00:00.401279",
2424
"duration_text": "401 ms"
2525
},
2626
{
2727
"stage": "build",
2828
"job": "generate-website",
29-
"start": "2024-04-21 15:06:16.891631",
30-
"stop": "2024-04-21 15:06:17.394657",
31-
"duration": "0:00:00.503026",
32-
"duration_text": "503 ms"
29+
"start": "2024-04-21 17:05:48.894970",
30+
"stop": "2024-04-21 17:05:49.397943",
31+
"duration": "0:00:00.502973",
32+
"duration_text": "502 ms"
3333
}
3434
]

cache/assets/timeline.json

+46-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
1-
[
2-
{
3-
"id": "fetch-data-1",
4-
"content": "fetch-data-1",
5-
"start": "2024-04-21 15:06:16.087712",
6-
"end": "2024-04-21 15:06:16.188543"
7-
},
8-
{
9-
"id": "calculate-functions",
10-
"content": "calculate-functions",
11-
"start": "2024-04-21 15:06:16.188543",
12-
"end": "2024-04-21 15:06:16.490527"
13-
},
14-
{
15-
"id": "compute-statistics",
16-
"content": "compute-statistics",
17-
"start": "2024-04-21 15:06:16.490527",
18-
"end": "2024-04-21 15:06:16.891631"
19-
},
20-
{
21-
"id": "generate-website",
22-
"content": "generate-website",
23-
"start": "2024-04-21 15:06:16.891631",
24-
"end": "2024-04-21 15:06:17.394657"
25-
}
26-
]
1+
{
2+
"items": [
3+
{
4+
"id": "fetch-data-1",
5+
"content": "fetch-data-1",
6+
"group": "fetch",
7+
"start": "2024-04-21 17:05:48.090399",
8+
"end": "2024-04-21 17:05:48.191794"
9+
},
10+
{
11+
"id": "calculate-functions",
12+
"content": "calculate-functions",
13+
"group": "process",
14+
"start": "2024-04-21 17:05:48.191794",
15+
"end": "2024-04-21 17:05:48.493691"
16+
},
17+
{
18+
"id": "compute-statistics",
19+
"content": "compute-statistics",
20+
"group": "process",
21+
"start": "2024-04-21 17:05:48.493691",
22+
"end": "2024-04-21 17:05:48.894970"
23+
},
24+
{
25+
"id": "generate-website",
26+
"content": "generate-website",
27+
"group": "build",
28+
"start": "2024-04-21 17:05:48.894970",
29+
"end": "2024-04-21 17:05:49.397943"
30+
}
31+
],
32+
"groups": [
33+
{
34+
"id": "fetch",
35+
"content": "fetch"
36+
},
37+
{
38+
"id": "process",
39+
"content": "process"
40+
},
41+
{
42+
"id": "build",
43+
"content": "build"
44+
}
45+
]
46+
}

graph_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def graph_to_dot(graph):
2222
label = node["label"]
2323
node_class = node["class"]
2424
node_shape = shapes_map[node_class]
25-
dot_string += f' {nodes_map[label]} [label="{label}", class="{node_class}", shape="{node_shape}"];\n'
25+
dot_string += f' {nodes_map[label]} [id="{label}", label="{label}", class="{node_class}", shape="{node_shape}"];\n'
2626
for edge in graph["edges"]:
2727
source = nodes_map[edge["source"]]
2828
target = nodes_map[edge["target"]]

runner.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,29 @@ def run_pipeline(pipeline):
102102

103103

104104
def generate_timeline(pipe):
105-
timeline = []
105+
items = []
106+
groups = []
107+
groups_names = [] #user to keep entries unique
106108
for item in pipe:
107-
timeline.append({
109+
if(item["stage"] not in groups_names):
110+
groups_names.append(item["stage"])
111+
groups.append({
112+
"id":item["stage"],
113+
"content":item["stage"]
114+
})
115+
items.append({
108116
"id":item["job"],
109117
"content":item["job"],
118+
"group":item["stage"],
110119
"start":item["start"],
111120
"end":item["stop"]
112121
})
122+
timeline = {
123+
"items":items,
124+
"groups":groups
125+
}
113126
return timeline
114127

128+
manifest = utl.load_yaml("manifest.yaml")
115129
if __name__ == '__main__':
116-
manifest = utl.load_yaml("manifest.yaml")
117130
run_pipeline(manifest["pipeline"])

website/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const outdir = join(cachedir,"web")
99
const base = env.PUBLIC_BASE
1010

1111
const config = {
12+
webdir,
1213
rootdir,
1314
base,
1415
cachedir,

website/src/components/SvgInline.astro

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import {load_text} from '@/libs/utils.js'
44
55
export interface Props {
66
filepath: string;
7+
folder: string;
78
}
89
9-
const { filepath } = Astro.props as Props;
10-
const innerHTML = await load_text(filepath);
10+
const { filepath, folder="cachedir" } = Astro.props as Props;
11+
const innerHTML = await load_text(filepath,folder);
1112
---
1213

1314
<Fragment set:html={innerHTML} />

website/src/components/timeline.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ async function init(){
1212
const data_file = timeline_element.dataset.file;
1313
try {
1414
const file_url = `${config.base}/artifacts/${data_file}`
15-
console.log(`fetching ${file_url}`)
15+
//console.log(`fetching ${file_url}`)
1616
const response = await fetch(file_url);
1717
const data_timeline = await response.json(); // Assuming the response needs to be converted to JSON
18-
new Timeline(timeline_element, data_timeline, {})
18+
new Timeline(timeline_element, data_timeline.items,data_timeline.groups,{})
1919
} catch (error) {
2020
console.error('Failed to fetch data:', error);
2121
}

website/src/icons/github.svg

+11
Loading

website/src/libs/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ async function load_json(path,folder="cachedir"){
1919
}
2020

2121
async function load_text(path,folder="cachedir"){
22-
return await readFile(join(config[folder],path));
22+
if(folder == "icons"){
23+
return await readFile(join(config.webdir,"src/icons",path));
24+
}else{
25+
return await readFile(join(config[folder],path));
26+
}
2327
}
2428

2529
export{

website/src/pages/artifacts.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
document.addEventListener('DOMContentLoaded', () => {
3+
const artifacts = document.querySelectorAll('g.artifact');
4+
5+
artifacts.forEach(artifact => {
6+
artifact.style.cursor = 'pointer'; // Make cursor a pointer to indicate clickable
7+
artifact.addEventListener('click', function() {
8+
const id = this.id;
9+
fetch(`/artifacts/${id}`)
10+
.then(response => response.blob()) // Get the file as a blob
11+
.then(blob => {
12+
const url = window.URL.createObjectURL(blob);
13+
const a = document.createElement('a');
14+
a.href = url;
15+
a.download = `${id}.json`; // Set the default filename for the download
16+
document.body.appendChild(a);
17+
a.click();
18+
document.body.removeChild(a);
19+
window.URL.revokeObjectURL(url);
20+
})
21+
.catch(error => console.error('Error downloading the file:', error));
22+
});
23+
});
24+
});

0 commit comments

Comments
 (0)