django-cfg 1.1.62__py3-none-any.whl → 1.1.64__py3-none-any.whl

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.
django_cfg/__init__.py CHANGED
@@ -38,7 +38,7 @@ default_app_config = "django_cfg.apps.DjangoCfgConfig"
38
38
  from typing import TYPE_CHECKING
39
39
 
40
40
  # Version information
41
- __version__ = "1.1.62"
41
+ __version__ = "1.1.64"
42
42
  __author__ = "Unrealos Team"
43
43
  __email__ = "info@unrealos.com"
44
44
  __license__ = "MIT"
@@ -127,7 +127,9 @@ class Command(BaseCommand):
127
127
  if log_file:
128
128
  process_args.extend(["--log-file", log_file])
129
129
 
130
- process_args.extend(tasks_modules)
130
+ # Add broker module first, then task modules
131
+ process_args.append("django_cfg.modules.dramatiq_setup") # Broker module
132
+ process_args.extend(tasks_modules[1:]) # Skip broker module from tasks_modules
131
133
 
132
134
  self.stdout.write(f"\nCommand that would be executed:")
133
135
  self.stdout.write(f' {" ".join(process_args)}')
@@ -168,8 +170,9 @@ class Command(BaseCommand):
168
170
  if log_file:
169
171
  process_args.extend(["--log-file", log_file])
170
172
 
171
- # Add task modules (broker module first, then discovered modules)
172
- process_args.extend(tasks_modules)
173
+ # Add broker module first, then task modules
174
+ process_args.append("django_cfg.modules.dramatiq_setup") # Broker module
175
+ process_args.extend(tasks_modules[1:]) # Skip broker module from tasks_modules
173
176
 
174
177
  self.stdout.write(f'Running dramatiq: "{" ".join(process_args)}"\n')
175
178
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-cfg
3
- Version: 1.1.62
3
+ Version: 1.1.64
4
4
  Summary: 🚀 Production-ready Django configuration framework with type-safe settings, smart automation, and modern developer experience
5
5
  Project-URL: Homepage, https://github.com/markolofsen/django-cfg
6
6
  Project-URL: Documentation, https://django-cfg.readthedocs.io
@@ -173,7 +173,7 @@ python manage.py runserver
173
173
  - ✅ **Newsletter campaigns** with email tracking
174
174
  - ✅ **Lead management** system with CRM integration
175
175
  - ✅ **Multi-database routing** and connection pooling
176
- - ✅ **Background task processing** with Dramatiq
176
+ - ✅ **Background task processing** with production-ready Dramatiq integration
177
177
  - ✅ **Webhook testing** with built-in ngrok integration
178
178
  - ✅ **Type-safe configuration** with full IDE support
179
179
 
@@ -413,8 +413,137 @@ Automatic dev/staging/production detection with appropriate defaults.
413
413
  ### 🌐 **Built-in Ngrok Integration**
414
414
  Instant webhook testing with zero-config ngrok tunnels for development.
415
415
 
