Mirrored from GitHub github.com/roostorg/osprey
0

Configure Feed

Select the types of activity you want to include in your feed.

Add GetActionId() stdlib UDF + ExecutionContext.get_action_id() (#327)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+39
+2
example_rules/models/base.sml
··· 12 12 13 13 ActionName=GetActionName() 14 14 15 + ActionId=GetActionId() 16 +
+4
osprey_worker/src/osprey/engine/executor/execution_context.py
··· 172 172 """Returns the action name that the execution context is currently being invoked upon.""" 173 173 return self._action.action_name 174 174 175 + def get_action_id(self) -> int: 176 + """Returns the action id of the event that the execution context is currently being invoked upon.""" 177 + return self._action.action_id 178 + 175 179 def get_action_time(self) -> datetime: 176 180 """Returns the time of the action that the execution context is currently being invoked upon.""" 177 181 return self._action.timestamp
+15
osprey_worker/src/osprey/engine/stdlib/udfs/get_action_id.py
··· 1 + from ._prelude import ArgumentsBase, ExecutionContext, UDFBase 2 + from .categories import UdfCategories 3 + 4 + 5 + class Arguments(ArgumentsBase): 6 + pass 7 + 8 + 9 + class GetActionId(UDFBase[Arguments, int]): 10 + """Returns the Action ID of the event being processed.""" 11 + 12 + category = UdfCategories.ENGINE 13 + 14 + def execute(self, execution_context: ExecutionContext, arguments: Arguments) -> int: 15 + return execution_context.get_action_id()
+16
osprey_worker/src/osprey/engine/stdlib/udfs/tests/test_get_action_id.py
··· 1 + import pytest 2 + from osprey.engine.ast_validator.validators.validate_call_kwargs import ValidateCallKwargs 3 + from osprey.engine.conftest import ExecuteFunction 4 + from osprey.engine.stdlib.udfs.get_action_id import GetActionId 5 + from osprey.engine.udf.registry import UDFRegistry 6 + 7 + pytestmark = [ 8 + pytest.mark.use_validators([ValidateCallKwargs]), 9 + pytest.mark.use_udf_registry(UDFRegistry.with_udfs(GetActionId)), 10 + ] 11 + 12 + 13 + def test_execute(execute: ExecuteFunction) -> None: 14 + data = execute('ActionId = GetActionId()', data={}, action_id=42) 15 + 16 + assert data == {'ActionId': 42}
+2
osprey_worker/src/osprey/worker/_stdlibplugin/udf_register.py
··· 12 12 InExperiment, 13 13 ) 14 14 from osprey.engine.stdlib.udfs.extract_cookie import ExtractCookie 15 + from osprey.engine.stdlib.udfs.get_action_id import GetActionId 15 16 from osprey.engine.stdlib.udfs.get_action_name import GetActionName 16 17 from osprey.engine.stdlib.udfs.import_ import Import 17 18 from osprey.engine.stdlib.udfs.ip_network import IpNetwork ··· 86 87 ExperimentsBucketAssignment, 87 88 InExperiment, 88 89 ExtractCookie, 90 + GetActionId, 89 91 GetActionName, 90 92 HasLabel, 91 93 Import,