Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
426bac3
ADR 022: GQL compliant notifications; first draft
robsdedude May 23, 2024
9c17148
Omit boilerplate values in polyfilled non-notification statuses + tests
robsdedude Jun 10, 2024
9cbd172
Recent ADR updates
robsdedude Jun 10, 2024
232b305
Fix applied ADR updates; partially revert 9cbd172f
robsdedude Jun 11, 2024
dc5089c
Fix missing license header
robsdedude Jun 11, 2024
b3efbac
Refactor
robsdedude Jun 12, 2024
1228724
Fix description of generated fallback GQL status objects
robsdedude Jun 12, 2024
87da424
Fix notification filter merging
robsdedude Jun 13, 2024
6ebf86b
Fix warn_notification_severity normalization
robsdedude Jun 13, 2024
02e4a02
Fix summary attribute getter
robsdedude Jun 13, 2024
449aa7d
Refactor diag. record enhancement into bolt class
robsdedude Jun 13, 2024
98df635
Fix minor bugs found during testing
robsdedude Jun 13, 2024
93f4d32
Revamp import test
robsdedude Jun 13, 2024
9c24231
TestKit backend: fix warnings
robsdedude Jun 13, 2024
153ed56
Merge branch '5.0' into 022-gql-notifications
robsdedude Jun 13, 2024
096efc3
Remove left-over debug print statement 😬
robsdedude Jun 14, 2024
a3a0e6a
Update changelog
robsdedude Jun 14, 2024
c6fdd63
Docs: fix version of change
robsdedude Jun 14, 2024
8313fb8
Fix docs from outdated design
robsdedude Jun 14, 2024
a3cb5f6
Remove left-over debug print
robsdedude Jun 14, 2024
225356d
Remove left-over debug print
robsdedude Jun 14, 2024
c285a21
Code clean-up + extra test + more resilience against invalid server r…
robsdedude Jun 24, 2024
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
101 changes: 95 additions & 6 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ Set the minimum severity for notifications the server should send to the client.
Disabling severities allows the server to skip analysis for those, which can speed up query execution.

Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`.ResultSummary.summary_notifications`.
Further, they are surfaced through :attr:`.ResultSummary.gql_status_objects`:
For GQL-aware servers, notifications are a subset of GqlStatusObjects.
See also :attr:`.GqlSatusObject.is_notification`.

:data:`None` will apply the server's default setting.

Expand All @@ -706,13 +709,17 @@ Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`

``notifications_disabled_categories``
-------------------------------------
Set categories of notifications the server should not send to the client.
Set categories/classifications of notifications the server should not send to the client.
Disabling categories allows the server to skip analysis for those, which can speed up query execution.

Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`.ResultSummary.summary_notifications`.
Further, they are surfaced (alongside other status objects) through :attr:`.ResultSummary.gql_status_objects`:
See also :attr:`.GqlSatusObject.is_notification`.

:data:`None` will apply the server's default setting.

If specified together with :ref:`driver-notifications-disabled-classifications-ref`, the settings will be merged.

.. Note::
If configured, the server or all servers of the cluster need to support notifications filtering
(server version 5.7 and newer).
Expand All @@ -726,6 +733,27 @@ Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`
.. seealso:: :class:`.NotificationDisabledCategory`, session config :ref:`session-notifications-disabled-categories-ref`


.. _driver-notifications-disabled-classifications-ref:

``notifications_disabled_classifications``
------------------------------------------
Identical to :ref:`driver-notifications-disabled-categories-ref`.

This alias is provided for a consistent naming with :attr:`.GqlStatusObject.classification`.

**This is a preview** (see :ref:`filter-warnings-ref`).
It might be changed without following the deprecation policy.
See also
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features

:Type: :data:`None`, :term:`iterable` of :class:`.NotificationDisabledClassification` and/or :class:`str`
:Default: :data:`None`

.. versionadded:: 5.21

.. seealso:: :class:`.NotificationDisabledClassification`, session config :ref:`session-notifications-disabled-classifications-ref`


.. _driver-warn-notification-severity-ref:

``warn_notification_severity``
Expand Down Expand Up @@ -1159,11 +1187,14 @@ Set the minimum severity for notifications the server should send to the client.
Disabling severities allows the server to skip analysis for those, which can speed up query execution.

Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`.ResultSummary.summary_notifications`.
Further, they are surfaced (alongside other status objects) through :attr:`.ResultSummary.gql_status_objects`:
See also :attr:`.GqlSatusObject.is_notification`.

:data:`None` will apply the driver's configuration setting (:ref:`driver-notifications-min-severity-ref`).

.. Note::
If configured, the server or all servers of the cluster need to support notifications filtering.
If configured, the server or all servers of the cluster need to support notifications filtering
(server version 5.7 and newer).
Otherwise, the driver will raise a :exc:`.ConfigurationError` as soon as it encounters a server that does not.

:Type: :data:`None`, :class:`.NotificationMinimumSeverity`, or :class:`str`
Expand All @@ -1182,11 +1213,16 @@ Set categories of notifications the server should not send to the client.
Disabling categories allows the server to skip analysis for those, which can speed up query execution.

Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`.ResultSummary.summary_notifications`.
Further, they are surfaced (alongside other status objects) through :attr:`.ResultSummary.gql_status_objects`:
See also :attr:`.GqlSatusObject.is_notification`.

:data:`None` will apply the driver's configuration setting (:ref:`driver-notifications-min-severity-ref`).
:data:`None` will apply the driver's configuration setting (:ref:`driver-notifications-disabled-categories-ref`).

If specified together with :ref:`session-notifications-disabled-classifications-ref`, the settings will be merged.

