brynq-sdk-task-scheduler 4.0.6__tar.gz → 4.0.8__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.
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: brynq_sdk_task_scheduler
3
+ Version: 4.0.8
4
+ Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
+ Author: BrynQ
6
+ Author-email: support@brynq.com
7
+ License: BrynQ License
8
+ Requires-Dist: brynq-sdk-brynq<5,>=4
9
+ Requires-Dist: brynq-sdk-functions<3,>=2
10
+ Requires-Dist: brynq-sdk-mysql<4,>=3
11
+ Requires-Dist: brynq-sdk-mandrill<4,>=2
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: description
15
+ Dynamic: license
16
+ Dynamic: requires-dist
17
+ Dynamic: summary
18
+
19
+ Code to execute tasks in the BrynQ.com platform with the task scheduler
@@ -254,8 +254,12 @@ class TaskScheduler:
254
254
  filter=f'WHERE `reload_id` = {self.run_id}')
255
255
  if self.email_after_errors:
256
256
  self.email_errors(failed=True)
257
- # Remove the temp values from the variables table
258
- self.mysql.raw_query(f'UPDATE `task_variables` SET temp_value = null WHERE task_id = {self.task_id}', insert=True)
257
+
258
+ # Remove the temp values from the variables table (legacy), if it doesn't exist, ignore the error. In that case it will already be flushed by the API endpoint
259
+ try:
260
+ self.mysql.raw_query(f'UPDATE `task_variables` SET temp_value = null WHERE task_id = {self.task_id}', insert=True)
261
+ except Exception as e:
262
+ pass
259
263
 
260
264
  # Start the chained tasks if it there are tasks which should start if this one is failed
261
265
  self.start_chained_tasks(finished_task_status='FAILED')
@@ -308,21 +312,25 @@ class TaskScheduler:
308
312
  values=['FinishedSuccess', f'{datetime.datetime.now()}'],
309
313
  filter=f'WHERE `reload_id` = {self.run_id}')
310
314
 
311
- # Remove the temp values from the variables table
312
- self.mysql.raw_query(f'UPDATE `task_variables` SET temp_value = null WHERE task_id = {self.task_id}', insert=True)
315
+ # Remove the temp values from the variables table if it exists (legacy)
316
+ try:
317
+ self.mysql.raw_query(f'UPDATE `task_variables` SET temp_value = null WHERE task_id = {self.task_id}', insert=True)
318
+ except Exception as e:
319
+ pass
313
320
 
314
321
  # Start the new task if it there is a task which should start if this one is finished
315
322
  self.start_chained_tasks(finished_task_status='SUCCESS')
316
323
 
317
324
  # Clean up execution log
318
325
  # set this date filter above the actual delete filter because of the many uncooperative quotation marks involved in the whole filter
319
- log_date_limit_filter = f"AND created_at >= \'{log_date_limit.strftime('%Y-%m-%d')}\'" if log_date_limit is not None else None
326
+ print(f"Deleting logs with filters: Date limit: {log_date_limit}, Max no. of entries: {log_limit} INFO logs")
327
+ log_date_limit_filter = f"AND created_at >= \'{log_date_limit.strftime('%Y-%m-%d')}\'" if log_date_limit is not None else ''
328
+ log_limit_filter = f"LIMIT {log_limit}" if log_limit is not None else ""
320
329
  delete_filter = f"WHERE task_id = {self.task_id} " \
330
+ f"AND log_level NOT IN ('CRITICAL', 'ERROR') " \
321
331
  f"AND reload_id NOT IN (SELECT reload_id FROM (SELECT reload_id FROM `task_execution_log` WHERE task_id = {self.task_id} " \
322
- f"AND log_level != 'CRITICAL' " \
323
- f"AND log_level != 'ERROR' " \
324
- f"{log_date_limit_filter if log_date_limit_filter is not None else ''} " \
325
- f"ORDER BY created_at DESC {f' LIMIT {log_limit} ' if log_limit is not None else ''}) temp)"
332
+ f"{log_date_limit_filter} " \
333
+ f"ORDER BY created_at DESC {log_limit_filter}) temp)"
326
334
  resp = self.mysql.delete(table="task_execution_log", filter=delete_filter)
327
335
  print(resp)
328
336
  print(f'{datetime.datetime.now()} - Task finished')
@@ -381,7 +389,7 @@ class TaskScheduler:
381
389
  logs = []
382
390
  logs.append(payload)
383
391
  with open(log_file_path, 'w') as f:
384
- json.dump(logs, f)
392
+ json.dump(logs, f, default=str)
385
393
  except Exception as e:
386
394
  print(f"Error saving log locally: {e}")
387
395
 
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: brynq_sdk_task_scheduler
3
+ Version: 4.0.8
4
+ Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
+ Author: BrynQ
6
+ Author-email: support@brynq.com
7
+ License: BrynQ License
8
+ Requires-Dist: brynq-sdk-brynq<5,>=4
9
+ Requires-Dist: brynq-sdk-functions<3,>=2
10
+ Requires-Dist: brynq-sdk-mysql<4,>=3
11
+ Requires-Dist: brynq-sdk-mandrill<4,>=2
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: description
15
+ Dynamic: license
16
+ Dynamic: requires-dist
17
+ Dynamic: summary
18
+
19
+ Code to execute tasks in the BrynQ.com platform with the task scheduler
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_task_scheduler',
5
- version='4.0.6',
5
+ version='4.0.8',
6
6
  description='Code to execute tasks in BrynQ.com with the task scheduler',
7
7
  long_description='Code to execute tasks in the BrynQ.com platform with the task scheduler',
8
8
  author='BrynQ',
@@ -1,10 +0,0 @@
1
- Metadata-Version: 1.0
2
- Name: brynq_sdk_task_scheduler
3
- Version: 4.0.6
4
- Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
- Home-page: UNKNOWN
6
- Author: BrynQ
7
- Author-email: support@brynq.com
8
- License: BrynQ License
9
- Description: Code to execute tasks in the BrynQ.com platform with the task scheduler
10
- Platform: UNKNOWN
@@ -1,10 +0,0 @@
1
- Metadata-Version: 1.0
2
- Name: brynq-sdk-task-scheduler
3
- Version: 4.0.6
4
- Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
- Home-page: UNKNOWN
6
- Author: BrynQ
7
- Author-email: support@brynq.com
8
- License: BrynQ License
9
- Description: Code to execute tasks in the BrynQ.com platform with the task scheduler
10
- Platform: UNKNOWN