Skip to content

Event consumer API simplification into develop #2566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5ef135e
implement EventConsumer
jrobinAV Apr 15, 2025
3c9ba97
Implement UTs for EventConsumer
jrobinAV Apr 15, 2025
9b5abd9
fix imports
jrobinAV Apr 15, 2025
d85df90
Update __init__.py
jrobinAV Apr 17, 2025
eae31fe
Update __init__.py
jrobinAV Apr 17, 2025
6a7e524
Decorate not implemented method with @abstractmethod
jrobinAV Apr 17, 2025
d094a4e
oups
jrobinAV Apr 17, 2025
47b4bc4
Make mypy happy
jrobinAV Apr 17, 2025
2f103e6
Merge branch 'develop' into feature/#2306-event-consumer-simplification
jrobinAV Apr 17, 2025
09a14da
Make ruff happy
jrobinAV Apr 17, 2025
ab163db
Update codeql-analysis.yml
jrobinAV Apr 17, 2025
d14e692
fix UT
jrobinAV Apr 18, 2025
2ba72a2
fix UT
jrobinAV Apr 18, 2025
cf4af84
Feedback from Eric and Florian: Systematically pass the gui as param
jrobinAV Apr 28, 2025
e2fc903
Merge branch 'develop' into feature/#2306-event-consumer-simplification
jrobinAV Apr 28, 2025
ec6dc93
Attempt to fix pipfile.lock
jrobinAV Apr 29, 2025
28f679a
Revert "Attempt to fix pipfile.lock"
jrobinAV Apr 29, 2025
52b5769
Merge branch 'develop' into feature/#2306-event-consumer-simplification
jrobinAV May 2, 2025
acaacae
#2597 Fix missing parent_ids
jrobinAV May 6, 2025
6d886f6
Merge branch 'develop' into feature/#2306-event-consumer-simplification
jrobinAV May 7, 2025
959cd8f
Yet another consumer API version
jrobinAV May 7, 2025
b6e195b
Linter + Giang's feedback
jrobinAV May 7, 2025
1559358
Linter + Giang's feedback
jrobinAV May 7, 2025
8a1fba2
Linter + Giang's feedback
jrobinAV May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions taipy/core/common/_check_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _check_dependency_is_installed(module_name: str, package_name: str) -> None:
class EnterpriseEditionUtils:
_TAIPY_ENTERPRISE_MODULE = "taipy.enterprise"
_TAIPY_ENTERPRISE_CORE_MODULE = _TAIPY_ENTERPRISE_MODULE + ".core"
_TAIPY_ENTERPRISE_EVENT_PACKAGE = _TAIPY_ENTERPRISE_MODULE + ".event"

@classmethod
def _using_enterprise(cls) -> bool:
Expand Down
1 change: 0 additions & 1 deletion taipy/core/notification/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from ._registration import _Registration
from ._topic import _Topic
from .core_event_consumer import CoreEventConsumerBase
from .event import Event, EventEntityType, EventOperation, _make_event
from .notifier import Notifier, _publish_event
from .registration_id import RegistrationId
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .event import Event


class CoreEventConsumerBase(threading.Thread):
class _CoreEventConsumerBase(threading.Thread):
"""Abstract base class for implementing a Core event consumer.

This class provides a framework for consuming events from a queue in a separate thread.
Expand Down
10 changes: 10 additions & 0 deletions taipy/event/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2021-2025 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
25 changes: 25 additions & 0 deletions taipy/event/_event_callback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2021-2025 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
from dataclasses import dataclass, field
from typing import Callable, List, Optional

from taipy.core.notification import Event


@dataclass
class _Callback:
callback: Callable
args: Optional[List] = field(default_factory=list)
broadcast: Optional[bool] = False
filter: Optional[Callable[[Event], bool]] = None

def __hash__(self):
return hash(self.callback)
26 changes: 26 additions & 0 deletions taipy/event/_event_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2021-2025 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
from taipy.core.notification import Event


class _AbstractEventProcessor:
"""Abstract base class for implementing an event processor."""

@classmethod
def process_event(cls, event_consumer, event: Event):
raise NotImplementedError("Subclasses must implement this method.")

class _EventProcessor(_AbstractEventProcessor):

@classmethod
def process_event(cls, event_consumer, event: Event):
event_consumer._process_event(event)

Loading
Loading