opendataframework 0.4.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {opendataframework-0.4.0 → opendataframework-0.6.0}/PKG-INFO +53 -5
  2. {opendataframework-0.4.0 → opendataframework-0.6.0}/README.md +52 -4
  3. {opendataframework-0.4.0 → opendataframework-0.6.0}/pyproject.toml +1 -1
  4. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/__init__.py +22 -2
  5. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/context.py +356 -72
  6. opendataframework-0.6.0/src/opendataframework/events.py +459 -0
  7. opendataframework-0.6.0/src/opendataframework/logger.py +1019 -0
  8. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/namespace.py +15 -0
  9. opendataframework-0.6.0/src/opendataframework/notifications.py +913 -0
  10. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/project.py +14 -4
  11. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/repository.py +32 -0
  12. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/view.py +56 -0
  13. opendataframework-0.4.0/src/opendataframework/events.py +0 -188
  14. opendataframework-0.4.0/src/opendataframework/logger.py +0 -140
  15. {opendataframework-0.4.0 → opendataframework-0.6.0}/LICENSE +0 -0
  16. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/agent.py +0 -0
  17. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/component.py +0 -0
  18. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/config.py +0 -0
  19. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/entity.py +0 -0
  20. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/function.py +0 -0
  21. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/layer.py +0 -0
  22. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/pipeline.py +0 -0
  23. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/py.typed +0 -0
  24. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/service.py +0 -0
  25. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/task.py +0 -0
  26. {opendataframework-0.4.0 → opendataframework-0.6.0}/src/opendataframework/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opendataframework
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: Lightweight dependency-injection framework for data applications.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -26,7 +26,7 @@ Lightweight dependency-injection framework for data applications.
26
26
  This package provides structural abstractions —
27
27
  `Entity`, `Repository`, `Component`, `Service`, `Task`, `Pipeline`,
28
28
  `Agent`, `Function`, `Layer`, `Namespace`, `Context`, `Project`, `Config`,
29
- `Logger`, `View` — with zero third-party dependencies. No UI, no CLI, no MCP server.
29
+ `Logger`, `Events`, `Notifications`, `View` — with zero third-party dependencies. No UI, no CLI, no MCP server.
30
30
 
31
31
  > Need the CLI, UI, or MCP server? That's the
