From 75c2ce0991dabccfaad5b6f1d72175566ce75467 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 11 Sep 2022 08:17:46 +0200 Subject: [PATCH] Improve platform parsing --- esds/helpers/platform.py | 17 ++++++++++++++++- example/platform.yaml | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py index 7d16756..7112ebc 100644 --- a/esds/helpers/platform.py +++ b/esds/helpers/platform.py @@ -47,6 +47,8 @@ class YAMLPlatformFile: self.default={ "breakpoints": [], "breakpoints_every": None, + "breakpoints_file": None, + "breakpoints_callback": None, "debug": False, "interferences": True, "node_count": 0, @@ -71,7 +73,9 @@ class YAMLPlatformFile: else: self.parsing_error("platform file has no interfaces section") - print(self.default) + ##### Sanity checks + if None in self.default["implementations"]: + self.parsing_error("Some nodes do not have assigned implementation") def parsing_error(self,msg): raise Exception("Fail to parse platform file \""+self.file_path+"\": "+msg) @@ -162,6 +166,17 @@ class YAMLPlatformFile: if not str(general["breakpoints_every"]).isnumeric(): self.parsing_error("breakpoints_every should be a number") self.default["breakpoints_every"]=general["breakpoints_every"] + if "breakpoints_callback" in general: + cb=general["breakpoints_callback"] + file=cb["file"] + path, ext=os.path.splitext(file) + if not os.path.exists(file): + self.parsing_error("File "+file+ " not found") + path, extension = os.path.splitext(file) + if extension != ".py": + self.parsing_error("File "+file+" must be a python file") + self.default["breakpoints_file"]=cb["file"] + self.default["breakpoints_callback"]=cb["callback"] if "debug" in general: if type(general["debug"]) != bool: self.parsing_error("debug should be on or off") diff --git a/example/platform.yaml b/example/platform.yaml index 0f6134e..5aa65e3 100644 --- a/example/platform.yaml +++ b/example/platform.yaml @@ -1,9 +1,13 @@ general: breakpoints: [] breakpoints_every: 0 + breakpoints_callback: + file: "platform_test.py" + callback: "callback" debug: off interferences: on + nodes: count: 5 implementations: