-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add vesuvio rules and extracts * Add tests for the Vesuvio rules * Formatting and linting commit --------- Co-authored-by: github-actions <[email protected]>
- Loading branch information
Showing
7 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Vesuvio Rules | ||
""" | ||
|
||
import logging | ||
|
||
from rundetection.job_requests import JobRequest | ||
from rundetection.rules.rule import Rule | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class VesuvioEmptyRunsRule(Rule[str]): | ||
""" | ||
Adds the empty runs numbers to JobRequest | ||
""" | ||
|
||
def verify(self, job_request: JobRequest) -> None: | ||
job_request.additional_values["empty_runs"] = self._value | ||
|
||
|
||
class VesuvioIPFileRule(Rule[str]): | ||
""" | ||
Adds the ip_file to JobRequest | ||
""" | ||
|
||
def verify(self, job_request: JobRequest) -> None: | ||
job_request.additional_values["ip_file"] = self._value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
Test for vesuvio rules | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from rundetection.ingestion.ingest import JobRequest | ||
from rundetection.rules.vesuvio_rules import VesuvioEmptyRunsRule, VesuvioIPFileRule | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def _working_directory_fix(): | ||
# Set dir to repo root for purposes of the test. | ||
current_working_directory = Path.cwd() | ||
if current_working_directory.name == "rules": | ||
os.chdir(current_working_directory / ".." / "..") | ||
|
||
|
||
@pytest.fixture | ||
def job_request(): | ||
""" | ||
job request fixture | ||
:return: job request | ||
""" | ||
return JobRequest( | ||
run_number=100, | ||
filepath=Path("/archive/100/VESUVIO100.nxs"), | ||
experiment_title="Test experiment", | ||
additional_values={}, | ||
additional_requests=[], | ||
raw_frames=3, | ||
good_frames=0, | ||
users="", | ||
run_start="", | ||
run_end="", | ||
instrument="vesuvio", | ||
experiment_number="", | ||
) | ||
|
||
|
||
def test_vesuvio_empty_runs_rule(job_request): | ||
""" | ||
Test empty runs are set and attached to additional values | ||
:param job_request: job request fixture | ||
:return: none | ||
""" | ||
rule = VesuvioEmptyRunsRule("123-132") | ||
rule.verify(job_request) | ||
|
||
assert job_request.additional_values["empty_runs"] == "123-132" | ||
|
||
|
||
def test_vesuvio_ip_file_rule(job_request): | ||
""" | ||
Test that the IP file is set via the specification | ||
:param job_request: JobRequest fixture | ||
:return: None | ||
""" | ||
rule = VesuvioIPFileRule("IP0001.par") | ||
rule.verify(job_request) | ||
|
||
assert job_request.additional_values["ip_file"] == "IP0001.par" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"enabled": false | ||
"enabled": true, | ||
"vesuvioipfilerule": "IP0005.par", | ||
"vesuviovemptyrunsrule": "50309-50341" | ||
} |