brynq-sdk-task-scheduler 4.0.4__tar.gz → 4.0.6__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.
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/PKG-INFO +1 -1
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler/task_scheduler.py +7 -6
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/PKG-INFO +1 -1
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/setup.py +1 -1
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler/__init__.py +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/not-zip-safe +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/requires.txt +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/brynq_sdk_task_scheduler.egg-info/top_level.txt +0 -0
- {brynq_sdk_task_scheduler-4.0.4 → brynq_sdk_task_scheduler-4.0.6}/setup.cfg +0 -0
|
@@ -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
|
|
@@ -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}")
|
|
@@ -72,6 +69,12 @@ class TaskScheduler:
|
|
|
72
69
|
self.mysql_reachable = True
|
|
73
70
|
try:
|
|
74
71
|
self.mysql = MySQL()
|
|
72
|
+
# override connection credentials always because they mightve been retrieved from an interface credential
|
|
73
|
+
self.mysql.host = os.getenv("MYSQL_HOST")
|
|
74
|
+
self.mysql.user = os.getenv("MYSQL_USER")
|
|
75
|
+
self.mysql.password = os.getenv("MYSQL_PASSWORD")
|
|
76
|
+
self.mysql.database = os.getenv("MYSQL_DATABASE")
|
|
77
|
+
self.mysql.port = 3306 if os.getenv("MYSQL_PORT") is None else int(os.getenv("MYSQL_PORT"))
|
|
75
78
|
self.mysql.ping()
|
|
76
79
|
except Exception as e:
|
|
77
80
|
self.mysql_reachable = False
|
|
@@ -142,12 +145,11 @@ class TaskScheduler:
|
|
|
142
145
|
|
|
143
146
|
return variable
|
|
144
147
|
|
|
145
|
-
def write_execution_log(self, message: str, data, loglevel: str = 'INFO', full_extract: bool = False):
|
|
148
|
+
def write_execution_log(self, message: str, data = None, loglevel: str = 'INFO', full_extract: bool = False):
|
|
146
149
|
"""
|
|
147
150
|
Writes messages to the database. Give the message and the level of the log
|
|
148
151
|
:param message: A string with a message for the log
|
|
149
152
|
: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
153
|
: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
154
|
:return: If writing to the database is successful or not
|
|
153
155
|
"""
|
|
@@ -370,7 +372,6 @@ class TaskScheduler:
|
|
|
370
372
|
MailClient().send_mail(email_to=email_list, subject=subject, content=content, language='EN')
|
|
371
373
|
|
|
372
374
|
def _save_log_locally(self, payload, system):
|
|
373
|
-
# system is 'mysql' or 'elastic'
|
|
374
375
|
log_file_path = os.path.join(self.local_log_dir, f'{system}_log_{self.run_id}.json')
|
|
375
376
|
try:
|
|
376
377
|
if os.path.exists(log_file_path):
|
|
@@ -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.
|
|
5
|
+
version='4.0.6',
|
|
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',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|