Skip to content

Commit

Permalink
Gt and era history (#48)
Browse files Browse the repository at this point in the history
* Entry points with gt and era history

* Modify Era History

* Update new entry points

* Update Regexps.py to fix global tag queries

---------

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
LinaresToine and Antonio authored Sep 21, 2023
1 parent 942a892 commit bdb7edd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
5 changes: 2 additions & 3 deletions src/python/DataEraHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get(self, era):
sql_with_era = """
SELECT acq_era, MAX(run) max_run, MIN(run) min_run
FROM run_config
WHERE acq_era LIKE :acq_era
WHERE acq_era LIKE :acq_era
GROUP BY acq_era
ORDER BY max_run DESC, min_run DESC
"""
Expand All @@ -35,8 +35,7 @@ def get(self, era):


if era is not None:
acq_era = "{}%".format(era)
c, _ = self.api.execute(sql_with_era, acq_era)
c, _ = self.api.execute(sql_with_era, acq_era = '%' + str(era) + '%')
else:
c, _ = self.api.execute(sql_no_era)

Expand Down
54 changes: 22 additions & 32 deletions src/python/DataGlobalTagHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,42 @@ def get(self, express_global_tag, prompt_global_tag):
:arg str era: the acquisition era
:returns: global tags, minimum run, and maximum run"""

sql = """
SELECT express_config.global_tag gt_express, reco_config.global_tag gt_prompt, MAX(run_config.run) AS max_run, MIN(run_config.run) AS min_run
FROM run_config
JOIN express_config ON express_config.run = run_config.run
JOIN reco_config ON reco_config.run = run_config.run
"""
sql_express = """
SELECT global_tag gt_express, MAX(run) max_run, MIN(run) min_run
FROM express_config
WHERE global_tag LIKE :gt_express
GROUP BY global_tag
WHERE express_config.global_tag LIKE :gt_express
"""
sql_ = """
GROUP BY express_config.global_tag, reco_config.global_tag
ORDER BY max_run DESC, min_run DESC
"""

sql_prompt = """
SELECT global_tag gt_prompt, MAX(run) max_run, MIN(run) min_run
FROM reco_config
WHERE global_tag LIKE :gt_prompt
GROUP BY global_tag
ORDER BY max_run DESC, min_run DESC
WHERE reco_config.global_tag LIKE :gt_prompt
"""
sql_both = """
SELECT reco_config.global_tag gt_prompt, express_config.global_tag gt_express, MAX(run_config.run) AS max_run, MIN(run_config.run) AS min_run
FROM run_config
JOIN express_config ON express_config.run = run_config.run
JOIN reco_config ON reco_config.run = run_config.run
WHERE global_tag LIKE :gt_express AND global_tag LIKE :gt_prompt
GROUP BY reco_config.global_tag, express_config.global_tag
ORDER BY max_run DESC, min_run DESC
"""
sql_none = """
SELECT reco_config.global_tag gt_prompt, express_config.global_tag gt_express, MAX(run_config.run) AS max_run, MIN(run_config.run) AS min_run
FROM run_config
JOIN express_config ON express_config.run = run_config.run
JOIN reco_config ON reco_config.run = run_config.run
GROUP BY reco_config.global_tag, express_config.global_tag
ORDER BY max_run DESC, min_run DESC
WHERE reco_config.global_tag LIKE :gt_prompt AND express_config.global_tag LIKE :gt_express
"""



if express_global_tag is not None and prompt_global_tag is not None:
gt_express = '{}%'.format(express_global_tag)
gt_prompt = '{}%'.format(prompt_global_tag)
c, _ = self.api.execute(sql_both, gt_express, gt_prompt)
sq = sql + sql_both + sql_
c, _ = self.api.execute(sq, gt_express = '%' + str(express_global_tag) + '%', gt_prompt = '%' + str(prompt_global_tag) + '%')
elif express_global_tag is not None and prompt_global_tag is None:
gt_express = '{}%'.format(express_global_tag)
c, _ = self.api.execute(sql_express, gt_express)
sq = sql + sql_express + sql_
c, _ = self.api.execute(sq, gt_express = '%' + str(express_global_tag) + '%')
elif express_global_tag is None and prompt_global_tag is not None:
gt_prompt = '{}%'.format(prompt_global_tag)
c, _ = self.api.execute(sql_prompt, gt_prompt)
sq = sql + sql_prompt + sql_
c, _ = self.api.execute(sq, gt_prompt = '%' + str(prompt_global_tag) + '%')
else:
c, _ = self.api.execute(sql_none)
sq = sql + sql_
c, _ = self.api.execute(sq)


configs = []
for result in c.fetchall():
Expand Down
7 changes: 4 additions & 3 deletions src/python/Regexps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
RX_STREAM = re.compile(r"[A-Z][0-9a-zA-Z]+")
RX_PRIMARY_DATASET = re.compile(r"[A-Z][0-9a-zA-Z]+")
RX_SCENARIO = re.compile(r"[a-zA-Z][0-9a-zA-Z]+")
RX_ERA = re.compile(r"[a-zA-Z][0-9a-zA-Z]+")
RX_EXPRESS_GLOBAL_TAG = re.compile(r"[1-9][0-9a-zA-Z]+")
RX_PROMPT_GLOBAL_TAG = re.compile(r"[1-9][0-9a-zA-Z]+")
RX_ERA = re.compile(r"[0-9_a-zA-Z]+")
RX_EXPRESS_GLOBAL_TAG = re.compile(r"[0-9_a-zA-Z]+")
RX_PROMPT_GLOBAL_TAG = re.compile(r"[0-9_a-zA-Z]+")

0 comments on commit bdb7edd

Please sign in to comment.