iker-python-common 1.0.50__tar.gz → 1.0.52__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 (83) hide show
  1. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/PKG-INFO +1 -1
  2. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/dbutils.py +33 -0
  3. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/retry.py +17 -17
  4. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/PKG-INFO +1 -1
  5. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/dbutils_test.py +14 -4
  6. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/.editorconfig +0 -0
  7. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/.github/workflows/pr.yml +0 -0
  8. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/.github/workflows/push.yml +0 -0
  9. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/.gitignore +0 -0
  10. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/MANIFEST.in +0 -0
  11. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/README.md +0 -0
  12. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/VERSION +0 -0
  13. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/pyproject.toml +0 -0
  14. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/config/config.cfg +0 -0
  15. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/csv/data.csv +0 -0
  16. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/csv/data.tsv +0 -0
  17. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.baz/file.bar.baz +0 -0
  18. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.baz/file.foo.bar +0 -0
  19. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.baz/file.foo.baz +0 -0
  20. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  21. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  22. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  23. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  24. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/file.bar +0 -0
  25. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/file.baz +0 -0
  26. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/s3utils/dir.foo/file.foo +0 -0
  27. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.baz/file.bar.baz +0 -0
  28. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.baz/file.foo.bar +0 -0
  29. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.baz/file.foo.baz +0 -0
  30. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  31. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  32. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  33. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  34. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/file.bar +0 -0
  35. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/file.baz +0 -0
  36. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/resources/unittest/shutils/dir.foo/file.foo +0 -0
  37. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/setup.cfg +0 -0
  38. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/setup.py +0 -0
  39. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/__init__.py +0 -0
  40. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/__init__.py +0 -0
  41. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/argutils.py +0 -0
  42. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/config.py +0 -0
  43. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/csv.py +0 -0
  44. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/dockerutils.py +0 -0
  45. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/dtutils.py +0 -0
  46. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/funcutils.py +0 -0
  47. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/jsonutils.py +0 -0
  48. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/logger.py +0 -0
  49. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/numutils.py +0 -0
  50. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/randutils.py +0 -0
  51. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/s3utils.py +0 -0
  52. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/sequtils.py +0 -0
  53. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/shutils.py +0 -0
  54. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/span.py +0 -0
  55. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/strutils.py +0 -0
  56. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/testutils.py +0 -0
  57. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker/common/utils/typeutils.py +0 -0
  58. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/SOURCES.txt +0 -0
  59. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/dependency_links.txt +0 -0
  60. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/not-zip-safe +0 -0
  61. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/requires.txt +0 -0
  62. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/src/iker_python_common.egg-info/top_level.txt +0 -0
  63. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_test.py +0 -0
  64. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/__init__.py +0 -0
  65. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/argutils_test.py +0 -0
  66. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/config_test.py +0 -0
  67. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/csv_test.py +0 -0
  68. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/dockerutils_test.py +0 -0
  69. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/dtutils_test.py +0 -0
  70. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/funcutils_test.py +0 -0
  71. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/jsonutils_test.py +0 -0
  72. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/logger_test.py +0 -0
  73. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/numutils_test.py +0 -0
  74. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/randutils_test.py +0 -0
  75. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/retry_test.py +0 -0
  76. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/s3utils_test.py +0 -0
  77. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/sequtils_test.py +0 -0
  78. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/shutils_test.py +0 -0
  79. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/span_test.py +0 -0
  80. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/strutils_test.py +0 -0
  81. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/testutils_test.py +0 -0
  82. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/common/utils/typeutils_test.py +0 -0
  83. {iker_python_common-1.0.50 → iker_python_common-1.0.52}/test/iker_tests/docker_fixtures.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iker-python-common
3
- Version: 1.0.50
3
+ Version: 1.0.52
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -65,6 +65,39 @@ class ConnectionMaker(object):
65
65
  self.engine_opts = engine_opts or {}
66
66
  self.session_opts = session_opts or {}
67
67
 
68
+ @staticmethod
69
+ def create(
70
+ driver: str | None = None,
71
+ host: str | None = None,
72
+ port: int | None = None,
73
+ username: str | None = None,
74
+ password: str | None = None,
75
+ database: str | None = None,
76
+ *,
77
+ engine_opts: dict[str, JsonType] | None = None,
78
+ session_opts: dict[str, JsonType] | None = None,
79
+ ):
80
+ """
81
+ Creates a new instance of ``ConnectionMaker`` using the provided parameters to construct a SQLAlchemy URL.
82
+
83
+ :param driver: Optional database driver.
84
+ :param host: The database host (e.g., 'localhost').
85
+ :param port: The database port.
86
+ :param username: The database username.
87
+ :param password: The database password.
88
+ :param database: The name of the database to connect to.
89
+ :param engine_opts: Optional dictionary of SQLAlchemy engine options.
90
+ :param session_opts: Optional dictionary of SQLAlchemy session options.
91
+ """
92
+ return ConnectionMaker(sqlalchemy.URL.create(drivername=driver,
93
+ host=host,
94
+ port=port,
95
+ username=username,
96
+ password=password,
97
+ database=database),
98
+ engine_opts=engine_opts,
99
+ session_opts=session_opts)
100
+
68
101
  @staticmethod
