orionis 0.519.0__py3-none-any.whl → 0.520.0__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.
@@ -1,3 +1,4 @@
1
+ from typing import Dict, List
1
2
  from rich.console import Console
2
3
  from rich.panel import Panel
3
4
  from rich.table import Table
@@ -71,7 +72,7 @@ class ScheduleListCommand(BaseCommand):
71
72
  await scheduler.tasks(schedule_service)
72
73
 
73
74
  # Retrieve the list of scheduled jobs/events
74
- list_tasks = schedule_service.events()
75
+ list_tasks: List[Dict] = schedule_service.events()
75
76
 
76
77
  # Display a message if no scheduled jobs are found
77
78
  if not list_tasks:
@@ -85,20 +86,20 @@ class ScheduleListCommand(BaseCommand):
85
86
  table.add_column("Signature", style="cyan", no_wrap=True)
86
87
  table.add_column("Arguments", style="magenta")
87
88
  table.add_column("Purpose", style="green")
88
- table.add_column("Random Delay (calculated result)", style="yellow")
89
+ table.add_column("Random Delay (Calculated Result)", style="yellow")
89
90
  table.add_column("Start Date", style="white")
90
91
  table.add_column("End Date", style="white")
91
92
  table.add_column("Details", style="dim")
92
93
 
93
94
  # Populate the table with job details
94
95
  for job in list_tasks:
95
- signature = str(job.get("signature", ""))
96
- args = ", ".join(map(str, job.get("args", [])))
97
- purpose = str(job.get("purpose", ""))
98
- random_delay = str(job.get("random_delay", ""))
99
- start_date = str(job.get("start_date", "")) if job.get("start_date") else "-"
100
- end_date = str(job.get("end_date", "")) if job.get("end_date") else "-"
101
- details = str(job.get("details", ""))
96
+ signature = str(job.get("signature"))
97
+ args = str(job.get("args", []))
98
+ purpose = str(job.get("purpose"))
99
+ random_delay = str(job.get("random_delay"))
100
+ start_date = str(job.get("start_date"))
101
+ end_date = str(job.get("end_date"))
102
+ details = str(job.get("details"))
102
103
 
103
104
  table.add_row(signature, args, purpose, random_delay, start_date, end_date, details)
104
105
 
@@ -367,17 +367,32 @@ class Scheduler(ISchedule):
367
367
 
368
368
  # Ensure the listener is callable before invoking it
369
369
  if callable(listener):
370
+
370
371
  try:
372
+
371
373
  # If the listener is a coroutine, schedule it as an asyncio task
372
374
  if asyncio.iscoroutinefunction(listener):
373
- asyncio.create_task(listener(event_data, self))
375
+ try:
376
+ # Try to get the running event loop
377
+ loop = asyncio.get_running_loop()
378
+ loop.create_task(listener(event_data, self))
379
+ except RuntimeError:
380
+ # If no event loop is running, create a new one
381
+ asyncio.run(listener(event_data, self))
374
382
  # Otherwise, invoke the listener directly as a regular function
375
383
  else:
376
384
  listener(event_data, self)
385
+
377
386
  except Exception as e:
387
+
378
388
  # Log any exceptions that occur during listener invocation
379
389
  self.__logger.error(f"Error invoking global listener for event '{scheduler_event}': {str(e)}")
380
390
 