416
- ### 🔄 **Background Task Processing**
417
- Built-in Dramatiq integration for reliable background job processing with Redis.
416
+ ### 🔄 **Background Task Processing** %%PRIORITY:HIGH%%
417
+
418
+ Django-CFG includes a complete Dramatiq integration for reliable background job processing with automatic Redis configuration, worker management, and task monitoring.
419
+
420
+ #### Features
421
+ - **🚀 Zero Configuration** - Automatic Redis broker setup and queue management
422
+ - **⚡ Smart Worker Management** - Built-in `rundramatiq` command with Django settings integration
423
+ - **🔧 Type-Safe Task Definition** - Full IDE support for task creation and scheduling
424
+ - **📊 Task Monitoring** - Built-in commands for queue status and task management
425
+ - **🐳 Docker Ready** - Pre-configured Docker containers for production deployment
426
+ - **🛡️ Production Tested** - Battle-tested configuration used in production environments
427
+
428
+ #### Quick Setup
429
+ ```python
430
+ from django_cfg import DjangoConfig
431
+
432
+ class MyConfig(DjangoConfig):
433
+ project_name: str = "My App"
434
+
435
+ # Dramatiq configuration (automatic)
436
+ redis_url: str = "redis://localhost:6379/2" # Separate DB for tasks
437
+
438
+ # Optional: Custom task settings
439
+ dramatiq: DramatiqConfig = DramatiqConfig(
440
+ processes=2, # Worker processes
441
+ threads=4, # Threads per process
442
+ redis_db=2, # Redis database for tasks
443
+ queues=["default", "high", "low"] # Available queues
444
+ )
445
+
446
+ config = MyConfig()
447
+ ```
448
+
449
+ #### Task Definition
450
+ ```python
451
+ import dramatiq
452
+ from django_cfg.modules.django_tasks import get_broker
453
+
454
+ # Tasks are automatically discovered from your apps
455
+ @dramatiq.actor(queue_name="high", max_retries=3)
456
+ def process_document(document_id: str) -> dict:
457
+ """Process document asynchronously with full Django context."""
458
+ from myapp.models import Document
459
+
460
+ document = Document.objects.get(id=document_id)
461
+ # Your processing logic here
462
+ document.status = "processed"
463
+ document.save()
464
+
465
+ return {"status": "completed", "document_id": document_id}
466
+
467
+ # Queue the task
468
+ process_document.send(document_id="123")
469
+ ```
470
+
471
+ #### Management Commands
472
+ ```bash
473
+ # Start Dramatiq workers with Django settings
474
+ python manage.py rundramatiq --processes 4 --threads 8
475
+
476
+ # Monitor task queues and status
477
+ python manage.py task_status --queue high
478
+
479
+ # Clear specific queues
480
+ python manage.py task_clear --queue default
481
+
482
+ # Test task processing pipeline
483
+ python manage.py test_tasks
484
+ ```
485
+
486
+ #### Docker Integration
487
+ ```yaml
488
+ # docker-compose.yml (automatically generated)
489
+ services:
490
+ app-dramatiq:
491
+ build: .
492
+ command: ["python", "manage.py", "rundramatiq"]
493
+ environment:
494
+ - DRAMATIQ_PROCESSES=2
495
+ - DRAMATIQ_THREADS=4
496
+ - DRAMATIQ_QUEUES=default,high,low
497
+ depends_on:
498
+ - redis
499
+ - postgres
500
+ ```
501
+
502
+ #### Production Features
503
+ - **🔄 Automatic Restart** - Workers restart on code changes in development
504
+ - **📈 Scaling** - Easy horizontal scaling with multiple worker containers
505
+ - **🛡️ Error Handling** - Built-in retry logic and dead letter queues
506
+ - **📊 Monitoring** - Integration with Django admin for task monitoring
507
+ - **⚡ Performance** - Optimized Redis configuration for high throughput
508
+
509
+ #### Real-World Example
510
+ ```python
511
+ # Document processing pipeline
512
+ @dramatiq.actor(queue_name="knowledge", max_retries=2)
513
+ def process_document_async(document_id: str) -> dict:
514
+ """Complete document processing with chunking and embeddings."""
515
+ try:
516
+ document = Document.objects.get(id=document_id)
517
+
518
+ # Step 1: Chunk document
519
+ chunks = create_document_chunks(document)
520
+
521
+ # Step 2: Generate embeddings
522
+ for chunk in chunks:
523
+ generate_embeddings.send(chunk.id)
524
+
525
+ # Step 3: Optimize database
526
+ optimize_document_embeddings.send(document_id)
527
+
528
+ return {"status": "completed", "chunks_created": len(chunks)}
529
+
530
+ except Exception as e:
531
+ logger.error(f"Document processing failed: {e}")
532
+ return {"status": "failed", "error": str(e)}
533
+
534
+ # Triggered automatically via Django signals
535
+ @receiver(post_save, sender=Document)
536
+ def queue_document_processing(sender, instance, created, **kwargs):
537
+ if created:
538
+ process_document_async.send(str(instance.id))
539
+ ```
540
+
541
+ **Perfect for:**
542
+ - 📄 **Document Processing** - PDF parsing, text extraction, embeddings
543
+ - 📧 **Email Campaigns** - Bulk email sending with delivery tracking
544
+ - 🔄 **Data Synchronization** - API integrations and data imports
545
+ - 📊 **Report Generation** - Heavy computational tasks
546
+ - 🧹 **Cleanup Tasks** - Database maintenance and optimization
418
547
 
419
548
  ---
420
549
 
@@ -444,6 +573,7 @@ Django-CFG includes powerful management commands for development and operations:
444
573
  | **`rundramatiq`** | Run Dramatiq background task workers | `python manage.py rundramatiq --processes 4` |
445
574
  | **`task_status`** | Show Dramatiq task status and queues | `python manage.py task_status --queue high` |
446
575
  | **`task_clear`** | Clear Dramatiq queues | `python manage.py task_clear --queue default` |
576
+ | **`test_tasks`** | Test Dramatiq task processing pipeline | `python manage.py test_tasks --document-id 123` |
447
577
  | **`tree`** | Display Django project structure | `python manage.py tree --depth 3 --include-docs` |
448
578
  | **`validate_config`** | Deep validation of all settings | `python manage.py validate_config --strict` |
449
579
 
@@ -955,6 +1085,17 @@ class ProductionConfig(DjangoConfig):
955
1085
  enable_newsletter: bool = True # Email marketing, campaigns, tracking & analytics
956
1086
  enable_leads: bool = True # Lead capture, CRM integration, source tracking
957
1087
 
1088
+ # === Background Task Processing ===
1089
+ redis_url: str = "redis://redis:6379/2" # Separate DB for Dramatiq tasks
1090
+ dramatiq: DramatiqConfig = DramatiqConfig(
1091
+ processes=4, # Production worker processes
1092
+ threads=8, # Threads per process for I/O bound tasks
1093
+ redis_db=2, # Dedicated Redis DB for task queues
1094
+ queues=["default", "high", "low", "knowledge", "email"], # Production queues
1095
+ max_retries=3, # Default retry attempts
1096
+ max_age=3600000, # 1 hour max task age (milliseconds)
1097
+ )
1098
+
958
1099
  # === Multi-Zone API ===
