autonomous-app 0.3.31__py3-none-any.whl → 0.3.32__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.
autonomous/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.31"
1
+ __version__ = "0.3.32"
2
2
 
3
3
  from dotenv import load_dotenv
4
4
 
autonomous/db/db_sync.py CHANGED
@@ -46,8 +46,8 @@ def process_single_object_sync(object_id, collection_name, token):
46
46
  token_key = f"sync_token:{collection_name}:{str_id}"
47
47
 
48
48
  # 1. THE DEBOUNCE WAIT (Happens in background)
49
- print(f"Debouncing {str_id} for 5 seconds...")
50
- time.sleep(5)
49
+ print(f"Debouncing {str_id} for 2 seconds...")
50
+ time.sleep(2)
51
51
 
52
52
  # 2. THE VERIFICATION
53
53
  # Check if a newer save happened while we slept
@@ -133,6 +133,7 @@ def request_indexing(object_id, collection_name):
133
133
  object_id=str_id,
134
134
  collection_name=collection_name,
135
135
  token=current_token,
136
+ priority=TaskPriority.LOW
136
137
  )
137
138
  return True
138
139
  except Exception as e:
@@ -1,8 +1,15 @@
1
1
  import os
2
+ from enum import Enum
2
3
  from redis import Redis
3
4
  from rq import Queue
4
5
  from rq.job import Job
5
6
 
7
+ # 1. Define Priorities clearly
8
+ class TaskPriority(Enum):
9
+ HIGH = "high"
10
+ DEFAULT = "default"
11
+ LOW = "low"
12
+
6
13
  class AutoTask:
7
14
  def __init__(self, job):
8
15
  self.job = job
@@ -17,7 +24,6 @@ class AutoTask:
17
24
 
18
25
  @property
19
26
  def result(self):
