diff --git a/docker/structure.sql b/docker/structure.sql index f4ee4d2ae..411c0436a 100644 --- a/docker/structure.sql +++ b/docker/structure.sql @@ -322,6 +322,23 @@ CREATE TRIGGER categories_moddatetime EXECUTE PROCEDURE moddatetime (updated_at); +CREATE TABLE micro_phases ( + id SERIAL PRIMARY KEY, + run_id uuid NOT NULL REFERENCES runs(id) ON DELETE CASCADE ON UPDATE CASCADE, + name text NOT NULL, + start_time bigint NOT NULL, + end_time bigint NOT NULL, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone +); + +CREATE INDEX "micro_phases_run_id" ON "micro_phases" USING HASH ("run_id"); +CREATE TRIGGER micro_phases_moddatetime + BEFORE UPDATE ON micro_phases + FOR EACH ROW + EXECUTE PROCEDURE moddatetime (updated_at); + + CREATE TABLE phase_stats ( id SERIAL PRIMARY KEY, run_id uuid NOT NULL REFERENCES runs(id) ON DELETE CASCADE ON UPDATE CASCADE, diff --git a/lib/scenario_runner.py b/lib/scenario_runner.py index c450100ad..1b803173b 100644 --- a/lib/scenario_runner.py +++ b/lib/scenario_runner.py @@ -1517,6 +1517,7 @@ def _run_flows(self): 'read-notes-stdout': cmd_obj.get('read-notes-stdout', False), 'ignore-errors': cmd_obj.get('ignore-errors', False), 'read-sci-stdout': cmd_obj.get('read-sci-stdout', False), + 'sub-phase-expansion-pattern': cmd_obj.get('sub-phase-expansion-pattern', None), 'detail_name': flow['container'], 'detach': cmd_obj.get('detach', False), }) @@ -1656,6 +1657,13 @@ def _read_and_cleanup_processes(self): for match in re.findall(r'^GMT_SCI_R=(\d+)$', stdout, re.MULTILINE): self._sci['R'] += int(match) + if ps.get('sub-phase-expansion-pattern', None): + print('Pattern is', ps['sub-phase-expansion-pattern']) + + for match in re.finditer(ps['sub-phase-expansion-pattern'], stdout, re.MULTILINE): + self.__phases[match['phase_name']] = {'start': int(match['start_time']), 'name': match['phase_name'], 'end': int(match['end_time']) } + DB().query("INSERT INTO micro_phases (run_id, name, start_time, end_time) VALUES (%s, %s, %s, %s)", (self._run_id, match['phase_name'], match['start_time'], match['end_time'])) + if stderr is not None: print('stderr from process:', ps['cmd'], stderr) self._add_to_current_run_log(f"{ps['container_name']} (ID: {id(ps['ps'])}; CMD: {ps['cmd']}); STDERR", stderr) diff --git a/lib/schema_checker.py b/lib/schema_checker.py index 599658589..45e94c9e4 100644 --- a/lib/schema_checker.py +++ b/lib/schema_checker.py @@ -187,6 +187,7 @@ def check_usage_scenario(self, usage_scenario): Optional("shell"): And(str, Use(self.not_empty)), Optional("log-stdout"): bool, Optional("log-stderr"): bool, + Optional("sub-phase-expansion-pattern"): And(str, Use(self.not_empty)), }], }],