Closed gmarabout closed 11 months ago
current status: ✅
Overall Coverage
Lines Covered Coverage Threshold Status 8716 8256 95% 85% 🟢 New Files
No new covered files...
Modified Files
File Coverage Status src/taipy/core/_entity/_entity.py 100% 🟢 src/taipy/core/_entity/_properties.py 100% 🟢 src/taipy/core/_entity/_reload.py 98% 🟢 src/taipy/core/_manager/_manager.py 99% 🟢 src/taipy/core/cycle/_cycle_manager.py 100% 🟢 src/taipy/core/cycle/cycle.py 98% 🟢 src/taipy/core/data/_data_manager.py 98% 🟢 src/taipy/core/data/data_node.py 99% 🟢 src/taipy/core/job/_job_manager.py 100% 🟢 src/taipy/core/job/job.py 98% 🟢 src/taipy/core/notification/init.py 100% 🟢 src/taipy/core/notification/event.py 98% 🟢 src/taipy/core/notification/notifier.py 100% 🟢 src/taipy/core/scenario/_scenario_manager.py 96% 🟢 src/taipy/core/scenario/scenario.py 94% 🟢 src/taipy/core/sequence/_sequence_manager.py 94% 🟢 src/taipy/core/sequence/sequence.py 98% 🟢 src/taipy/core/submission/_submission_manager.py 100% 🟢 src/taipy/core/submission/submission.py 95% 🟢 src/taipy/core/task/_task_manager.py 96% 🟢 src/taipy/core/task/task.py 94% 🟢 TOTAL 98% 🟢 updated for commit:
ecf2f99
by action🐍
Goals
We would like to add additional data to core events so we can use it for telemetry. The data we want to add are: the
config_id
of the entity (will eventually be sent as an attribute), the possibility to add extra data, especially for job events (like duration/latency).What the PR solves
We will need to create events with different (meta)data depending on the entity type. The problem is that the method
_publish_event
takes a bunch of data that the callers must provide in a non-generic way. It means that if we add one field to an event, then we have to change it everywhere_publish_event
is used. Moreover, the method being static, it is difficult for the dynamic_Reloader
and_Properties
classes to have a generic code.The biggest change in this PR is the attempt to make a central piece where the logic of creating an event is delegated to a
_make_event
function which is "overridden" per entity type using the built-in Pythonsingledispatch
mechanism. This function could eventually totally replace the static_publish_event
.For now, the
_publish_event
is still there for few cases.Changes
Event
is now a frozen dataclassEvent.attribute_value
to contain the value of a changed attributeEvent.metadata
, a dict to contain any extra information we would like to transmit via the event (ex:task_config_id
for job events)./_make_event
to create an event for a particular entity type. The base function corresponds to the "default" case, and will raise an error if called. The overloaded functions are implemented within each entity Python file (injob.py
for jobs, inscenario.py
for scenarios, etc) and will implement the logic of creating an event from this specific entity. This method is intended to centralize event creation.