959
1100
  revolution: RevolutionConfig = RevolutionConfig(
960
1101
  api_prefix="api/v2",
@@ -1,4 +1,4 @@
1
- django_cfg/__init__.py,sha256=hKbPbaVNg7IaLQ4vE3n3Y7U-mkn0685XzcnlerGqy-s,14288
1
+ django_cfg/__init__.py,sha256=y07sq8IgnY7SBDOPKENJt5CzHEv6lGomZd6AqXWYaZQ,14288
2
2
  django_cfg/apps.py,sha256=k84brkeXJI7EgKZLEpTkM9YFZofKI4PzhFOn1cl9Msc,1656
3
3
  django_cfg/exceptions.py,sha256=RTQEoU3PfR8lqqNNv5ayd_HY2yJLs3eioqUy8VM6AG4,10378
4
4
  django_cfg/integration.py,sha256=-7hvd-4ohLdzH4eufCZTOe3yTzPoQyB_HCfvsSm9AAw,5218
@@ -156,7 +156,7 @@ django_cfg/management/commands/create_token.py,sha256=beHtUTuyFZhG97F9vSkaX-u7ti
156
156
  django_cfg/management/commands/generate.py,sha256=w0BF7IMftxNjxTxFuY8cw5pNKGW-LmTScJ8kZpxHu_8,4248
157
157
  django_cfg/management/commands/list_urls.py,sha256=D8ikInA3uE1LbQGLWmfdLnEqPg7wqrI3caQA6iTe_-0,11009
158
158
  django_cfg/management/commands/migrator.py,sha256=mhMM63uv_Jp9zHVVM7TMwCB90uv3iFZn1vOG-rXyi3s,16191
159
- django_cfg/management/commands/rundramatiq.py,sha256=1e07PWrtSnxTPZ8RCpgY_yxwV2y-EAduVZDZ34DRqoI,8896
159
+ django_cfg/management/commands/rundramatiq.py,sha256=JmRB_eAexMZcuXu0ln8vqO0CSpWO_7yEMBykKOHCYTE,9190
160
160
  django_cfg/management/commands/runserver_ngrok.py,sha256=mcTioDIzHgha6sGo5eazlJhdKr8y5-uEQIc3qG3AvCI,5237
161
161
  django_cfg/management/commands/script.py,sha256=I6zOEQEGaED0HoLxl2EqKz39HwbKg9HhdxnGKybfH5s,16974
162
162
  django_cfg/management/commands/show_config.py,sha256=0YJ99P1XvymT3fWritaNmn_HJ-PVb0I-yBy757M_bn8,8337
@@ -252,8 +252,8 @@ django_cfg/templates/emails/base_email.html,sha256=TWcvYa2IHShlF_E8jf1bWZStRO0v8
252
252
  django_cfg/utils/__init__.py,sha256=64wwXJuXytvwt8Ze_erSR2HmV07nGWJ6DV5wloRBvYE,435
253
253
  django_cfg/utils/path_resolution.py,sha256=eML-6-RIGTs5TePktIQN8nxfDUEFJ3JA0AzWBcihAbs,13894
254
254
  django_cfg/utils/smart_defaults.py,sha256=iL6_n3jGDW5812whylWAwXik0xBSYihdLp4IJ26T5eA,20547
255
- django_cfg-1.1.62.dist-info/METADATA,sha256=kN7aAQBvL6bjI5WJrhev0tknRjeiRBoNfFhtQscS74o,38953
256
- django_cfg-1.1.62.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
257
- django_cfg-1.1.62.dist-info/entry_points.txt,sha256=Ucmde4Z2wEzgb4AggxxZ0zaYDb9HpyE5blM3uJ0_VNg,56
258
- django_cfg-1.1.62.dist-info/licenses/LICENSE,sha256=xHuytiUkSZCRG3N11nk1X6q1_EGQtv6aL5O9cqNRhKE,1071
259
- django_cfg-1.1.62.dist-info/RECORD,,
255
+ django_cfg-1.1.64.dist-info/METADATA,sha256=fpzL6zF9N33CDJwsPPmWdQnNJ6v6l3MBrjmDWFZE_Qk,44084
256
+ django_cfg-1.1.64.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
257
+ django_cfg-1.1.64.dist-info/entry_points.txt,sha256=Ucmde4Z2wEzgb4AggxxZ0zaYDb9HpyE5blM3uJ0_VNg,56
258
+ django_cfg-1.1.64.dist-info/licenses/LICENSE,sha256=xHuytiUkSZCRG3N11nk1X6q1_EGQtv6aL5O9cqNRhKE,1071
259
+ django_cfg-1.1.64.dist-info/RECORD,,