69
102
  def from_url(
70
103
  url: str | sqlalchemy.URL,
@@ -1,9 +1,9 @@
1
1
  import abc
2
- import datetime
3
2
  import random
4
3
  import time
5
4
 
6
5
  from iker.common.utils import logger
6
+ from iker.common.utils.dtutils import dt_utc_now
7
7
 
8
8
  __all__ = [
9
9
  "Attempt",
@@ -21,8 +21,8 @@ class Attempt(object):
21
21
  number: int,
22
22
  prev_wait: int,
23
23
  next_wait: int,
24
- start_time: datetime.datetime,
25
- check_time: datetime.datetime,
24
+ start_ts: float,
25
+ check_ts: float,
26
26
  last_exception: Exception,
27
27
  ):
28
28
  """
@@ -31,15 +31,15 @@ class Attempt(object):
31
31
  :param number: The attempt number (1-based).
32
32
  :param prev_wait: The wait time before the previous attempt (in seconds).
33
33
  :param next_wait: The wait time before the next attempt (in seconds).
34
- :param start_time: The start time of the first attempt.
35
- :param check_time: The time at which the current attempt is checked.
34
+ :param start_ts: The start timestamp of the first attempt.
35
+ :param check_ts: The timestamp at which the current attempt is checked.
36
36
  :param last_exception: The exception raised during the last attempt, if any.
37
37
  """
38
38
  self.number = number
39
39
  self.prev_wait = prev_wait
40
40
  self.next_wait = next_wait
41
- self.start_time = start_time
42
- self.check_time = check_time
41
+ self.start_ts = start_ts
42
+ self.check_ts = check_ts
43
43
  self.last_exception = last_exception
44
44
 
45
45
 
@@ -127,17 +127,17 @@ class RetryWrapper(object):
127
127
  else:
128
128
  return 0
129
129
 
130
- def __check_timeout(self, start_time: datetime.datetime):
130
+ def __check_timeout(self, start_ts: float) -> tuple[bool, float]:
131
131
  """
132
132
  Checks if the retry operation has exceeded the configured timeout.
133
133
 
134
- :param start_time: The start time of the first attempt.
135
- :return: Tuple (``True`` if within timeout, current time as ``datetime``).
134
+ :param start_ts: The start timestamp of the first attempt.
135
+ :return: Tuple (``True`` if within timeout, current timestamp).
136
136
  """
137
- now = datetime.datetime.now()
137
+ current_ts = dt_utc_now().timestamp()
138
138
  if self.timeout is None:
139
- return True, now
140
- return (now < start_time + datetime.timedelta(seconds=self.timeout)), now
139
+ return True, current_ts
140
+ return current_ts < start_ts + self.timeout, current_ts
141
141
 
142
142
  def __run(self, *args, **kwargs):
143
143
  """
@@ -150,13 +150,13 @@ class RetryWrapper(object):
150
150
  :raises RuntimeError: If all attempts fail or timeout is reached.
151
151
  """
152
152
  attempt_number = 0
153
- start_time = datetime.datetime.now()
153
+ start_ts = dt_utc_now().timestamp()
154
154
  last_exception = None
155
155
 
156
156
  while self.retrials is None or attempt_number <= self.retrials:
157
157
  attempt_number += 1
158
158
 
159
- check_result, check_time = self.__check_timeout(start_time)
159
+ check_result, check_ts = self.__check_timeout(start_ts)
160
160
  if not check_result:
161
161
  break
162
162
 
@@ -164,8 +164,8 @@ class RetryWrapper(object):
164
164
  attempt_number,
165
165
  self.__next_wait(attempt_number - 1),
166
166
  self.__next_wait(attempt_number),
167
- start_time,
168
- check_time,
167
+ start_ts,
168
+ check_ts,
169
169
  last_exception,
170
170
  )
171
171
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iker-python-common
3
- Version: 1.0.50
3
+ Version: 1.0.52
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -225,8 +225,13 @@ def test_mysql_connection_maker__sql_text(fixture_mysql_test_proc, fixture_mysql
225
225
  user = fixture_mysql_test_proc.user
226
226
  database = "test"
227
227
 
228
- maker = ConnectionMaker.from_url(f"{scheme}://{user}@{host}:{port}/{database}",
229
- session_opts=dict(expire_on_commit=False))
228
+ maker = ConnectionMaker.create(scheme,
229
+ host,
230
+ port,
231
+ user,
232
+ None,
233
+ database,
234
+ session_opts=dict(expire_on_commit=False))
230
235
 
231
236
  maker.create_model(MysqlBaseModel)
232
237
 
@@ -655,8 +660,13 @@ def test_postgresql_connection_maker__sql_text(fixture_postgresql_test_proc, fix
655
660
  user = fixture_postgresql_test.info.user
656
661
  database = fixture_postgresql_test.info.dbname
657
662
 
658
- maker = ConnectionMaker.from_url(f"{scheme}://{user}@{host}:{port}/{database}",
659
- session_opts=dict(expire_on_commit=False))
663
+ maker = ConnectionMaker.create(scheme,
664
+ host,
665
+ port,
666
+ user,
667
+ None,
668
+ database,
669
+ session_opts=dict(expire_on_commit=False))
660
670
 
661
671
  maker.create_model(PostgresqlBaseModel)
662
672