avtomatika 1.0b5__tar.gz → 1.0b7__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 (86) hide show
  1. {avtomatika-1.0b5/src/avtomatika.egg-info → avtomatika-1.0b7}/PKG-INFO +77 -4
  2. {avtomatika-1.0b5 → avtomatika-1.0b7}/README.md +76 -2
  3. {avtomatika-1.0b5 → avtomatika-1.0b7}/pyproject.toml +1 -2
  4. avtomatika-1.0b7/src/avtomatika/api/handlers.py +549 -0
  5. avtomatika-1.0b7/src/avtomatika/api/routes.py +118 -0
  6. avtomatika-1.0b7/src/avtomatika/app_keys.py +32 -0
  7. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/blueprint.py +125 -54
  8. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/config.py +4 -0
  9. avtomatika-1.0b7/src/avtomatika/constants.py +30 -0
  10. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/context.py +2 -2
  11. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/data_types.py +3 -2
  12. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/dispatcher.py +1 -1
  13. avtomatika-1.0b7/src/avtomatika/engine.py +380 -0
  14. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/executor.py +21 -16
  15. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/history/postgres.py +56 -13
  16. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/history/sqlite.py +54 -34
  17. avtomatika-1.0b7/src/avtomatika/logging_config.py +92 -0
  18. avtomatika-1.0b7/src/avtomatika/scheduler.py +119 -0
  19. avtomatika-1.0b7/src/avtomatika/scheduler_config_loader.py +41 -0
  20. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/security.py +3 -5
  21. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/storage/base.py +17 -3
  22. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/storage/memory.py +50 -8
  23. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/storage/redis.py +17 -0
  24. avtomatika-1.0b7/src/avtomatika/utils/__init__.py +0 -0
  25. avtomatika-1.0b7/src/avtomatika/utils/webhook_sender.py +54 -0
  26. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/watcher.py +1 -3
  27. {avtomatika-1.0b5 → avtomatika-1.0b7/src/avtomatika.egg-info}/PKG-INFO +77 -4
  28. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika.egg-info/SOURCES.txt +13 -0
  29. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika.egg-info/requires.txt +0 -1
  30. avtomatika-1.0b7/tests/test_blueprint_integrity.py +100 -0
  31. avtomatika-1.0b7/tests/test_engine.py +259 -0
  32. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_error_handling.py +21 -13
  33. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_executor.py +68 -0
  34. avtomatika-1.0b7/tests/test_handlers.py +451 -0
  35. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_history.py +4 -1
  36. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_logging_config.py +16 -4
  37. avtomatika-1.0b7/tests/test_optimization.py +83 -0
  38. avtomatika-1.0b7/tests/test_scheduler.py +200 -0
  39. avtomatika-1.0b7/tests/test_webhook_sender.py +54 -0
  40. avtomatika-1.0b5/src/avtomatika/engine.py +0 -854
  41. avtomatika-1.0b5/src/avtomatika/logging_config.py +0 -41
  42. avtomatika-1.0b5/tests/test_engine.py +0 -672
  43. {avtomatika-1.0b5 → avtomatika-1.0b7}/LICENSE +0 -0
  44. {avtomatika-1.0b5 → avtomatika-1.0b7}/setup.cfg +0 -0
  45. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/__init__.py +0 -0
  46. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/api.html +0 -0
  47. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/client_config_loader.py +0 -0
  48. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/compression.py +0 -0
  49. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/datastore.py +0 -0
  50. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/health_checker.py +0 -0
  51. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/history/base.py +0 -0
  52. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/history/noop.py +0 -0
  53. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/metrics.py +0 -0
  54. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/py.typed +0 -0
  55. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/quota.py +0 -0
  56. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/ratelimit.py +0 -0
  57. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/reputation.py +0 -0
  58. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/storage/__init__.py +0 -0
  59. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/telemetry.py +0 -0
  60. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/worker_config_loader.py +0 -0
  61. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika/ws_manager.py +0 -0
  62. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika.egg-info/dependency_links.txt +0 -0
  63. {avtomatika-1.0b5 → avtomatika-1.0b7}/src/avtomatika.egg-info/top_level.txt +0 -0
  64. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_blueprint_conditions.py +0 -0
  65. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_blueprints.py +0 -0
  66. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_client_config_loader.py +0 -0
  67. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_compression.py +0 -0
  68. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_config_validation.py +0 -0
  69. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_context.py +0 -0
  70. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_dispatcher.py +0 -0
  71. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_dispatcher_extended.py +0 -0
  72. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_health_checker.py +0 -0
  73. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_integration.py +0 -0
  74. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_memory_locking.py +0 -0
  75. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_memory_storage.py +0 -0
  76. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_metrics.py +0 -0
  77. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_noop_history.py +0 -0
  78. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_postgres_history.py +0 -0
  79. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_ratelimit.py +0 -0
  80. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_redis_locking.py +0 -0
  81. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_redis_storage.py +0 -0
  82. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_reputation.py +0 -0
  83. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_telemetry.py +0 -0
  84. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_watcher.py +0 -0
  85. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_worker_config_loader.py +0 -0
  86. {avtomatika-1.0b5 → avtomatika-1.0b7}/tests/test_ws_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: avtomatika
