uncledecart commited on
Commit
0687447
·
verified ·
1 Parent(s): 63e54c7

Delete dataset.py

Browse files
Files changed (1) hide show
  1. dataset.py +0 -94
dataset.py DELETED
@@ -1,94 +0,0 @@
1
- import os
2
- import csv
3
- import json
4
- import datasets
5
-
6
- EXPERIMENTS = {
7
- "test1": "05-19-35",
8
- "test2": "06-38-03",
9
- "test3": "15-12-05",
10
- "test4": "10-49-18",
11
- "test5": "11-04-24",
12
- }
13
-
14
- FILETYPES = [
15
- "output",
16
- "cpu_monitor",
17
- "cpustat_monitor",
18
- "irq_monitor",
19
- "softirq_monitor",
20
- "meminfo_monitor",
21
- "sysinfo",
22
- ]
23
-
24
-
25
- class MonitoringConfig(datasets.BuilderConfig):
26
- def __init__(self, filetype, **kwargs):
27
- super().__init__(version=datasets.Version("1.0.0"), **kwargs)
28
- self.filetype = filetype
29
-
30
-
31
- class MonitoringDataset(datasets.GeneratorBasedBuilder):
32
-
33
- BUILDER_CONFIGS = [
34
- MonitoringConfig(
35
- name=filetype,
36
- filetype=filetype,
37
- description=f"{filetype} across all experiments"
38
- )
39
- for filetype in FILETYPES
40
- ]
41
-
42
- def _info(self):
43
- filetype = self.config.filetype
44
-
45
- # JSON sysinfo
46
- if filetype == "sysinfo":
47
- return datasets.DatasetInfo(
48
- features=datasets.Features({"json": datasets.Value("string")})
49
- )
50
-
51
- # For optional output.csv, detect header only if a sample exists
52
- for folder in EXPERIMENTS.values():
53
- path = os.path.join(folder, f"{filetype}.csv")
54
- if os.path.exists(path):
55
- with open(path, "r") as f:
56
- header = next(csv.reader(f))
57
- return datasets.DatasetInfo(
58
- features=datasets.Features({col: datasets.Value("string") for col in header})
59
- )
60
-
61
- # No experiment contains this filetype → return empty schema
62
- return datasets.DatasetInfo(
63
- features=datasets.Features({})
64
- )
65
-
66
- def _split_generators(self, dl_manager):
67
- return [
68
- datasets.SplitGenerator(
69
- name=exp_name,
70
- gen_kwargs={"folder": folder, "filetype": self.config.filetype}
71
- )
72
- for exp_name, folder in EXPERIMENTS.items()
73
- ]
74
-
75
- def _generate_examples(self, folder, filetype):
76
-
77
- # JSON
78
- if filetype == "sysinfo":
79
- json_path = os.path.join(folder, "sysinfo.json")
80
- if not os.path.exists(json_path):
81
- return
82
- with open(json_path, "r") as f:
83
- data = json.load(f)
84
- yield 0, {"json": json.dumps(data)}
85
- return
86
-
87
- path = os.path.join(folder, f"{filetype}.csv")
88
- if not os.path.exists(path):
89
- return # gracefully skip this experiment
90
-
91
- with open(path, "r") as f:
92
- reader = csv.DictReader(f)
93
- for idx, row in enumerate(reader):
94
- yield idx, row