File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
src/orca/services/synapse Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,18 @@ def fs(self) -> SynapseFS:
4242 raise ConfigError (message )
4343
4444 return SynapseFS (auth_token = auth_token )
45+
46+ def monitor_evaluation_queue (self , evaluation_id : str ) -> bool :
47+ """Monitor an evaluation queue in Synapse.
48+
49+ Args:
50+ evaluation_id: The Synapse ID of the queue to monitor.
51+
52+ Returns:
53+ True if there are "RECEIVED" submissions, False otherwise.
54+ """
55+ received_submissions = self .client .getSubmissionBundles (
56+ evaluation_id , status = "RECEIVED"
57+ )
58+ submissions_num = sum (1 for submission in received_submissions )
59+ return submissions_num > 0
Original file line number Diff line number Diff line change 11import pytest
22
3+ from orca .services .synapse import SynapseClientFactory , SynapseConfig , SynapseOps
4+
35
46@pytest .fixture
57def syn_project_id ():
68 yield "syn51469029"
9+
10+
11+ @pytest .fixture
12+ def config (patch_os_environ ):
13+ yield SynapseConfig ("foo" )
14+
15+
16+ @pytest .fixture
17+ def client (config ):
18+ factory = SynapseClientFactory (config = config )
19+ yield factory .create_client ()
20+
21+
22+ @pytest .fixture
23+ def mocked_ops (config , client , mocker ):
24+ mocker .patch .object (SynapseOps , "client" , return_value = client )
25+ yield SynapseOps (config )
26+
27+
28+ @pytest .fixture
29+ def ops (config ):
30+ yield SynapseOps (config )
Original file line number Diff line number Diff line change @@ -10,3 +10,27 @@ def test_for_an_error_when_accessing_fs_without_credentials(
1010 ops = SynapseOps ()
1111 with pytest .raises (ConfigError ):
1212 ops .fs .listdir (syn_project_id )
13+
14+
15+ def test_monitor_evaluation_queue_returns_false_when_there_are_no_new_submissions (
16+ mocker , mocked_ops
17+ ):
18+ mock = mocker .patch .object (
19+ mocked_ops .client , "getSubmissionBundles" , return_value = []
20+ )
21+ result = mocked_ops .monitor_evaluation_queue ("foo" )
22+ mock .assert_called_once_with ("foo" , status = "RECEIVED" )
23+ assert result is False
24+
25+
26+ def test_monitor_evaluation_queue_returns_true_when_there_are_new_submissions (
27+ mocker , mocked_ops
28+ ):
29+ mock = mocker .patch .object (
30+ mocked_ops .client ,
31+ "getSubmissionBundles" ,
32+ return_value = ["submission_1" , "submission_2" ],
33+ )
34+ result = mocked_ops .monitor_evaluation_queue ("foo" )
35+ mock .assert_called_once_with ("foo" , status = "RECEIVED" )
36+ assert result
You can’t perform that action at this time.
0 commit comments