66 Returns a dictionary {project_tag: {period: [runs]}}
68 retrieved from the coma database.
71 from sqlalchemy
import (select, Table, Column,
72 String, Integer, ForeignKey)
74 from re
import compile
76 LETTER_PART = compile(
r"^(\D+)")
78 from DQUtils.oracle
import make_oracle_connection
82 schema =
"ATLAS_TAGS_METADATA"
84 coma_runs = Table(
"coma_runs", metadata,
85 Column(
"run_index", Integer),
86 Column(
"run_number", Integer),
90 coma_period_definitions = Table(
"coma_period_defs", metadata,
91 Column(
"p_index", Integer),
92 Column(
"p_project_period", String),
95 project_period = coma_period_definitions.c.p_project_period
97 coma_period_p1_to_runs = Table(
"coma_period_p1_to_runs", metadata,
98 Column(
"p2r_index", Integer),
99 Column(
"p_index", Integer, ForeignKey(coma_period_definitions.c.p_index)),
100 Column(
"run_index", Integer, ForeignKey(coma_runs.c.run_index)),
103 joined = coma_period_p1_to_runs.join(coma_runs).
join(coma_period_definitions)
105 smt = (
select([project_period, coma_runs.c.run_number], from_obj=joined)
106 .order_by(coma_runs.c.run_number))
108 projectperiod_runs = smt.execute().fetchall()
111 for projectperiod, run
in projectperiod_runs:
112 project, period = projectperiod.split(
".")
113 period = period.replace(
"period",
"")
115 project_dict = mapping.setdefault(project, {})
116 period_runs = project_dict.setdefault(period, [])
117 if not period_runs
or period_runs[-1] != run:
118 period_runs.append(run)
120 period_letter = LETTER_PART.search(period)
122 (period_letter,) = period_letter.groups()
123 period_runs = project_dict.setdefault(period_letter, [])
124 if not period_runs
or period_runs[-1] != run:
125 period_runs.append(run)