Avaiga / taipy-core

A Python library to build powerful and customized data-driven back-end applications.
Apache License 2.0
38 stars 17 forks source link

Improve Core Events to support additional metadata #829

Closed gmarabout closed 11 months ago

gmarabout commented 11 months ago

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 Python singledispatch mechanism. This function could eventually totally replace the static _publish_event.

For now, the _publish_event is still there for few cases.

Changes

github-actions[bot] commented 11 months ago

☂️ Python Cov

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🐍