391
+ # Raise a runtime error if listener invocation fails
392
+ raise CLIOrionisRuntimeError(
393
+ f"An error occurred while invoking the listener for event '{scheduler_event}': {str(e)}"
394
+ )
395
+
381
396
  def __taskCallableListener(
382
397
  self,
383
398
  event_data: Optional[Union[JobError, JobExecuted, JobSubmitted, JobMissed, JobMaxInstances]],
@@ -993,8 +1008,8 @@ class Scheduler(ISchedule):
993
1008
  self.__scheduler.add_job(
994
1009
  func=self.__scheduler.pause, # Function to pause the scheduler
995
1010
  trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
996
- id=f"pause_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
997
- name=f"Pause Scheduler at {at.isoformat()}", # Descriptive name for the job
1011
+ id=ListeningEvent.SCHEDULER_PAUSED.value, # Unique job ID for pausing the scheduler
1012
+ name=ListeningEvent.SCHEDULER_PAUSED.value, # Descriptive name for the job
998
1013
  replace_existing=True # Replace any existing job with the same ID
999
1014
  )
1000
1015
 
@@ -1035,8 +1050,8 @@ class Scheduler(ISchedule):
1035
1050
  self.__scheduler.add_job(
1036
1051
  func=self.__scheduler.resume, # Function to resume the scheduler
1037
1052
  trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
1038
- id=f"resume_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
1039
- name=f"Resume Scheduler at {at.isoformat()}", # Descriptive name for the job
1053
+ id=ListeningEvent.SCHEDULER_RESUMED.value, # Unique job ID for resuming the scheduler
1054
+ name=ListeningEvent.SCHEDULER_RESUMED.value, # Descriptive name for the job
1040
1055
  replace_existing=True # Replace any existing job with the same ID
1041
1056
  )
1042
1057
 
@@ -1077,8 +1092,8 @@ class Scheduler(ISchedule):
1077
1092
  self.__scheduler.add_job(
1078
1093
  func=self.__scheduler.shutdown, # Function to shut down the scheduler
1079
1094
  trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
1080
- id=f"shutdown_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
1081
- name=f"Shutdown Scheduler at {at.isoformat()}", # Descriptive name for the job
1095
+ id=ListeningEvent.SCHEDULER_SHUTDOWN.value, # Unique job ID for shutting down the scheduler
1096
+ name=ListeningEvent.SCHEDULER_SHUTDOWN.value, # Descriptive name for the job
1082
1097
  replace_existing=True # Replace any existing job with the same ID
1083
1098
  )
1084
1099
 
@@ -1099,15 +1114,15 @@ class Scheduler(ISchedule):
1099
1114
  # Start the AsyncIOScheduler to handle asynchronous jobs.
1100
1115
  try:
1101
1116
 
1117
+ # Ensure we're in an asyncio context
1118
+ asyncio.get_running_loop()
1119
+
1102
1120
  # Ensure all events are loaded into the internal jobs list
1103
1121
  self.__loadEvents()
1104
1122
 
1105
- # Subscribe to scheduler events for monitoring and handling
1123
+ # Subscribe to scheduler events
1106
1124
  self.__subscribeListeners()
1107
1125
 
1108
- # Ensure we're in an asyncio context
1109
- asyncio.get_running_loop()
1110
-
1111
1126
  # Start the scheduler
1112
1127
  if not self.__scheduler.running:
1113
1128
  self.__scheduler.start()
@@ -1352,15 +1367,24 @@ class Scheduler(ISchedule):
1352
1367
 
1353
1368
  # Iterate over each job in the internal jobs list
1354
1369
  for job in self.__jobs:
1370
+
1371
+ signature = job.signature
1372
+ args = job.args
1373
+ purpose = job.purpose
1374
+ random_delay = job.random_delay if job.random_delay else 0
1375
+ start_date = job.start_date.strftime('%Y-%m-%d %H:%M:%S') if job.start_date else 'Not Applicable'
1376
+ end_date = job.end_date.strftime('%Y-%m-%d %H:%M:%S') if job.end_date else 'Not Applicable'
1377
+ details = job.details if job.details else 'Not Available'
1378
+
1355
1379
  # Append a dictionary with relevant job details to the events list
1356
1380
  events.append({
1357
- 'signature': job.signature,
1358
- 'args': job.args,
1359
- 'purpose': job.purpose,
1360
- 'random_delay': job.random_delay,
1361
- 'start_date': job.start_date.strftime('%Y-%m-%d %H:%M:%S') if job.start_date else None,
1362
- 'end_date': job.end_date.strftime('%Y-%m-%d %H:%M:%S') if job.end_date else None,
1363
- 'details': job.details
1381
+ 'signature': signature,
1382
+ 'args': args,
1383
+ 'purpose': purpose,
1384
+ 'random_delay': random_delay,
1385
+ 'start_date': start_date,
1386
+ 'end_date': end_date,
1387
+ 'details': details
1364
1388
  })
1365
1389
 
1366
1390
  # Return the list of scheduled job details
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.519.0"
8
+ VERSION = "0.520.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.519.0
3
+ Version: 0.520.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -14,7 +14,7 @@ orionis/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
14
14
  orionis/console/commands/cache.py,sha256=8DsYoRzSBLn0P9qkGVItRbo0R6snWBDBg0_Xa7tmVhs,2322
15
15
  orionis/console/commands/help.py,sha256=zfSw0pYaOnFN-_Ozdn4veBQDYMgSSDY10nPDCi-7tTY,3199
16
16
  orionis/console/commands/publisher.py,sha256=FUg-EUzK7LLXsla10ZUZro8V0Z5S-KjmsaSdRHSSGbA,21381
17
- orionis/console/commands/scheduler_list.py,sha256=iPO-tc5qj-Q17lL_1MRSCaRov_o4GoQcnWTATLKPeLE,4826
17
+ orionis/console/commands/scheduler_list.py,sha256=A2N_mEXEJDHO8DX2TDrL1ROeeRhFSkWD3rCw64Hrf0o,4763
18
18
  orionis/console/commands/scheduler_work.py,sha256=yHTbnDH1frAmyvPaUgn0a5q34Eym9QYMXdqYZWwodFs,6336
19
19
  orionis/console/commands/test.py,sha256=-EmQwFwMBuby3OI9HwqMIwuJzd2CGbWbOqmwrR25sOE,2402
20
20
  orionis/console/commands/version.py,sha256=SUuNDJ40f2uq69OQUmPQXJKaa9Bm_iVRDPmBd7zc1Yc,3658
@@ -81,7 +81,7 @@ orionis/console/request/cli_request.py,sha256=7-sgYmNUCipuHLVAwWLJiHv0cJCDmsM1Lu
81
81
  orionis/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  orionis/console/tasks/event.py,sha256=l4J-HEPaj1mxB_PYQMgG9dRHUe01wUag8fKLLnR2N2M,164395
83
83
  orionis/console/tasks/listener.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
- orionis/console/tasks/schedule.py,sha256=pUU9583IfF4_SSR2QShOC9emYIRVZIw55L0I231OCzE,57354
84
+ orionis/console/tasks/schedule.py,sha256=y6fnvxofKw_sd-Br2ICzsvinCyV5HDLygLJtDlyTCLw,58292
85
85
  orionis/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
86
  orionis/container/container.py,sha256=aF_b6lTUpG4YCo9yFJEzsntTdIzgMMXFW5LyWqAJVBQ,87987
87
87
  orionis/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -239,7 +239,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=72SoixFog9IOE9Ve9Xcfw6
239
239
  orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
240
240
  orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
241
241
  orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
242
- orionis/metadata/framework.py,sha256=VeR527XQrx3ObhbRQw5nqCi2-UqaggUmArNd_JGPPIw,4109
242
+ orionis/metadata/framework.py,sha256=9ERo-wA31Fhf-QLk4fPAYjSxTyE4FM6xHG0dXUxPL_0,4109
243
243
  orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
244
244
  orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
245
245
  orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -415,7 +415,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
415
415
  orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
416
416
  orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
417
417
  orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
418
- orionis-0.519.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
418
+ orionis-0.520.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
419
419
  tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
420
420
  tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
421
421
  tests/container/context/test_manager.py,sha256=wOwXpl9rHNfTTexa9GBKYMwK0_-KSQPbI-AEyGNkmAE,1356
@@ -561,8 +561,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
561
561
  tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
562
562
  tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
563
563
  tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
564
- orionis-0.519.0.dist-info/METADATA,sha256=XE_Lo42wgelgD9vBLaDtuWArC0hUaAI-nqGUiBTZvSs,4801
565
- orionis-0.519.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
566
- orionis-0.519.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
567
- orionis-0.519.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
568
- orionis-0.519.0.dist-info/RECORD,,
564
+ orionis-0.520.0.dist-info/METADATA,sha256=UAhnPWMKxyQiTmmFb6zL_34hsjfhmzdPIjOrXhmJDYM,4801
565
+ orionis-0.520.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
566
+ orionis-0.520.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
567
+ orionis-0.520.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
568
+ orionis-0.520.0.dist-info/RECORD,,