3
- Version: 1.0b5
3
+ Version: 1.0b7
4
4
  Summary: A state-machine based orchestrator for long-running AI and other jobs.
5
5
  Project-URL: Homepage, https://github.com/avtomatika-ai/avtomatika
6
6
  Project-URL: Bug Tracker, https://github.com/avtomatika-ai/avtomatika/issues
@@ -12,7 +12,6 @@ Requires-Python: >=3.11
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: aiohttp~=3.12
15
- Requires-Dist: aiocache~=0.12
16
15
  Requires-Dist: python-json-logger~=4.0
17
16
  Requires-Dist: graphviz~=0.21
18
17
  Requires-Dist: zstandard~=0.24
@@ -60,6 +59,8 @@ This document serves as a comprehensive guide for developers looking to build pi
60
59
  - [Delegating Tasks to Workers (dispatch_task)](#delegating-tasks-to-workers-dispatch_task)
61
60
  - [Parallel Execution and Aggregation (Fan-out/Fan-in)](#parallel-execution-and-aggregation-fan-outfan-in)
62
61
  - [Dependency Injection (DataStore)](#dependency-injection-datastore)
62
+ - [Native Scheduler](#native-scheduler)
63
+ - [Webhook Notifications](#webhook-notifications)
63
64
  - [Production Configuration](#production-configuration)
64
65
  - [Fault Tolerance](#fault-tolerance)
65
66
  - [Storage Backend](#storage-backend)
@@ -74,7 +75,17 @@ The project is based on a simple yet powerful architectural pattern that separat
74
75
 
75
76
  * **Orchestrator (OrchestratorEngine)** — The Director. It manages the entire process from start to finish, tracks state, handles errors, and decides what should happen next. It does not perform business tasks itself.
76
77
  * **Blueprints (Blueprint)** — The Script. Each blueprint is a detailed plan (a state machine) for a specific business process. It describes the steps (states) and the rules for transitioning between them.
77
- * **Workers (Worker)** — The Team of Specialists. These are independent, specialized executors. Each worker knows how to perform a specific set of tasks (e.g., "process video," "send email") and reports back to the Orchestrator.## Installation
78
+ * **Workers (Worker)** — The Team of Specialists. These are independent, specialized executors. Each worker knows how to perform a specific set of tasks (e.g., "process video," "send email") and reports back to the Orchestrator.
79
+
80
+ ## Ecosystem
81
+
82
+ Avtomatika is part of a larger ecosystem:
83
+
84
+ * **[Avtomatika Worker SDK](https://github.com/avtomatika-ai/avtomatika-worker)**: The official Python SDK for building workers that connect to this engine.
85
+ * **[RCA Protocol](https://github.com/avtomatika-ai/rca)**: The architectural specification and manifesto behind the system.
86
+ * **[Full Example](https://github.com/avtomatika-ai/avtomatika-full-example)**: A complete reference project demonstrating the engine and workers in action.
87
+
88
+ ## Installation
78
89
 
79
90
  * **Install the core engine only:**
80
91
  ```bash
@@ -146,7 +157,13 @@ async def end_handler(context):
146
157
  engine = OrchestratorEngine(storage, config)
147
158
  engine.register_blueprint(my_blueprint)
148
159
 
149
- # 4. Define the main entrypoint to run the server
160
+ # 4. Accessing Components (Optional)
161
+ # You can access the internal aiohttp app and core components using AppKeys
162
+ # from avtomatika.app_keys import ENGINE_KEY, DISPATCHER_KEY
163
+ # app = engine.app
164
+ # dispatcher = app[DISPATCHER_KEY]
165
+
166
+ # 5. Define the main entrypoint to run the server
150
167
  async def main():
151
168
  await engine.start()
152
169
 
@@ -328,6 +345,56 @@ async def cache_handler(data_stores):
328
345
  user_data = await data_stores.cache.get("user:123")
329
346
  print(f"User from cache: {user_data}")
330
347
  ```
348
+
349
+ ### 5. Native Scheduler
350
+
351
+ Avtomatika includes a built-in distributed scheduler. It allows you to trigger blueprints periodically (interval, daily, weekly, monthly) without external tools like cron.
352
+
353
+ * **Configuration:** Defined in `schedules.toml`.
354
+ * **Timezone Aware:** Supports global timezone configuration (e.g., `TZ="Europe/Moscow"`).
355
+ * **Distributed Locking:** Safe to run with multiple orchestrator instances; jobs are guaranteed to run only once per interval using distributed locks (Redis/Memory).
356
+
357
+ ```toml
358
+ # schedules.toml example
359
+ [nightly_backup]
360
+ blueprint = "backup_flow"
361
+ daily_at = "02:00"
362
+ ```
363
+
364
+ ### 6. Webhook Notifications
365
+
366
+ The orchestrator can send asynchronous notifications to an external system when a job completes, fails, or is quarantined. This eliminates the need for clients to constantly poll the API for status updates.
367
+
368
+ * **Usage:** Pass a `webhook_url` in the request body when creating a job.
369
+ * **Events:**
370
+ * `job_finished`: The job reached a final success state.
371
+ * `job_failed`: The job failed (e.g., due to an error or invalid input).
372
+ * `job_quarantined`: The job was moved to quarantine after repeated failures.
373
+
374
+ **Example Request:**
375
+ ```json
376
+ POST /api/v1/jobs/my_flow
377
+ {
378
+ "initial_data": {
379
+ "video_url": "..."
380
+ },
381
+ "webhook_url": "https://my-app.com/webhooks/avtomatika"
382
+ }
383
+ ```
384
+
385
+ **Example Webhook Payload:**
386
+ ```json
387
+ {
388
+ "event": "job_finished",
389
+ "job_id": "123e4567-e89b-12d3-a456-426614174000",
390
+ "status": "finished",
391
+ "result": {
392
+ "output_path": "/videos/result.mp4"
393
+ },
394
+ "error": null
395
+ }
396
+ ```
397
+
331
398
  ## Production Configuration
332
399
 
333
400
  The orchestrator's behavior can be configured through environment variables. Additionally, any configuration parameter loaded from environment variables can be programmatically overridden in your application code after the `Config` object has been initialized. This provides flexibility for different deployment and testing scenarios.
@@ -349,6 +416,12 @@ To manage access and worker settings securely, Avtomatika uses TOML configuratio
349
416
  [gpu-worker-01]
350
417
  token = "worker-secret-456"
351
418
  ```
419
+ - **`schedules.toml`**: Defines periodic tasks (CRON-like) for the native scheduler.
420
+ ```toml
421
+ [nightly_backup]
422
+ blueprint = "backup_flow"
423
+ daily_at = "02:00"
424
+ ```
352
425
 
353
426
  For detailed specifications and examples, please refer to the [**Configuration Guide**](docs/configuration.md).
354
427
 
@@ -14,6 +14,8 @@ This document serves as a comprehensive guide for developers looking to build pi
14
14
  - [Delegating Tasks to Workers (dispatch_task)](#delegating-tasks-to-workers-dispatch_task)
15
15
  - [Parallel Execution and Aggregation (Fan-out/Fan-in)](#parallel-execution-and-aggregation-fan-outfan-in)
16
16
  - [Dependency Injection (DataStore)](#dependency-injection-datastore)
17
+ - [Native Scheduler](#native-scheduler)
18
+ - [Webhook Notifications](#webhook-notifications)
17
19
  - [Production Configuration](#production-configuration)
18
20
  - [Fault Tolerance](#fault-tolerance)
19
21
  - [Storage Backend](#storage-backend)
@@ -28,7 +30,17 @@ The project is based on a simple yet powerful architectural pattern that separat
28
30
 
29
31
  * **Orchestrator (OrchestratorEngine)** — The Director. It manages the entire process from start to finish, tracks state, handles errors, and decides what should happen next. It does not perform business tasks itself.
30
32
  * **Blueprints (Blueprint)** — The Script. Each blueprint is a detailed plan (a state machine) for a specific business process. It describes the steps (states) and the rules for transitioning between them.
31
- * **Workers (Worker)** — The Team of Specialists. These are independent, specialized executors. Each worker knows how to perform a specific set of tasks (e.g., "process video," "send email") and reports back to the Orchestrator.## Installation
33
+ * **Workers (Worker)** — The Team of Specialists. These are independent, specialized executors. Each worker knows how to perform a specific set of tasks (e.g., "process video," "send email") and reports back to the Orchestrator.
34
+
35
+ ## Ecosystem
36
+
37
+ Avtomatika is part of a larger ecosystem:
38
+
39
+ * **[Avtomatika Worker SDK](https://github.com/avtomatika-ai/avtomatika-worker)**: The official Python SDK for building workers that connect to this engine.
40
+ * **[RCA Protocol](https://github.com/avtomatika-ai/rca)**: The architectural specification and manifesto behind the system.
41
+ * **[Full Example](https://github.com/avtomatika-ai/avtomatika-full-example)**: A complete reference project demonstrating the engine and workers in action.
42
+
43
+ ## Installation
32
44
 
33
45
  * **Install the core engine only:**
34
46
  ```bash
@@ -100,7 +112,13 @@ async def end_handler(context):
100
112
  engine = OrchestratorEngine(storage, config)
101
113
  engine.register_blueprint(my_blueprint)
102
114
 
103
- # 4. Define the main entrypoint to run the server
115
+ # 4. Accessing Components (Optional)
116
+ # You can access the internal aiohttp app and core components using AppKeys
117
+ # from avtomatika.app_keys import ENGINE_KEY, DISPATCHER_KEY
118
+ # app = engine.app
119
+ # dispatcher = app[DISPATCHER_KEY]
120
+
121
+ # 5. Define the main entrypoint to run the server
104
122
  async def main():
105
123
  await engine.start()
106
124
 
@@ -282,6 +300,56 @@ async def cache_handler(data_stores):
282
300
  user_data = await data_stores.cache.get("user:123")
283
301
  print(f"User from cache: {user_data}")
284
302
  ```
303
+
304
+ ### 5. Native Scheduler
305
+
306
+ Avtomatika includes a built-in distributed scheduler. It allows you to trigger blueprints periodically (interval, daily, weekly, monthly) without external tools like cron.
307
+
308
+ * **Configuration:** Defined in `schedules.toml`.
309
+ * **Timezone Aware:** Supports global timezone configuration (e.g., `TZ="Europe/Moscow"`).
310
+ * **Distributed Locking:** Safe to run with multiple orchestrator instances; jobs are guaranteed to run only once per interval using distributed locks (Redis/Memory).
311
+
312
+ ```toml
313
+ # schedules.toml example
314
+ [nightly_backup]
315
+ blueprint = "backup_flow"
316
+ daily_at = "02:00"
317
+ ```
318
+
319
+ ### 6. Webhook Notifications
320
+
321
+ The orchestrator can send asynchronous notifications to an external system when a job completes, fails, or is quarantined. This eliminates the need for clients to constantly poll the API for status updates.
322
+
323
+ * **Usage:** Pass a `webhook_url` in the request body when creating a job.
324
+ * **Events:**
325
+ * `job_finished`: The job reached a final success state.
326
+ * `job_failed`: The job failed (e.g., due to an error or invalid input).
327
+ * `job_quarantined`: The job was moved to quarantine after repeated failures.
328
+
329
+ **Example Request:**
330
+ ```json
331
+ POST /api/v1/jobs/my_flow
332
+ {
333
+ "initial_data": {
334
+ "video_url": "..."
335
+ },
336
+ "webhook_url": "https://my-app.com/webhooks/avtomatika"
337
+ }
338
+ ```
339
+
340
+ **Example Webhook Payload:**
341
+ ```json
342
+ {
343
+ "event": "job_finished",
344
+ "job_id": "123e4567-e89b-12d3-a456-426614174000",
345
+ "status": "finished",
346
+ "result": {
347
+ "output_path": "/videos/result.mp4"
348
+ },
349
+ "error": null
350
+ }
351
+ ```
352
+
285
353
  ## Production Configuration
286
354
 
287
355
  The orchestrator's behavior can be configured through environment variables. Additionally, any configuration parameter loaded from environment variables can be programmatically overridden in your application code after the `Config` object has been initialized. This provides flexibility for different deployment and testing scenarios.
@@ -303,6 +371,12 @@ To manage access and worker settings securely, Avtomatika uses TOML configuratio
303
371
  [gpu-worker-01]
304
372
  token = "worker-secret-456"
305
373
  ```
374
+ - **`schedules.toml`**: Defines periodic tasks (CRON-like) for the native scheduler.
375
+ ```toml
376
+ [nightly_backup]
377
+ blueprint = "backup_flow"
378
+ daily_at = "02:00"
379
+ ```
306
380
 
307
381
  For detailed specifications and examples, please refer to the [**Configuration Guide**](docs/configuration.md).
308
382
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "avtomatika"
7
- version = "1.0b5"
7
+ version = "1.0b7"
8
8
  description = "A state-machine based orchestrator for long-running AI and other jobs."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -16,7 +16,6 @@ classifiers = [
16
16
  ]
17
17
  dependencies = [
18
18
  "aiohttp~=3.12",
19
- "aiocache~=0.12",
20
19
  "python-json-logger~=4.0",
21
20
  "graphviz~=0.21",
22
21
  "zstandard~=0.24",