python-sdk-remote 0.0.128__tar.gz → 0.0.130__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.

Potentially problematic release.


This version of python-sdk-remote might be problematic. Click here for more details.

Files changed (21) hide show
  1. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/PKG-INFO +1 -1
  2. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/http_response.py +7 -3
  3. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/item.py +3 -0
  4. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/mini_logger.py +5 -2
  5. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/our_object.py +3 -0
  6. python_sdk_remote-0.0.130/python_sdk_remote/src/temp.py +18 -0
  7. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/unified_json.py +4 -0
  8. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/utilities.py +25 -15
  9. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote.egg-info/PKG-INFO +1 -1
  10. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote.egg-info/SOURCES.txt +1 -0
  11. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/setup.py +1 -1
  12. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/README.md +0 -0
  13. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/pyproject.toml +0 -0
  14. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/__init__.py +0 -0
  15. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/constants.py +0 -0
  16. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/valid_json_versions.py +0 -0
  17. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote/src/validate_environment.py +0 -0
  18. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  19. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote.egg-info/requires.txt +0 -0
  20. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/python_sdk_remote.egg-info/top_level.txt +0 -0
  21. {python_sdk_remote-0.0.128 → python_sdk_remote-0.0.130}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.128
3
+ Version: 0.0.130
4
4
  Summary: PyPI Package for Circles Python SDK Local Python
5
5
  Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
6
6
  Author: Circles
@@ -1,21 +1,25 @@
1
1
  import traceback
2
+ from datetime import date
2
3
  from functools import wraps
3
4
  from http import HTTPStatus
4
5
  from typing import Any
5
6
 
6
7
  from .mini_logger import MiniLogger as logger
8
+ from .temp import deprecation_warning
7
9
  from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
8
10
 
9
11
  HEADERS_KEY = 'headers'
10
12
  AUTHORIZATION_KEY = 'authorization'
11
13
  AUTHORIZATION_PREFIX = 'Bearer '
12
14
 
15
+ # TODO: move date(2024, 6, 5) to constants and use it everywhere
16
+ deprecation_warning("http_response", "DELETE", date(2024, 6, 5))
17
+
13
18
 
14
19
  # TODO Align those methods with typescript-sdk https://github.com/circles-zone/typescript-sdk-remote-typescript-package/blob/dev/typescript-sdk/src/utils/index.ts
15
20
  # TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
16
21
 
17
- # TODO: add handler wrapper?
18
-
22
+ # TODO Shall we add the word body? i.e. get_body_payload_dict_from_event()
19
23
  def get_payload_dict_from_event(event: dict) -> dict:
20
24
  """Extracts params sent with payload"""
21
25
  return to_dict(event.get('body'))
@@ -77,7 +81,7 @@ def handler_decorator(logger):
77
81
  # TODO: should we auto detect user_jwt if not provided?
78
82
  def create_authorization_http_headers(user_jwt: str) -> dict:
79
83
  logger.start(object={"user_jwt": user_jwt})
