brynq-sdk-task-scheduler 4.0.3__tar.gz → 4.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_task_scheduler
3
- Version: 4.0.3
3
+ Version: 4.0.5
4
4
  Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -12,7 +12,6 @@ import requests
12
12
  from brynq_sdk_mandrill import MailClient
13
13
  from brynq_sdk_functions import Functions
14
14
  from brynq_sdk_mysql import MySQL
15
- from brynq_sdk_elastic import Elastic
16
15
  from brynq_sdk_brynq import BrynQ
17
16
  import warnings
18
17
  import re
@@ -32,7 +31,7 @@ class TaskScheduler:
32
31
  """
33
32
  # If the task is started via the task_scheduler, the following parameters will be passed by the scheduler.
34
33
  # The distinction between local and non local is made because the scheduler usually sets the scheduler_log table entry and run_id. When running locally, the tasks will not log anything by default.
35
- if any(flag in sys.argv[0].split('/') for flag in ['opt', 'home']):
34
+ if any(flag in sys.argv[0].split('/') for flag in ['opt', 'home', 'Users']):
36
35
  self.started_local = True
37
36
  self.run_id = int(round(time.time() * 100000))
38
37
  self.task_id = None
@@ -40,13 +39,11 @@ class TaskScheduler:
40
39
  # set it into environment variables for reuse in source and target systems
41
40
  os.environ['DATA_INTERFACE_ID'] = str(self.data_interface_id)
42
41
  self.mysql_enabled = False
43
- self.elastic_enabled = False
44
42
  print("You're running locally, so your task won't be started in the platform and logs won't be saved")
45
43
  else:
46
44
  self.started_local = False
47
45
  self.customer_db, self.task_id, self.run_id, self.data_interface_id = sys.argv[1:5]
48
46
  self.mysql_enabled = True
49
- self.elastic_enabled = True
50
47
  # If the task is started locally, the parameters should be set locally
51
48
 
52
49
  print(f"Run ID: {self.run_id}, Data Interface ID: {self.data_interface_id}, Task ID: {self.task_id}, Started Locally: {self.started_local}")
@@ -142,12 +139,11 @@ class TaskScheduler:
142
139
 
143
140
  return variable
144
141
 
145
- def write_execution_log(self, message: str, data, loglevel: str = 'INFO', full_extract: bool = False):
142
+ def write_execution_log(self, message: str, data = None, loglevel: str = 'INFO', full_extract: bool = False):
146
143
  """
147
144
  Writes messages to the database. Give the message and the level of the log
148
145
  :param message: A string with a message for the log
149
146
  :param loglevel: You can choose between DEBUG, INFO, ERROR or CRITICAL (DEBUG is most granulated, CRITICAL the less)
150
- :param data: Uploaded data by the interface that has to be logged in ElasticSearch, if you have nothing to log, use None
151
147
  :param full_extract: If the data is a full load, set this to True. This will prevent the payload from being logged in ElasticSearch
152
148
  :return: If writing to the database is successful or not
153
149
  """
@@ -370,7 +366,6 @@ class TaskScheduler:
370
366
  MailClient().send_mail(email_to=email_list, subject=subject, content=content, language='EN')
371
367
 
372
368
  def _save_log_locally(self, payload, system):
373
- # system is 'mysql' or 'elastic'
374
369
  log_file_path = os.path.join(self.local_log_dir, f'{system}_log_{self.run_id}.json')
375
370
  try:
376
371
  if os.path.exists(log_file_path):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-task-scheduler
3
- Version: 4.0.3
3
+ Version: 4.0.5
4
4
  Summary: Code to execute tasks in BrynQ.com with the task scheduler
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -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.3',
5
+ version='4.0.5',
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',