32
32
  > [`odf`](https://opendataframework.github.io/odf/) package, which
@@ -284,7 +284,7 @@ class Postgres: ...
284
284
 
285
285
  The base class underlying every framework decorator — `Entity`,
286
286
  `Component`, `Service`, `Task`, `Pipeline`, `Agent`, `Function`,
287
- `Repository`, and `Layer` are all `Namespace` subclasses, each with its own independent name → class
287
+ `Repository`, `Layer`, `Subscriber`, and `Publisher` are all `Namespace` subclasses, each with its own independent name → class
288
288
  mapping. A framework extension point, not something end users subclass
289
289
  directly. See
290
290
  [Namespace](https://opendataframework.github.io/opendataframework/namespace/).
@@ -307,7 +307,12 @@ class Postgres:
307
307
 
308
308
  Per-component logging handle, injectable via constructor DI like any
309
309
  other dependency — writes land in that component's own log file with no
310
- name argument needed.
310
+ name argument needed. Logs are structured: one JSON record per line by
311
+ default, keyword arguments become fields, and every protocol call the
312
+ framework makes is logged with its call and parent ids, so a run can be
313
+ traced across files. Files can rotate by size (`max-bytes` and `backups`
314
+ under `[project.logging]`); see
315
+ [Logger](https://opendataframework.github.io/opendataframework/logger/).
311
316
 
312
317
  ```python
313
318
  @Task
@@ -317,7 +322,50 @@ class ExportUsers:
317
322
  self.logger = logger
318
323
 
319
324
  def execute(self) -> None:
320
- self.logger.info("export starting")
325
+ self.logger.info("export starting", users=len(self.users.all()))
326
+ ```
327
+
328
+ ## Events
329
+
330
+ Reports every protocol call the framework makes — a `Service`'s `setup()`,
331
+ a `Task`'s `execute()`, a `@Function` call — as `started`, then `completed`
332
+ or `failed`, with timing and the `parent` call it ran inside.
333
+
334
+ ```python
335
+ @Component
336
+ class FailureAlerts:
337
+ def __init__(self, events: Events):
338
+ self._unsubscribe = events.subscribe(self.on_event)
339
+
340
+ def on_event(self, event: Event) -> None:
341
+ if event.state == "failed":
342
+ ...
343
+ ```
344
+
345
+ ## Notifications
346
+
347
+ Lets a component announce that something happened — a file arrived, an
348
+ order came in — so others can react without the publisher knowing who
349
+ they are. Never emitted by the framework itself. A publisher declares the
350
+ topics it publishes, and a subscriber the topics it reacts to; each
351
+ reaction is its own traced call.
352
+
353
+ ```python
354
+ @Publisher("orders.received")
355
+ @Task
356
+ class TakeOrders:
357
+ def __init__(self, notifications: Notifications):
358
+ self.notifications = notifications
359
+
360
+ def execute(self) -> None:
361
+ self.notifications.publish("orders.received", {"id": 7}, summary="Le Petit: 2 x baguette")
362
+
363
+
364
+ @Subscriber("orders.*") # deliver="background" for a slow reaction
365
+ @Component
366
+ class Kitchen:
367
+ def on_notification(self, notification: Notification) -> None:
368
+ print("cooking order", notification.payload["id"])
321
369
  ```
322
370
 
323
371
  ## Context
@@ -10,7 +10,7 @@ Lightweight dependency-injection framework for data applications.
10
10
  This package provides structural abstractions —
11
11
  `Entity`, `Repository`, `Component`, `Service`, `Task`, `Pipeline`,
12
12
  `Agent`, `Function`, `Layer`, `Namespace`, `Context`, `Project`, `Config`,
13
- `Logger`, `View` — with zero third-party dependencies. No UI, no CLI, no MCP server.
13
+ `Logger`, `Events`, `Notifications`, `View` — with zero third-party dependencies. No UI, no CLI, no MCP server.
14
14
 
15
15
  > Need the CLI, UI, or MCP server? That's the
16
16
  > [`odf`](https://opendataframework.github.io/odf/) package, which
@@ -268,7 +268,7 @@ class Postgres: ...
268
268
 
269
269
  The base class underlying every framework decorator — `Entity`,
270
270
  `Component`, `Service`, `Task`, `Pipeline`, `Agent`, `Function`,
271
- `Repository`, and `Layer` are all `Namespace` subclasses, each with its own independent name → class
271
+ `Repository`, `Layer`, `Subscriber`, and `Publisher` are all `Namespace` subclasses, each with its own independent name → class
272
272
  mapping. A framework extension point, not something end users subclass
273
273
  directly. See
274
274
  [Namespace](https://opendataframework.github.io/opendataframework/namespace/).
@@ -291,7 +291,12 @@ class Postgres:
291
291
 
292
292
  Per-component logging handle, injectable via constructor DI like any
293
293
  other dependency — writes land in that component's own log file with no
294
- name argument needed.
294
+ name argument needed. Logs are structured: one JSON record per line by
295
+ default, keyword arguments become fields, and every protocol call the
296
+ framework makes is logged with its call and parent ids, so a run can be
297
+ traced across files. Files can rotate by size (`max-bytes` and `backups`
298
+ under `[project.logging]`); see
299
+ [Logger](https://opendataframework.github.io/opendataframework/logger/).
295
300
 
296
301
  ```python
297
302
  @Task
@@ -301,7 +306,50 @@ class ExportUsers:
301
306
  self.logger = logger
302
307
 
303
308
  def execute(self) -> None:
304
- self.logger.info("export starting")
309
+ self.logger.info("export starting", users=len(self.users.all()))
310
+ ```
311
+
312
+ ## Events
313
+
314
+ Reports every protocol call the framework makes — a `Service`'s `setup()`,
315
+ a `Task`'s `execute()`, a `@Function` call — as `started`, then `completed`
316
+ or `failed`, with timing and the `parent` call it ran inside.
317
+
318
+ ```python
319
+ @Component
320
+ class FailureAlerts:
321
+ def __init__(self, events: Events):
322
+ self._unsubscribe = events.subscribe(self.on_event)
323
+
324
+ def on_event(self, event: Event) -> None:
325
+ if event.state == "failed":
326
+ ...
327
+ ```
328
+
329
+ ## Notifications
330
+
331
+ Lets a component announce that something happened — a file arrived, an
332
+ order came in — so others can react without the publisher knowing who
333
+ they are. Never emitted by the framework itself. A publisher declares the
334
+ topics it publishes, and a subscriber the topics it reacts to; each
335
+ reaction is its own traced call.
336
+
337
+ ```python
338
+ @Publisher("orders.received")
339
+ @Task
340
+ class TakeOrders:
341
+ def __init__(self, notifications: Notifications):
342
+ self.notifications = notifications
343
+
344
+ def execute(self) -> None:
345
+ self.notifications.publish("orders.received", {"id": 7}, summary="Le Petit: 2 x baguette")
346
+
347
+
348
+ @Subscriber("orders.*") # deliver="background" for a slow reaction
349
+ @Component
350
+ class Kitchen:
351
+ def on_notification(self, notification: Notification) -> None:
352
+ print("cooking order", notification.payload["id"])
305
353
  ```
306
354
 
307
355
  ## Context
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "opendataframework"
3
- version = "0.4.0"
3
+ version = "0.6.0"
4
4
  description = "Lightweight dependency-injection framework for data applications."
5
5
  authors = [
6
6
  {name = "mykytapavlov",email = "mykytapavlov@users.noreply.github.com"}
@@ -8,12 +8,20 @@ from opendataframework.entity import Entity
8
8
  from opendataframework.events import Event, Events
9
9
  from opendataframework.function import Function, FunctionProtocol
10
10
  from opendataframework.layer import Analytics, Api, Layer, Messaging, Monitoring, Security, Storage
11
- from opendataframework.logger import Logger
12
- from opendataframework.namespace import Namespace
11
+ from opendataframework.logger import Logger, LogsUnavailable
12
+ from opendataframework.namespace import Namespace, normalize_key
13
+ from opendataframework.notifications import (
14
+ Notification,
15
+ Notifications,
16
+ Publisher,
17
+ Subscriber,
18
+ SubscriberProtocol,
19
+ )
13
20
  from opendataframework.pipeline import Pipeline, PipelineProtocol
14
21
  from opendataframework.project import Project
15
22
  from opendataframework.repository import (
16
23
  ReadableProtocol,
24
+ Record,
17
25
  Repository,
18
26
  StreamableProtocol,
19
27
  WritableProtocol,
@@ -24,6 +32,8 @@ from opendataframework.view import (
24
32
  AudioView,
25
33
  ContentMetadata,
26
34
  ContentMetadataProtocol,
35
+ Conversation,
36
+ ConversationProtocol,
27
37
  DataView,
28
38
  DataViewProtocol,
29
39
  DocumentView,
@@ -48,6 +58,8 @@ __all__ = [
48
58
  "ContentMetadata",
49
59
  "ContentMetadataProtocol",
50
60
  "Context",
61
+ "Conversation",
62
+ "ConversationProtocol",
51
63
  "DataView",
52
64
  "DataViewProtocol",
53
65
  "DocumentView",
@@ -61,13 +73,18 @@ __all__ = [
61
73
  "Lifecycle",
62
74
  "LocationView",
63
75
  "Logger",
76
+ "LogsUnavailable",
64
77
  "Messaging",
65
78
  "Monitoring",
66
79
  "Namespace",
80
+ "Notification",
81
+ "Notifications",
67
82
  "Pipeline",
68
83
  "PipelineProtocol",
69
84
  "Project",
85
+ "Publisher",
70
86
  "ReadableProtocol",
87
+ "Record",
71
88
  "ReplayProtocol",
72
89
  "Repository",
73
90
  "Resolver",
@@ -78,10 +95,13 @@ __all__ = [
78
95
  "StreamableProtocol",
79
96
  "StreamingAudioView",
80
97
  "StreamingVideoView",
98
+ "Subscriber",
99
+ "SubscriberProtocol",
81
100
  "TableView",
82
101
  "Task",
83
102
  "TaskProtocol",
84
103
  "TimeseriesView",
85
104
  "VideoView",
86
105
  "WritableProtocol",
106
+ "normalize_key",
87
107
  ]