80
- #TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
84
+ # TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
81
85
  authorization_http_headers = {
82
86
  'Content-Type': 'application/json',
83
87
  'Authorization': AUTHORIZATION_PREFIX + user_jwt,
@@ -1,10 +1,13 @@
1
1
  from abc import abstractmethod
2
+ from datetime import date
2
3
 
3
4
  from .our_object import OurObject
5
+ from .temp import deprecation_warning
4
6
 
5
7
 
6
8
  class Item(OurObject):
7
9
  def __init__(self, **kwargs):
10
+ deprecation_warning("item", "DELETE", date(2024, 6, 5))
8
11
  super().__init__(**kwargs)
9
12
 
10
13
  @abstractmethod
@@ -2,7 +2,10 @@ import logging
2
2
  import os
3
3
  import sys
4
4
 
5
- LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
5
+ # Try to get MINI_LOGGER_MINIMUM_SEVERITY from the environment, if not found, try to get LOGGER_MINIMUM_SEVERITY
6
+ # If not found, default to INFO
7
+ LOGGER_MINIMUM_SEVERITY = os.getenv("MINI_LOGGER_MINIMUM_SEVERITY",
8
+ os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO")).upper()
6
9
  # logging expects NOTSET/DEBUG/INFO/WARNING/ERROR/FATAL/CRITICAL
7
10
  if LOGGER_MINIMUM_SEVERITY.isdigit():
8
11
  logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
@@ -25,7 +28,7 @@ logger = logging.getLogger(__name__)
25
28
 
26
29
  class MiniLogger:
27
30
  # TODO Can we so one generic function call by all
28
-
31
+ # TODO: print the caller function name
29
32
  @staticmethod
30
33
  def start(message: str = "", object: dict = None):
31
34
  """
@@ -1,12 +1,15 @@
1
1
  import json
2
2
  from abc import ABC, abstractmethod
3
+ from datetime import date
3
4
 
4
5
  from .mini_logger import MiniLogger as logger
6
+ from .temp import deprecation_warning
5
7
 
6
8
 
7
9
  # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
8
10
  class OurObject(ABC):
9
11
  def __init__(self, **kwargs):
12
+ deprecation_warning("our_object", "DELETE", date(2024, 6, 5))
10
13
  INIT_METHOD_NAME = '__init__'
11
14
  logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
12
15
  self.kwargs = kwargs
@@ -0,0 +1,18 @@
1
+ # TODO: remove once all breaking changes related to deprecation are done
2
+ import inspect
3
+ from datetime import date
4
+ from functools import lru_cache
5
+
6
+ from .mini_logger import MiniLogger as logger
7
+
8
+
9
+ @lru_cache(maxsize=64) # don't print the same warning multiple times
10
+ def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
11
+ if start_date and start_date < date.today():
12
+ return
13
+ warnings_message = f"{new_name} {old_name} and use the local version."
14
+ try:
15
+ warnings_message += " Called from: " + inspect.stack()[2].filename
16
+ except Exception:
17
+ pass
18
+ logger.warning(warnings_message)
@@ -1,9 +1,13 @@
1
+ from datetime import date
2
+
3
+ from .temp import deprecation_warning
1
4
  from .valid_json_versions import valid_json_versions
2
5
 
3
6
 
4
7
  # TODO Shall we merge it with the machine-learning-unified-json?
5
8
  class UnifiedJson:
6
9
  def __init__(self, data: dict, json_version: str):
10
+ deprecation_warning("unified_json", "DELETE", date(2024, 6, 5))
7
11
  if json_version not in valid_json_versions:
8
12
  raise Exception(
9
13
  f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
@@ -1,10 +1,8 @@
1
- import inspect
2
1
  import json
3
2
  import os
4
3
  import random
5
4
  import re
6
5
  from datetime import date, datetime, time, timedelta, timezone
7
- from functools import lru_cache
8
6
  from urllib.parse import urlparse
9
7
 
10
8
  import jwt
@@ -13,6 +11,7 @@ from dotenv import load_dotenv
13
11
  from url_remote.environment_name_enum import EnvironmentName
14
12
 
15
13
  from .mini_logger import MiniLogger as logger
14
+ from .temp import deprecation_warning
16
15
 
17
16
  load_dotenv()
18
17
  # TODO Let's do brainstorming on this
@@ -33,19 +32,22 @@ DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
33
32
 
34
33
 
35
34
  def append_if_not_exist(lst: list, item: object) -> None:
35
+ deprecation_warning("append_if_not_exist", "DELETE", date(2024, 6, 5))
36
36
  if item not in lst:
37
37
  lst.append(item)
38
38
 
39
39
 
40
40
  def to_dict(data: json or dict or None) -> dict:
41
+ deprecation_warning("to_dict", "DELETE", date(2024, 6, 5))
41
42
  if data is None:
42
43
  return {}
43
44
  if isinstance(data, dict):
44
45
  return data
45
- return json.loads(data)
46
+ return json.loads(data) # TODO: replace all `return statement` with `return identifier`
46
47
 
47
48
 
48
49
  def to_json(data: json or dict or None) -> json:
50
+ deprecation_warning("to_json", "DELETE", date(2024, 6, 5))
49
51
  if data is None:
50
52
  data = {}
51
53
  if isinstance(data, dict):
@@ -54,6 +56,7 @@ def to_json(data: json or dict or None) -> json:
54
56
 
55
57
 
56
58
  def timedelta_to_time_format(time_delta: timedelta) -> str:
59
+ deprecation_warning("timedelta_to_time_format", "DELETE", date(2024, 6, 5))
57
60
  """
58
61
  Convert a timedelta to a time format in HH:MM:SS.
59
62
 
@@ -90,6 +93,7 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
90
93
 
91
94
 
92
95
  def is_valid_time_range(time_range: tuple) -> bool:
96
+ deprecation_warning("is_valid_time_range", "DELETE", date(2024, 6, 5))
93
97
  """
94
98
  Validate that the time range is in the format 'HH:MM:SS'.
95
99
  """
@@ -116,6 +120,7 @@ def is_valid_time_range(time_range: tuple) -> bool:
116
120
  # TODO shall we also use Url type and not only str? - Strongly Type which I prefer
117
121
  # (if yes we should change it also in all the calls to this function)
118
122
  def validate_url(url: str):
123
+ deprecation_warning("validate_url", "DELETE", date(2024, 6, 5))
119
124
  logger.start(object={"url": url})
120
125
  if url is not None or url != "":
121
126
  parsed_url = urlparse(url)
@@ -127,6 +132,7 @@ def validate_url(url: str):
127
132
 
128
133
 
129
134
  def is_valid_date_range(date_range: tuple) -> bool:
135
+ deprecation_warning("is_valid_date_range", "DELETE", date(2024, 6, 5))
130
136
  """
131
137
  Validate that the date range is in the format 'YYYY-MM-DD'.
132
138
  """
@@ -145,6 +151,7 @@ def is_valid_date_range(date_range: tuple) -> bool:
145
151
 
146
152
 
147
153
  def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
154
+ deprecation_warning("is_valid_datetime_range", "DELETE", date(2024, 6, 5))
148
155
  """
149
156
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
150
157
  """
@@ -162,6 +169,7 @@ def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
162
169
 
163
170
 
164
171
  def is_list_of_dicts(obj: object) -> bool:
172
+ deprecation_warning("is_list_of_dicts", "DELETE", date(2024, 6, 5))
165
173
  """
166
174
  Check if an object is a list of dictionaries.
167
175
 
@@ -206,6 +214,7 @@ def is_list_of_dicts(obj: object) -> bool:
206
214
 
207
215
 
208
216
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
217
+ deprecation_warning("is_time_in_time_range", "DELETE", date(2024, 6, 5))
209
218
  """
210
219
  Check if the given time is within the specified time range.
211
220
 
@@ -229,6 +238,7 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
229
238
 
230
239
 
231
240
  def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
241
+ deprecation_warning("is_date_in_date_range", "DELETE", date(2024, 6, 5))
232
242
  """
233
243
  Check if the given date is within the specified date range.
234
244
 
@@ -253,6 +263,7 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
253
263
 
254
264
 
255
265
  def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
266
+ deprecation_warning("is_datetime_in_datetime_range", "DELETE", date(2024, 6, 5))
256
267
  """
257
268
  Check if the given datetime is within the specified datetime range.
258
269
 
@@ -316,6 +327,7 @@ def get_dialog_jwt_secret_key() -> str:
316
327
 
317
328
 
318
329
  def encode_jwt(payload: dict, key: str) -> str:
330
+ deprecation_warning("encode_jwt", "DELETE", date(2024, 6, 5))
319
331
  """Example:
320
332
  payload = {
321
333
  "user_id": 123,
@@ -327,6 +339,7 @@ def encode_jwt(payload: dict, key: str) -> str:
327
339
 
328
340
 
329
341
  def decode_jwt(token: str, key: str) -> dict:
342
+ deprecation_warning("decode_jwt", "DELETE", date(2024, 6, 5))
330
343
  """key can be private / public"""
331
344
  return jwt.decode(token, key, algorithms=['HS256'])
332
345
 
@@ -362,29 +375,35 @@ def obfuscate_log_dict(log_dict: dict) -> dict:
362
375
  # TODO: add tests to the following functions
363
376
 
364
377
  def remove_digits(text: str) -> str:
378
+ deprecation_warning("remove_digits", "DELETE", date(2024, 6, 5))
365
379
  return ''.join(i for i in text if not i.isdigit())
366
380
 
367
381
 
368
382
  def generate_otp():
383
+ deprecation_warning("generate_otp", "DELETE", date(2024, 6, 5))
369
384
  """Generates a 6-digit OTP"""
370
385
  otp = random.randint(100000, 999999)
371
386
  return otp
372
387
 
373
388
 
374
389
  def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT, tz: timezone = None) -> str:
390
+ deprecation_warning("get_current_datetime_string", "DELETE", date(2024, 6, 5))
375
391
  current_datetime_string = datetime.now(tz).strftime(datetime_format)
376
392
  return current_datetime_string
377
393
 
378
394
 
379
395
  def datetime_from_str(date_str: str, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> datetime:
396
+ deprecation_warning("datetime_from_str", "DELETE", date(2024, 6, 5))
380
397
  return datetime.strptime(date_str, datetime_format)
381
398
 
382
399
 
383
400
  def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> str:
401
+ deprecation_warning("datetime_to_str", "DELETE", date(2024, 6, 5))
384
402
  return input_datetime.strftime(datetime_format)
385
403
 
386
404
 
387
405
  def validate_arguments(args: dict) -> None:
406
+ deprecation_warning("validate_arguments", "DELETE", date(2024, 6, 5))
388
407
  """
389
408
  Validate method arguments to ensure they are not None or ''
390
409
  :param args: arguments to be validated (usually locals())
@@ -396,6 +415,7 @@ def validate_arguments(args: dict) -> None:
396
415
 
397
416
 
398
417
  def reformat_time_string(input_str: str) -> str:
418
+ deprecation_warning("reformat_time_string", "DELETE", date(2024, 6, 5))
399
419
  """Example:
400
420
  "1234" -> "12:34:00:00"
401
421
  """
@@ -409,10 +429,12 @@ def reformat_time_string(input_str: str) -> str:
409
429
 
410
430
 
411
431
  def get_ip_v4():
432
+ deprecation_warning("get_ip_v4", "DELETE", date(2024, 6, 5))
412
433
  return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
413
434
 
414
435
 
415
436
  def get_ip_v6():
437
+ deprecation_warning("get_ip_v6", "DELETE", date(2024, 6, 5))
416
438
  return requests.get('https://api.seeip.org/jsonip').json()['ip']
417
439
 
418
440
 
@@ -427,15 +449,3 @@ def camel_to_snake(camel_str: str) -> str:
427
449
  """Converts camelCase to snake_case."""
428
450
  snake_str = re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
429
451
  return snake_str
430
-
431
-
432
- @lru_cache(maxsize=64) # don't print the same warning multiple times
433
- def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
434
- if start_date and start_date < date.today():
435
- return
436
- warnings_message = f"Please use {old_name} instead of {new_name}."
437
- try:
438
- warnings_message += " Called from: " + inspect.stack()[2].filename
439
- except Exception:
440
- pass
441
- logger.warning(warnings_message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.128
3
+ Version: 0.0.130
4
4
  Summary: PyPI Package for Circles Python SDK Local Python
5
5
  Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
6
6
  Author: Circles
@@ -12,6 +12,7 @@ python_sdk_remote/src/http_response.py
12
12
  python_sdk_remote/src/item.py
13
13
  python_sdk_remote/src/mini_logger.py
14
14
  python_sdk_remote/src/our_object.py
15
+ python_sdk_remote/src/temp.py
15
16
  python_sdk_remote/src/unified_json.py
16
17
  python_sdk_remote/src/utilities.py
17
18
  python_sdk_remote/src/valid_json_versions.py
@@ -7,7 +7,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
7
7
  # python -m build needs pyproject.toml or setup.py
8
8
  setuptools.setup(
9
9
  name=PACKAGE_NAME,
10
- version='0.0.128', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.130', # https://pypi.org/project/python-sdk-remote/
11
11
  author="Circles",
12
12
  author_email="info@circlez.ai",
13
13
  description="PyPI Package for Circles Python SDK Local Python",