This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Improve Core Events to support additional metadata #829
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
550fa1f
Change event API and introduce the make_event function to dynamically…
gmarabout 2f505bf
Merge branch 'develop' into experimental/improve-core-events
gmarabout c8bd55b
test: Improve unit tests
gmarabout 447e12d
test: order of events is not guaranteed
gmarabout abf3d53
Remove config_id from the Event class, use more Notifier.publish
gmarabout ecf2f99
Merge branch 'develop' into experimental/improve-core-events
gmarabout File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
|
||
import traceback | ||
from datetime import datetime | ||
from typing import Callable, List | ||
from typing import Any, Callable, List, Optional | ||
|
||
from taipy.logger._taipy_logger import _TaipyLogger | ||
|
||
|
@@ -22,6 +22,7 @@ | |
from .._entity._reload import _self_reload, _self_setter | ||
from .._version._version_manager_factory import _VersionManagerFactory | ||
from ..common._utils import _fcts_to_dict | ||
from ..notification.event import Event, EventEntityType, EventOperation, make_event | ||
from ..task.task import Task | ||
from .job_id import JobId | ||
from .status import Status | ||
|
@@ -70,6 +71,9 @@ def __init__(self, id: JobId, task: Task, submit_id: str, submit_entity_id: str, | |
self.__logger = _TaipyLogger._get_logger() | ||
self._version = version or _VersionManagerFactory._build_manager()._get_latest_version() | ||
|
||
def get_event_context(self): | ||
return {"task_config_id": self._task.config_id} | ||
|
||
@property # type: ignore | ||
@_self_reload(_MANAGER_NAME) | ||
def task(self): | ||
|
@@ -351,3 +355,24 @@ def is_deletable(self) -> bool: | |
from ... import core as tp | ||
|
||
return tp.is_deletable(self) | ||
|
||
|
||
@make_event.register(Job) | ||
def make_event_for_job( | ||
job: Job, | ||
operation: EventOperation, | ||
/, | ||
attribute_name: Optional[str] = None, | ||
attribute_value: Optional[Any] = None, | ||
**kwargs, | ||
) -> Event: | ||
metadata = {"creation_date": job.creation_date} | ||
return Event( | ||
entity_type=EventEntityType.JOB, | ||
entity_id=job.id, | ||
config_id=job._task.config_id, # OK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous comment may have an impact on this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
operation=operation, | ||
attribute_name=attribute_name, | ||
attribute_value=attribute_value, | ||
metadata={**metadata, **kwargs}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: Adding more arguments to the
Event
class make the use of a arg list a bit cumbersome and very error prone (think the order being significant!).That is why I propose to replace this list of args by a list of
Event
objects. Then, the logic does not change, except that it makes more sense to callNotifier.publish
directly now...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's awesome!!