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.
Files changed (35) hide show
  1. {shareddata-3.86.0/src/shareddata.egg-info → shareddata-4.0.0}/PKG-INFO +1 -1
  2. {shareddata-3.86.0 → shareddata-4.0.0}/setup.cfg +1 -1
  3. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/AWSKinesis.py +42 -22
  4. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Schedule.py +1 -1
  5. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/WorkerLib.py +13 -13
  6. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TimeseriesContainer.py +1 -1
  7. {shareddata-3.86.0 → shareddata-4.0.0/src/shareddata.egg-info}/PKG-INFO +1 -1
  8. {shareddata-3.86.0 → shareddata-4.0.0}/LICENSE +0 -0
  9. {shareddata-3.86.0 → shareddata-4.0.0}/README.md +0 -0
  10. {shareddata-3.86.0 → shareddata-4.0.0}/pyproject.toml +0 -0
  11. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/AWSS3.py +0 -0
  12. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/DataFrame.py +0 -0
  13. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Defaults.py +0 -0
  14. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Logger.py +0 -0
  15. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Metadata.py +0 -0
  16. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/MultiProc.py +0 -0
  17. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/RealTime.py +0 -0
  18. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/ReadLogs.py +0 -0
  19. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Scheduler.py +0 -0
  20. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/SendCommand.py +0 -0
  21. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Server.py +0 -0
  22. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/Worker.py +0 -0
  23. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Routines/__init__.py +0 -0
  24. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/SharedData.py +0 -0
  25. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/SharedNumpy.py +0 -0
  26. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Table.py +0 -0
  27. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TableIndex.py +0 -0
  28. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TableIndexJit.py +0 -0
  29. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/TimeSeries.py +0 -0
  30. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/Utils.py +0 -0
  31. {shareddata-3.86.0 → shareddata-4.0.0}/src/SharedData/__init__.py +0 -0
  32. {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/SOURCES.txt +0 -0
  33. {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/dependency_links.txt +0 -0
  34. {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/requires.txt +0 -0
  35. {shareddata-3.86.0 → shareddata-4.0.0}/src/shareddata.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shareddata
3
- Version: 3.86.0
3
+ Version: 4.0.0
4
4
  Summary: Shared Memory Database with S3 repository
5
5
  Home-page: https://github.com/jcarlitooliveira/SharedData
6
6
  Author: Jose Carlito de Oliveira Filho
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = shareddata
3
- version = 3.86.0
3
+ version = 4.0.0
4
4
  author = Jose Carlito de Oliveira Filho
5
5
  author_email = jcarlitooliveira@gmail.com
6
6
  description = Shared Memory Database with S3 repository
@@ -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
- try:
29
- session = boto3.Session(
30
- profile_name=os.environ['KINESIS_AWS_PROFILE'])
31
- if 'KINESIS_ENDPOINT_URL' in os.environ:
32
- self.datastream = session.client('kinesis',
33
- endpoint_url=os.environ['KINESIS_ENDPOINT_URL'])
34
- else:
35
- self.datastream = session.client('kinesis')
36
- except Exception:
37
- print('Kinesis client initialization failed.')
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.datastream.create_stream(
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.datastream:
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.datastream and self.stream_buffer:
88
- self.datastream.put_records(
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
- raise Exception('Logging failed check aws credentials!')
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.datastream = None
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.datastream = session.client('kinesis',
321
+ self.client = session.client('kinesis',
302
322
  endpoint_url=os.environ['KINESIS_ENDPOINT_URL'])
303
323
  else:
304
- self.datastream = session.client('kinesis')
324
+ self.client = session.client('kinesis')
305
325
  except Exception:
306
326
  print('Kinesis client initialization failed.')
307
327
 
308
328
  try:
309
- self.datastream.create_stream(
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.datastream.put_records(
346
+ self.client.put_records(
327
347
  StreamName=self.stream_name,
328
348
  Records=self.stream_buffer
329
349
  )
@@ -15,7 +15,7 @@ from datetime import datetime
15
15
  from tzlocal import get_localzone
16
16
  local_tz = pytz.timezone(str(get_localzone()))
17
17
 
18
-
18
+ #TODO: ADD STOPED STATE TO REALTIME ROUTINES
19
19
  class Schedule:
20
20
 
21
21
  def __init__(self, schedule_name):
@@ -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
- 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()
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(int))
384
+ io_obj.write(np.array([0]).astype(np.int64))
385
385
  io_obj.write(m)
386
386
  return io_obj
387
387
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shareddata
3
- Version: 3.86.0
3
+ Version: 4.0.0
4
4
  Summary: Shared Memory Database with S3 repository
5
5
  Home-page: https://github.com/jcarlitooliveira/SharedData
6
6
  Author: Jose Carlito de Oliveira Filho
File without changes
File without changes
File without changes