.. Note::
If configured, the server or all servers of the cluster need to support notifications filtering.
If configured, the server or all servers of the cluster need to support notifications filtering
(server version 5.7 and newer).
Otherwise, the driver will raise a :exc:`.ConfigurationError` as soon as it encounters a server that does not.

:Type: :data:`None`, :term:`iterable` of :class:`.NotificationDisabledCategory` and/or :class:`str`
Expand All @@ -1197,6 +1233,27 @@ Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`
.. seealso:: :class:`.NotificationDisabledCategory`


.. _session-notifications-disabled-classifications-ref:

``notifications_disabled_classifications``
------------------------------------------
Identical to :ref:`session-notifications-disabled-categories-ref`.

This alias is provided for a consistent naming with :attr:`.GqlStatusObject.classification`.

**This is a preview** (see :ref:`filter-warnings-ref`).
It might be changed without following the deprecation policy.
See also
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features

:Type: :data:`None`, :term:`iterable` of :class:`.NotificationDisabledClassification` and/or :class:`str`
:Default: :data:`None`

.. versionadded:: 5.21

.. seealso:: :class:`.NotificationDisabledClassification`



***********
Transaction
Expand Down Expand Up @@ -1521,6 +1578,20 @@ ServerInfo
:members:


GqlStatusObject
===============

.. autoclass:: neo4j.GqlStatusObject()
:members:


NotificationClassification
--------------------------

.. autoclass:: neo4j.NotificationClassification()
:members:


SummaryNotification
===================

Expand All @@ -1542,11 +1613,26 @@ NotificationCategory
:members:


SummaryInputPosition
--------------------

.. autoclass:: neo4j.SummaryInputPosition()
:members:


SummaryNotificationPosition
---------------------------

.. autoclass:: neo4j.SummaryNotificationPosition()
:members:
.. data:: neo4j.SummaryNotificationPosition
:annotation: = neo4j.SummaryInputPosition

Deprecated alias for :class:`.SummaryInputPosition`.

.. versionadded:: 5.7

.. versionchanged:: 5.21
Deprecated in favor of :class:`.SummaryInputPosition`.




Expand Down Expand Up @@ -1869,6 +1955,9 @@ Constants, Enums, Helpers
:show-inheritance:
:members:

.. autoclass:: neo4j.NotificationDisabledClassification()
:members:

.. autoclass:: neo4j.RoutingControl()
:show-inheritance:
:members:
Expand Down
47 changes: 42 additions & 5 deletions src/neo4j/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# limitations under the License.


import typing as _t
from logging import getLogger as _getLogger

from ._api import (
NotificationCategory,
NotificationDisabledCategory,
NotificationDisabledClassification as _NotificationDisabledClassification,
NotificationMinimumSeverity,
NotificationSeverity,
RoutingControl,
Expand Down Expand Up @@ -49,6 +51,7 @@
deprecation_warn as _deprecation_warn,
ExperimentalWarning,
get_user_agent,
preview_warn as _preview_warn,
PreviewWarning,
version as __version__,
)
Expand All @@ -67,13 +70,25 @@
)
from ._work import (
EagerResult,
GqlStatusObject as _GqlStatusObject,
NotificationClassification as _NotificationClassification,
Query,
ResultSummary,
SummaryCounters,
SummaryInputPosition,
SummaryNotification,
SummaryNotificationPosition,
unit_of_work,
)


if _t.TYPE_CHECKING:
from ._api import NotificationDisabledClassification
from ._work import (
GqlStatusObject,
NotificationClassification,
SummaryInputPosition as SummaryNotificationPosition
)

from .addressing import (
Address,
IPv4Address,
Expand Down Expand Up @@ -122,20 +137,23 @@
"Config",
"custom_auth",
"DEFAULT_DATABASE",
"NotificationDisabledCategory",
"Driver",
"EagerResult",
"ExperimentalWarning",
"get_user_agent",
"GqlStatusObject",
"GraphDatabase",
"IPv4Address",
"IPv6Address",
"kerberos_auth",
"log",
"ManagedTransaction",
"NotificationMinimumSeverity",
"Neo4jDriver",
"NotificationCategory",
"NotificationClassification",
"NotificationDisabledCategory",
"NotificationDisabledClassification",
"NotificationMinimumSeverity",
"NotificationSeverity",
"PoolConfig",
"PreviewWarning",
Expand All @@ -149,6 +167,7 @@
"Session",
"SessionConfig",
"SummaryCounters",
"SummaryInputPosition",
"SummaryNotification",
"SummaryNotificationPosition",
"Transaction",
Expand All @@ -173,12 +192,30 @@ def __getattr__(name):
"log", "Config", "PoolConfig", "SessionConfig", "WorkspaceConfig"
):
_deprecation_warn(
"Importing {} from neo4j is deprecated without replacement. It's "
"internal and will be removed in a future version."
"Importing {} from neo4j is deprecated without replacement. "
"It's internal and will be removed in a future version."
.format(name),
stack_level=2
)
return globals()[f"_{name}"]
if name == "SummaryNotificationPosition":
_deprecation_warn(
"SummaryNotificationPosition is deprecated. "
"Use SummaryInputPosition instead.",
stack_level=2
)
return SummaryInputPosition
if name in (
"NotificationClassification",
"GqlStatusObject",
"NotificationDisabledClassification",
):
_preview_warn(
f"{name} is part of GQLSTATUS support, "
"which is a preview feature.",
stack_level=2
)
return globals()[f"_{name}"]
raise AttributeError(f"module {__name__} has no attribute {name}")


Expand Down
Loading