diff --git a/orchestrator/activities/temporal_manager.py b/orchestrator/activities/temporal_manager.py index 71bf7e6..a6ecc64 100644 --- a/orchestrator/activities/temporal_manager.py +++ b/orchestrator/activities/temporal_manager.py @@ -209,7 +209,10 @@ class TemporalManager(BaseActivity): ScheduleIntervalSpec( every=timedelta( seconds=parse_frequency(schedule.get('frequency', '1m')) - ) + ), + offset=timedelta( + seconds=parse_frequency(schedule.get('offset', '0m')) + ), ) ] ), diff --git a/orchestrator/utils/orchestrator_functions.py b/orchestrator/utils/orchestrator_functions.py index c6e5cc0..505d079 100644 --- a/orchestrator/utils/orchestrator_functions.py +++ b/orchestrator/utils/orchestrator_functions.py @@ -22,6 +22,7 @@ def common_config(config: dict[str, Any]): 'workflow_type': config['workflow_type'], 'schedule_name': config['schedule_name'], 'frequency': config.get('frequency', '1m'), + 'offset': config.get('offset', '0m'), 'max_retry_policy': config.get('max_retry_policy', 1), 'model_id': config['model_id'], 'model_name': model['name'], diff --git a/requirements.txt b/requirements.txt index 0ae2245..7668196 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ redis couchbase pymongo jinja2 -git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.6 +git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.7 prometheus-client diff --git a/tests/orchestrator/activities/test_temporal_manager.py b/tests/orchestrator/activities/test_temporal_manager.py index 89ee56b..d8af937 100644 --- a/tests/orchestrator/activities/test_temporal_manager.py +++ b/tests/orchestrator/activities/test_temporal_manager.py @@ -148,6 +148,7 @@ async def test_create_schedule( 'model_name': 'test-model-name', 'workflow_type': 'test-workflow', 'frequency': '10y', + 'offset': '5m', 'data': {'test': 'test'}, 'execution_timeout_seconds': 400, 'task_timeout_seconds': 400, @@ -159,6 +160,7 @@ async def test_create_schedule( 'model_name': 'test-model-name', 'workflow_type': 'test-workflow', 'frequency': '2m', + 'offset': '1h', 'data': {'test': 'test'}, 'execution_timeout_seconds': 500, 'task_timeout_seconds': 500, @@ -239,10 +241,15 @@ async def test_create_schedule( ) mock_schedule_interval_spec.assert_has_calls( - [call(every=timedelta(seconds=60)), call(every=timedelta(seconds=120))] + [ + call(every=timedelta(seconds=60), offset=timedelta(seconds=0)), + call(every=timedelta(seconds=120), offset=timedelta(seconds=3600)), + ] ) - mock_parse_frequency.assert_has_calls([call('1m'), call('10y'), call('2m')]) + mock_parse_frequency.assert_has_calls( + [call('1m'), call('0m'), call('10y'), call('2m'), call('1h')] + ) mock_typed_search_attributes.assert_has_calls( [ diff --git a/tests/orchestrator/utils/test_orchestrator_functions.py b/tests/orchestrator/utils/test_orchestrator_functions.py index 7e35124..ee91a1f 100644 --- a/tests/orchestrator/utils/test_orchestrator_functions.py +++ b/tests/orchestrator/utils/test_orchestrator_functions.py @@ -24,6 +24,7 @@ def test_common_config(): 'workflow_type': 'scouter', 'schedule_name': 'test_schedule', 'frequency': '1m', + 'offset': '0m', 'max_retry_policy': 1, 'model_id': 'test_model_id', 'model_name': 'test_model_name', @@ -48,6 +49,7 @@ def test_minimal_retrain(): 'workflow_type': 'minimal_retrain', 'schedule_name': 'test_schedule', 'frequency': '1m', + 'offset': '0m', 'max_retry_policy': 1, 'model_id': 'test_model_id', 'model_name': 'test_model_name', @@ -81,6 +83,7 @@ def test_scouter(): 'workflow_type': 'scouter', 'schedule_name': 'test_schedule', 'frequency': '1m', + 'offset': '0m', 'max_retry_policy': 1, 'model_id': 'test_model_id', 'model_name': 'test_model_name', @@ -163,6 +166,7 @@ def test_predictions_batch(mock_process_path_priority, mock_overlap_filter_confi 'workflow_type': 'predictions_batch', 'schedule_name': 'test_schedule', 'frequency': '1m', + 'offset': '0m', 'max_retry_policy': 1, 'model_id': 'test_model_id', 'model_name': 'test_model_name', @@ -275,7 +279,7 @@ def test_build_tag_config(): def test_build_tag_config_no_server_id(): tag = {'server_id': '1', 'tag_address': 'test_tag_address'} - opc_servers = {} + opc_servers: dict = {} try: build_tag_config(tag, {}, opc_servers, 1)