Skip to content

Commit

Permalink
Fix Loq run detection rules (#329)
Browse files Browse the repository at this point in the history
* Rush in a fix for prod

* Change test values to reflect reality
  • Loading branch information
Pasarus authored Oct 15, 2024
1 parent 12e31c9 commit 9700772
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions rundetection/ingestion/extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def loq_extract(job_request: JobRequest, dataset: Any) -> JobRequest:
:return: The updated job request
"""
job_request.additional_values["cycle_string"] = get_cycle_string_from_path(job_request.filepath)
job_request.additional_values["sample_thickness"] = dataset.get("sample").get("thickness")
job_request.additional_values["sample_geometry"] = dataset.get("sample").get("shape")
job_request.additional_values["sample_height"] = dataset.get("sample").get("height")
job_request.additional_values["sample_width"] = dataset.get("sample").get("width")
job_request.additional_values["sample_thickness"] = float(dataset.get("sample").get("thickness")[0])
job_request.additional_values["sample_geometry"] = str(dataset.get("sample").get("shape")[0]).lstrip("b").strip("'")
job_request.additional_values["sample_height"] = float(dataset.get("sample").get("height")[0])
job_request.additional_values["sample_width"] = float(dataset.get("sample").get("width")[0])

return job_request

Expand Down
9 changes: 3 additions & 6 deletions rundetection/rules/loq_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,9 @@ def create_list_of_files(job_request: JobRequest) -> list[SansFileData]:
for run_info in cycle_run_info["NXroot"]["NXentry"]:
title_contents = run_info["title"]["#text"].split("_")
run_number = run_info["run_number"]["#text"]
if len(title_contents) in {2, 3}:
file_type = title_contents[-1]
else:
job_request.will_reduce = False
logger.error(f"Run {run_info} either doesn't contain a _ or is not an expected experiment title format.")
return []
if len(title_contents) not in {2, 3}:
continue
file_type = title_contents[-1]
list_of_files.append(SansFileData(title=run_info["title"]["#text"], type=file_type, run_number=run_number))
return list_of_files

Expand Down
8 changes: 4 additions & 4 deletions test/ingestion/test_extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ def test_osiris_extract_raises_on_bad_frequencies(job_request):
def test_loq_extract(job_request):
dataset = {
"sample": {
"thickness": 1.0,
"shape": "Disc",
"height": 8.0,
"width": 8.0,
"thickness": [1.0],
"shape": ["b'Disc'"],
"height": [8.0],
"width": [8.0],
}
}
with patch("rundetection.ingestion.extracts.get_cycle_string_from_path", return_value="some string"):
Expand Down

0 comments on commit 9700772

Please sign in to comment.