shareddata 3.86.0__tar.gz → 4.0.0__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.
- {shareddata-3.86.0/src/shareddata.egg-info → shareddata-4.0.0}/PKG-INFO +1 -1
- {shareddata-3.86.0 → shareddata-4.0.0}/setup.cfg +1 -1
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/AWSKinesis.py +42 -22
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Schedule.py +1 -1
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/WorkerLib.py +13 -13
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TimeseriesContainer.py +1 -1
- {shareddata-3.86.0 → shareddata-4.0.0/src/shareddata.egg-info}/PKG-INFO +1 -1
- {shareddata-3.86.0 → shareddata-4.0.0}/LICENSE +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/README.md +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/pyproject.toml +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/AWSS3.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/DataFrame.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Defaults.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Logger.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Metadata.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/MultiProc.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/RealTime.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/ReadLogs.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Scheduler.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/SendCommand.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Server.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Worker.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/__init__.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/SharedData.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/SharedNumpy.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Table.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TableIndex.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TableIndexJit.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TimeSeries.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Utils.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/__init__.py +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/SOURCES.txt +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/dependency_links.txt +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/requires.txt +0 -0
- {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/top_level.txt +0 -0
|
@@ -22,23 +22,39 @@ class KinesisLogStreamHandler(logging.StreamHandler):
|
|
|
22
22
|
logging.StreamHandler.__init__(self)
|
|
23
23
|
|
|
24
24
|
self.user = user
|
|
25
|
-
self.datastream = None
|
|
26
25
|
self.stream_buffer = []
|
|
26
|
+
self.client = None
|
|
27
|
+
self.stream_name = os.environ['LOG_STREAMNAME']
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
if not self.get_client():
|
|
30
|
+
raise Exception('Logging failed check aws credentials!')
|
|
31
|
+
|
|
32
|
+
self.create_stream()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_client(self):
|
|
36
|
+
success = False
|
|
37
|
+
trials = 3
|
|
38
|
+
while trials>0:
|
|
39
|
+
trials-=1
|
|
40
|
+
try:
|
|
41
|
+
session = boto3.Session(
|
|
42
|
+
profile_name=os.environ['KINESIS_AWS_PROFILE'])
|
|
43
|
+
if 'KINESIS_ENDPOINT_URL' in os.environ:
|
|
44
|
+
self.client = session.client('kinesis',
|
|
45
|
+
endpoint_url=os.environ['KINESIS_ENDPOINT_URL'])
|
|
46
|
+
else:
|
|
47
|
+
self.client = session.client('kinesis')
|
|
48
|
+
success = True
|
|
49
|
+
except Exception:
|
|
50
|
+
time.sleep(1)
|
|
51
|
+
pass
|
|
52
|
+
return success
|
|
53
|
+
|
|
54
|
+
def create_stream(self):
|
|
38
55
|
|
|
39
|
-
self.stream_name = os.environ['LOG_STREAMNAME']
|
|
40
56
|
try:
|
|
41
|
-
self.
|
|
57
|
+
self.client.create_stream(
|
|
42
58
|
StreamName=self.stream_name,
|
|
43
59
|
ShardCount=1,
|
|
44
60
|
StreamModeDetails={
|
|
@@ -49,6 +65,7 @@ class KinesisLogStreamHandler(logging.StreamHandler):
|
|
|
49
65
|
except Exception as e:
|
|
50
66
|
pass
|
|
51
67
|
|
|
68
|
+
|
|
52
69
|
def emit(self, record):
|
|
53
70
|
try:
|
|
54
71
|
# msg = self.format(record)
|
|
@@ -67,7 +84,7 @@ class KinesisLogStreamHandler(logging.StreamHandler):
|
|
|
67
84
|
# 'file_name': record.filename,
|
|
68
85
|
}
|
|
69
86
|
msg = json.dumps(msg)
|
|
70
|
-
if self.
|
|
87
|
+
if self.client:
|
|
71
88
|
self.stream_buffer.append({
|
|
72
89
|
'Data': str(msg).encode(encoding="UTF-8", errors="strict"),
|
|
73
90
|
'PartitionKey': user,
|
|
@@ -84,8 +101,8 @@ class KinesisLogStreamHandler(logging.StreamHandler):
|
|
|
84
101
|
def flush(self):
|
|
85
102
|
self.acquire()
|
|
86
103
|
try:
|
|
87
|
-
if self.
|
|
88
|
-
self.
|
|
104
|
+
if self.client and self.stream_buffer:
|
|
105
|
+
self.client.put_records(
|
|
89
106
|
StreamName=self.stream_name,
|
|
90
107
|
Records=self.stream_buffer
|
|
91
108
|
)
|
|
@@ -95,7 +112,10 @@ class KinesisLogStreamHandler(logging.StreamHandler):
|
|
|
95
112
|
print("An error occurred during flush operation.")
|
|
96
113
|
print(f"Exception: {e}")
|
|
97
114
|
print(f"Stream buffer: {self.stream_buffer}")
|
|
98
|
-
|
|
115
|
+
|
|
116
|
+
if not self.get_client():
|
|
117
|
+
raise Exception('Logging failed check aws credentials!')
|
|
118
|
+
|
|
99
119
|
finally:
|
|
100
120
|
if self.stream and hasattr(self.stream, "flush"):
|
|
101
121
|
self.stream.flush()
|
|
@@ -292,21 +312,21 @@ class KinesisLogStreamConsumer():
|
|
|
292
312
|
class KinesisStreamProducer():
|
|
293
313
|
def __init__(self, stream_name):
|
|
294
314
|
self.stream_name = stream_name
|
|
295
|
-
self.
|
|
315
|
+
self.client = None
|
|
296
316
|
self.stream_buffer = []
|
|
297
317
|
try:
|
|
298
318
|
session = boto3.Session(
|
|
299
319
|
profile_name=os.environ['KINESIS_AWS_PROFILE'])
|
|
300
320
|
if 'KINESIS_ENDPOINT_URL' in os.environ:
|
|
301
|
-
self.
|
|
321
|
+
self.client = session.client('kinesis',
|
|
302
322
|
endpoint_url=os.environ['KINESIS_ENDPOINT_URL'])
|
|
303
323
|
else:
|
|
304
|
-
self.
|
|
324
|
+
self.client = session.client('kinesis')
|
|
305
325
|
except Exception:
|
|
306
326
|
print('Kinesis client initialization failed.')
|
|
307
327
|
|
|
308
328
|
try:
|
|
309
|
-
self.
|
|
329
|
+
self.client.create_stream(
|
|
310
330
|
StreamName=stream_name,
|
|
311
331
|
ShardCount=1,
|
|
312
332
|
StreamModeDetails={
|
|
@@ -323,7 +343,7 @@ class KinesisStreamProducer():
|
|
|
323
343
|
'Data': str(_rec).encode(encoding="UTF-8", errors="strict"),
|
|
324
344
|
'PartitionKey': partitionkey,
|
|
325
345
|
})
|
|
326
|
-
self.
|
|
346
|
+
self.client.put_records(
|
|
327
347
|
StreamName=self.stream_name,
|
|
328
348
|
Records=self.stream_buffer
|
|
329
349
|
)
|
|
@@ -530,20 +530,20 @@ def process_command(command):
|
|
|
530
530
|
kill_routine(command)
|
|
531
531
|
|
|
532
532
|
elif command['job'] == 'restart':
|
|
533
|
-
kill_routine(command)
|
|
533
|
+
if kill_routine(command):
|
|
534
534
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
535
|
+
start_time = time.time()
|
|
536
|
+
routine = {
|
|
537
|
+
'command': command,
|
|
538
|
+
'thread': None,
|
|
539
|
+
'process': None,
|
|
540
|
+
'start_time': start_time,
|
|
541
|
+
}
|
|
542
|
+
thread = Thread(target=run_routine,
|
|
543
|
+
args=(command, routine))
|
|
544
|
+
routine['thread'] = thread
|
|
545
|
+
routines.append(routine)
|
|
546
|
+
thread.start()
|
|
547
547
|
|
|
548
548
|
elif command['job'] == 'status':
|
|
549
549
|
|
|
@@ -381,7 +381,7 @@ class TimeseriesContainer:
|
|
|
381
381
|
io_obj.write(np.ascontiguousarray(df.values.astype(np.float64)))
|
|
382
382
|
|
|
383
383
|
m = hashlib.md5(io_obj.getvalue()).digest()
|
|
384
|
-
io_obj.write(np.array([0]).astype(
|
|
384
|
+
io_obj.write(np.array([0]).astype(np.int64))
|
|
385
385
|
io_obj.write(m)
|
|
386
386
|
return io_obj
|
|
387
387
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|