commons-metrics 0.0.26__py3-none-any.whl → 0.0.28__py3-none-any.whl
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.
- commons_metrics/__init__.py +1 -1
- commons_metrics/github_api_client.py +7 -4
- commons_metrics/repositories.py +2 -8
- {commons_metrics-0.0.26.dist-info → commons_metrics-0.0.28.dist-info}/METADATA +1 -1
- {commons_metrics-0.0.26.dist-info → commons_metrics-0.0.28.dist-info}/RECORD +8 -8
- {commons_metrics-0.0.26.dist-info → commons_metrics-0.0.28.dist-info}/WHEEL +0 -0
- {commons_metrics-0.0.26.dist-info → commons_metrics-0.0.28.dist-info}/licenses/LICENSE +0 -0
- {commons_metrics-0.0.26.dist-info → commons_metrics-0.0.28.dist-info}/top_level.txt +0 -0
commons_metrics/__init__.py
CHANGED
|
@@ -12,4 +12,4 @@ from .text_simplifier import TextSimplifier
|
|
|
12
12
|
from .variable_finder import VariableFinder
|
|
13
13
|
|
|
14
14
|
__all__ = ['Util', 'DatabaseConnection', 'ComponentRepository', 'UpdateDesignSystemComponents', 'GitHubAPIClient', 'AzureDevOpsClient', 'S3FileManager', 'CacheManager', 'CommonsReposClient', 'DateUtils', 'TextSimplifier', 'VariableFinder']
|
|
15
|
-
__version__ = '0.0.
|
|
15
|
+
__version__ = '0.0.28'
|
|
@@ -10,14 +10,15 @@ from .commons_repos_client import CommonsReposClient
|
|
|
10
10
|
class RateLimiter:
|
|
11
11
|
"""
|
|
12
12
|
Controla el rate limiting para respetar los límites de API de GitHub.
|
|
13
|
-
GitHub permite
|
|
13
|
+
GitHub App permite 15000 requests/hora autenticados = ~4.17 TPS.
|
|
14
|
+
Personal Access Token: 5000 requests/hora = ~1.4 TPS.
|
|
14
15
|
|
|
15
16
|
Estrategia adaptativa:
|
|
16
17
|
1. Cuando está cerca del límite (>90%), aumenta delays si falta >10min para reset
|
|
17
18
|
2. Si faltan <10min para reset, reduce delay a 10ms para usar toda la cuota
|
|
18
19
|
3. Exponential backoff solo para errores 403/429 de rate limit
|
|
19
20
|
"""
|
|
20
|
-
def __init__(self, delay: float = 0.
|
|
21
|
+
def __init__(self, delay: float = 0.24, token: str = None):
|
|
21
22
|
self.base_delay = delay
|
|
22
23
|
self.current_delay = delay
|
|
23
24
|
self.last_request_time = 0
|
|
@@ -104,7 +105,9 @@ class RateLimiter:
|
|
|
104
105
|
class GitHubAPIClient:
|
|
105
106
|
"""
|
|
106
107
|
Cliente para interactuar con la API de GitHub con rate limiting integrado.
|
|
107
|
-
Controla automáticamente el TPS para no exceder los límites de GitHub
|
|
108
|
+
Controla automáticamente el TPS para no exceder los límites de GitHub:
|
|
109
|
+
- GitHub App: 15000 req/hora (~4.17 TPS)
|
|
110
|
+
- Personal Token: 5000 req/hora (~1.4 TPS)
|
|
108
111
|
|
|
109
112
|
Incluye:
|
|
110
113
|
- Rate limiting adaptativo (ajusta delays según uso)
|
|
@@ -137,7 +140,7 @@ class GitHubAPIClient:
|
|
|
137
140
|
|
|
138
141
|
# Inicializar rate limiter compartido con token
|
|
139
142
|
if GitHubAPIClient._rate_limiter is None:
|
|
140
|
-
GitHubAPIClient._rate_limiter = RateLimiter(delay=0.
|
|
143
|
+
GitHubAPIClient._rate_limiter = RateLimiter(delay=0.24, token=token)
|
|
141
144
|
|
|
142
145
|
def _request_with_backoff(self, method: str, url: str, max_retries: int = 5, **kwargs):
|
|
143
146
|
"""
|
commons_metrics/repositories.py
CHANGED
|
@@ -144,13 +144,6 @@ class ComponentRepository:
|
|
|
144
144
|
cursor.close()
|
|
145
145
|
|
|
146
146
|
def get_or_create_current_month_date(self) -> int:
|
|
147
|
-
"""
|
|
148
|
-
Obtiene el ID de la fecha de HOY en measurement_systems_history.
|
|
149
|
-
Si no existe, crea un registro con CURRENT_DATE y devuelve su ID.
|
|
150
|
-
|
|
151
|
-
Returns:
|
|
152
|
-
int: ID del registro de fecha de hoy
|
|
153
|
-
"""
|
|
154
147
|
cursor = None
|
|
155
148
|
try:
|
|
156
149
|
self.db.ensure_connection()
|
|
@@ -159,7 +152,8 @@ class ComponentRepository:
|
|
|
159
152
|
query_select = """
|
|
160
153
|
SELECT id
|
|
161
154
|
FROM schmetrc.measurement_systems_history
|
|
162
|
-
WHERE date = CURRENT_DATE
|
|
155
|
+
WHERE EXTRACT(YEAR FROM date) = EXTRACT(YEAR FROM CURRENT_DATE)
|
|
156
|
+
AND EXTRACT(MONTH FROM date) = EXTRACT(MONTH FROM CURRENT_DATE)
|
|
163
157
|
LIMIT 1
|
|
164
158
|
"""
|
|
165
159
|
cursor.execute(query_select)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
commons_metrics/__init__.py,sha256=
|
|
1
|
+
commons_metrics/__init__.py,sha256=Bi1dg_3-9zvvSAmotQqZminbmRY3ruotmotRz36Dj40,796
|
|
2
2
|
commons_metrics/azure_devops_client.py,sha256=XrGqhr4voFUtGkdB27tnzsMSiNdpfY4stQUU51e1a0U,16755
|
|
3
3
|
commons_metrics/cache_manager.py,sha256=HOeup9twUizjJAbh1MNXdPT8BMVeLFoolOWlAzMTXkE,2651
|
|
4
4
|
commons_metrics/commons_repos_client.py,sha256=PiAMLWuDnI8AlZzE3sfQ3s2P23UrYbbqaq63AFRroHc,4695
|
|
5
5
|
commons_metrics/database.py,sha256=pFJAnkiPpEENDXJ6zqcGXO0CKpruxBt_8zokp4JLB-0,2995
|
|
6
6
|
commons_metrics/date_utils.py,sha256=8465712QJDGcshqry97Gi90lbMEbvbX3uiuHRVwGHbE,2654
|
|
7
|
-
commons_metrics/github_api_client.py,sha256=
|
|
8
|
-
commons_metrics/repositories.py,sha256=
|
|
7
|
+
commons_metrics/github_api_client.py,sha256=RMM-NyvTOGWv3jS__SFxWBzZX9_IjtbqgA-mr41D51o,18850
|
|
8
|
+
commons_metrics/repositories.py,sha256=DXa9ZkqtGZ95weOsPKf8-8mnxKNhyjdiu60hiTi5Nts,8903
|
|
9
9
|
commons_metrics/s3_file_manager.py,sha256=Mm7vlPJeXB46LnCXFs9oz7PQezcIcgYLlSJqMzVf72g,3384
|
|
10
10
|
commons_metrics/text_simplifier.py,sha256=jRYckQ5APR0A3wY4hg70kOHxHUFuGzd6D-CJC3__j78,1518
|
|
11
11
|
commons_metrics/update_design_components.py,sha256=QpY0GCCCMjdYOZ7b8oNigU9iTpiGx91CYsyWwN8WVDA,7660
|
|
12
12
|
commons_metrics/util.py,sha256=98zuynalXumQRh-BB0Bcjyoh6vS2BTOUM8tVgr7iS9Q,1225
|
|
13
13
|
commons_metrics/variable_finder.py,sha256=pxI_XSd-lq_AiUjDbcUC4knIZhWZwt7HQrQOa-F0ud4,8061
|
|
14
|
-
commons_metrics-0.0.
|
|
15
|
-
commons_metrics-0.0.
|
|
16
|
-
commons_metrics-0.0.
|
|
17
|
-
commons_metrics-0.0.
|
|
18
|
-
commons_metrics-0.0.
|
|
14
|
+
commons_metrics-0.0.28.dist-info/licenses/LICENSE,sha256=jsHZ2Sh1wCL74HC25pDDGXCyQ0xgsTAy62FvEnehKIg,1067
|
|
15
|
+
commons_metrics-0.0.28.dist-info/METADATA,sha256=tqStufbUVov52HOuC-KWLEoxjTIg34bm5PbZi7MZAaI,402
|
|
16
|
+
commons_metrics-0.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
commons_metrics-0.0.28.dist-info/top_level.txt,sha256=lheUN-3OKdU3A8Tg8Y-1IEB_9i_vVRA0g_FOiUsTQz8,16
|
|
18
|
+
commons_metrics-0.0.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|