-
Notifications
You must be signed in to change notification settings - Fork 309
/
check_resources.py
57 lines (46 loc) · 1.67 KB
/
check_resources.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# %% Imports
import logging
from pathlib import Path
import pandas as pd
from kakarot_scripts.artifacts import get_artifacts
pd.set_option("display.max_rows", 500)
pd.set_option("display.max_columns", 10)
pd.set_option("display.width", 1000)
pd.set_option("max_colwidth", 400)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# %% Main
def main():
# %% Script constants
artifact_name = Path("resources")
base_branch_name = "main"
current_name = "local"
artifacts = get_artifacts(artifact_name, base_branch_name)
# %% Build aggregated stat for checking resources evolution
resources = []
for artifact in artifacts.to_dict("records"):
file_path = next(
(artifact_name / artifact["head_branch"]).glob("resources*.csv")
)
resources.append(
pd.read_csv(file_path).assign(head_branch=artifact["head_branch"])
)
local_artifact = list(artifact_name.glob("resources*.csv"))
if local_artifact:
resources.append(
pd.read_csv(local_artifact[0]).assign(head_branch=current_name)
)
else:
logger.info("No local resources found to compare against")
all_resources = (
# There shouldn't be any duplicated, but rn we only have the test name, so
# to avoid any confusion we just drop them
pd.concat(resources)
.drop_duplicates(["head_branch", "test"], keep=False)
.set_index(["head_branch", "test"])
)
average_summary = all_resources.groupby(level="head_branch").agg("mean").round(2)
logger.info(f"### Resources summary\n\n{average_summary.to_markdown()}")
# %% Run
if __name__ == "__main__":
main()