20
- # Simplified result fetching
21
27
  return {
22
28
  "id": self.id,
23
29
  "return_value": self.job.result,
@@ -27,9 +33,8 @@ class AutoTask:
27
33
 
28
34
  class AutoTasks:
29
35
  _connection = None
30
- queue = None
36
+ # We remove the single 'queue' class attribute because we now have multiple
31
37
 
32
- # Config stays the same
33
38
  config = {
34
39
  "host": os.environ.get("REDIS_HOST", "cachedb"),
35
40
  "port": os.environ.get("REDIS_PORT", 6379),
@@ -38,32 +43,40 @@ class AutoTasks:
38
43
  "db": os.environ.get("REDIS_DB", 0),
39
44
  }
40
45
 
41
- def __init__(self, queue_name="default"):
46
+ def __init__(self):
47
+ # Establish connection once (Singleton pattern logic)
42
48
  if not AutoTasks._connection:
43
49
  options = {}
44
50
  if AutoTasks.config.get("password"):
45
51
  options["password"] = AutoTasks.config.get("password")
46
52
 
47
- # Create Redis Connection
48
53
  AutoTasks._connection = Redis(
49
54
  host=AutoTasks.config.get("host"),
50
55
  port=AutoTasks.config.get("port"),
51
- decode_responses=False, # RQ requires bytes, not strings
56
+ decode_responses=False,
52
57
  **options,
53
58
  )
54
59
 
55
- # Initialize Queue
56
- AutoTasks.queue = Queue(queue_name, connection=AutoTasks._connection)
60
+ def _get_queue(self, priority_name):
61
+ """Helper to get or create the queue object for a specific priority"""
62
+ return Queue(priority_name, connection=AutoTasks._connection)
57
63
 
58
64
  def task(self, func, *args, **kwargs):
59
65
  """
60
- Enqueues a job to Redis. Does NOT start a worker.
66
+ Enqueues a job.
67
+ kwarg 'priority' determines the queue (default: 'default').
61
68
  """
62
69
  job_timeout = kwargs.pop("_task_job_timeout", 3600)
63
70
 
64
- # Enqueue the job
65
- # func can be a string path or the function object itself
66
- job = AutoTasks.queue.enqueue(
71
+ # 2. Extract Priority (support Enum or string)
72
+ priority = kwargs.pop("priority", TaskPriority.DEFAULT)
73
+ queue_name = priority.value if isinstance(priority, TaskPriority) else priority
74
+
75
+ # 3. Get the specific queue
76
+ q = self._get_queue(queue_name)
77
+
78
+ # 4. Enqueue
79
+ job = q.enqueue(
67
80
  func,
68
81
  args=args,
69
82
  kwargs=kwargs,
@@ -77,4 +90,4 @@ class AutoTasks:
77
90
  job = Job.fetch(job_id, connection=AutoTasks._connection)
78
91
  return AutoTask(job)
79
92
  except Exception:
80
- return None
93
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autonomous-app
3
- Version: 0.3.31
3
+ Version: 0.3.32
4
4
  Summary: Containerized application framework built on Flask with additional libraries and tools for rapid development of web applications.
5
5
  Author-email: Steven A Moore <samoore@binghamton.edu>
6
6
  Project-URL: homepage, https://github.com/Sallenmoore/autonomous
@@ -1,4 +1,4 @@
1
- autonomous/__init__.py,sha256=IYpCcBa6pM-33askQSaMEQIruv9EItiurnkTkM6Q-Uc,95
1
+ autonomous/__init__.py,sha256=o0OBgjtEx3l3_EWwzavqnwIF8TyTqfqpMo9MyaB2SOY,95
2
2
  autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
3
3
  autonomous/logger.py,sha256=NQtgEaTWNAWfLSgqSP7ksXj1GpOuCgoUV711kSMm-WA,2022
4
4
  autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -27,7 +27,7 @@ autonomous/db/__init__.py,sha256=2mNynmYV0I_J3-W4Aw1cojAQrHf4aHZT1Ow9xUdmM18,115
27
27
  autonomous/db/common.py,sha256=BUN2x_XuQBRFcq54TGPx4yLMLJdgytdbIt07QWr4CSM,2551
28
28
  autonomous/db/connection.py,sha256=j_-eMre4ade9Y8GejJcMbQQiSEimL4j2vIQxaXViKxI,17754
29
29
  autonomous/db/context_managers.py,sha256=_nH2ajCL8Xy90AuB2rKaryR4iF8Q8ksU3Nei_mZj-DE,9918
30
- autonomous/db/db_sync.py,sha256=dTJ8QO1-_OJkNJL-Bb8lHQkWpdOHyDRIVB4w3WW5lCU,4308
30
+ autonomous/db/db_sync.py,sha256=o_7Fw-6eL-Wco-ktSFneq2CRQNuOneO1f4YzgOa4Wcs,4346
31
31
  autonomous/db/dereference.py,sha256=EgbpPCXtDZqD_ZuY1Wd4o3ltRy8qEo3C5yRh5_c9fLE,12776
32
32
  autonomous/db/document.py,sha256=oZKdTaoqwv9fCHiv450rIxgINASQF3J9FzIsUOUXHhw,44428
33
33
  autonomous/db/errors.py,sha256=_QeCotid1kmr7_W0QyH6NUrwwYN9eced_yyyiop0Xlw,4108
@@ -55,10 +55,10 @@ autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
55
55
  autonomous/storage/imagestorage.py,sha256=SmBjBNBlP1ZEjxdOnGVzCHZhbEhMKTUQC2TbpWbejDE,6168
56
56
  autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
57
57
  autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
58
- autonomous/tasks/autotask.py,sha256=9Fi7juGEEq8OVEQYES7sEkU21bkBhtBAIQ-Js5fMXDc,2193
58
+ autonomous/tasks/autotask.py,sha256=2zRaqHYqfdlgC_BQm6B6D2svN1ukyWeJJHwweZFHVoo,2616
59
59
  autonomous/tasks/task_router.py,sha256=W09HtRUuhwlnGxM5w4l6Hzw6mfS6L4ljWiMzD3ZVFeU,601
60
60
  autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
61
- autonomous_app-0.3.31.dist-info/METADATA,sha256=Nz_e0D8StzIr6uAFxzXlazvrva2rFu8GzV2WTayCRDE,3024
62
- autonomous_app-0.3.31.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
63
- autonomous_app-0.3.31.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
64
- autonomous_app-0.3.31.dist-info/RECORD,,
61
+ autonomous_app-0.3.32.dist-info/METADATA,sha256=d3w42OsH0w0u6PpAY8ADR1SJSeLsee0f-UbbfieVWfE,3024
62
+ autonomous_app-0.3.32.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
63
+ autonomous_app-0.3.32.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
64
+ autonomous_app-0.3.32.dist-info/RECORD,,