svc-infra 0.1.611__py3-none-any.whl → 0.1.613__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.

Potentially problematic release.


This version of svc-infra might be problematic. Click here for more details.

@@ -80,9 +80,12 @@ def setup_cache(
80
80
  logger.info(f"Cache version updated to: {_current_version}")
81
81
 
82
82
  # Setup backend connection
83
+ # Newer cashews versions require an explicit settings_url; default to in-memory
84
+ # backend when no URL is provided so acceptance/unit tests work out of the box.
83
85
  try:
84
- setup_awaitable = _cache.setup(url) if url else _cache.setup()
85
- logger.info(f"Cache backend setup initiated with URL: {url or 'default'}")
86
+ settings_url = url or "mem://"
87
+ setup_awaitable = _cache.setup(settings_url)
88
+ logger.info(f"Cache backend setup initiated with URL: {settings_url}")
86
89
  except Exception as e:
87
90
  logger.error(f"Failed to setup cache backend: {e}")
88
91
  raise
@@ -98,7 +98,25 @@ def cache_read(
98
98
  ttl_val = validate_ttl(ttl)
99
99
  template = build_key_template(key)
100
100
  namespace = _alias() or ""
101
- tags_func = create_tags_function(tags)
101
+ # Build a tags function that renders any templates against the call kwargs
102
+ base_tags_func = create_tags_function(tags)
103
+
104
+ def tags_func(*_args, **call_kwargs):
105
+ try:
106
+ raw = base_tags_func(*_args, **call_kwargs) or []
107
+ rendered = []
108
+ for t in raw:
109
+ if isinstance(t, str) and ("{" in t and "}" in t):
110
+ try:
111
+ rendered.append(t.format(**call_kwargs))
112
+ except Exception:
113
+ # Best effort: fall back to original
114
+ rendered.append(t)
115
+ else:
116
+ rendered.append(t)
117
+ return rendered
118
+ except Exception:
119
+ return raw if isinstance(raw, list) else []
102
120
 
103
121
  def _decorator(func: Callable[..., Awaitable[Any]]):
104
122
  # Try different cashews cache decorator signatures for compatibility
svc_infra/cache/keys.py CHANGED
@@ -88,12 +88,32 @@ def build_key_variants_renderer(template: str) -> Callable[..., list[str]]:
88
88
 
89
89
 
90
90
  def resolve_tags(tags, *args, **kwargs) -> list[str]:
91
- """Resolve tags from static list or callable."""
91
+ """Resolve tags from static list or callable and render templates with kwargs.
92
+
93
+ Supports entries like "thing:{id}" which will be formatted using provided kwargs.
94
+ Non-string items are passed through as str(). Missing keys are skipped with a warning.
95
+ """
92
96
  try:
97
+ # 1) Obtain raw tags list
93
98
  if callable(tags):
94
- result = tags(*args, **kwargs)
95
- return list(result) if result is not None else []
96
- return list(tags)
99
+ raw = tags(*args, **kwargs)
100
+ raw_list = list(raw) if raw is not None else []
101
+ else:
102
+ raw_list = list(tags)
103
+
104
+ # 2) Render any templates using kwargs
105
+ rendered: list[str] = []
106
+ for t in raw_list:
107
+ try:
108
+ if isinstance(t, str) and ("{" in t and "}" in t):
109
+ rendered.append(t.format(**kwargs))
110
+ else:
111
+ rendered.append(str(t))
112
+ except KeyError as e:
113
+ logger.warning(f"Tag template missing key {e} in '{t}'")
114
+ except Exception as e:
115
+ logger.warning(f"Failed to render tag '{t}': {e}")
116
+ return [r for r in rendered if r]
97
117
  except Exception as e:
98
118
  logger.error(f"Failed to resolve cache tags: {e}")
99
119
  return []
@@ -177,8 +177,16 @@ def _collect_metadata() -> list[object]:
177
177
  if name not in pkgs:
178
178
  pkgs.append(name)
179
179
 
180
+ # Only attempt bare 'models' import if it is discoverable to avoid noisy tracebacks
180
181
  if "models" not in pkgs:
181
- pkgs.append("models")
182
+ try:
183
+ spec = getattr(importlib, "util", None)
184
+ if spec is not None and getattr(spec, "find_spec", None) is not None:
185
+ if spec.find_spec("models") is not None:
186
+ pkgs.append("models")
187
+ except Exception:
188
+ # Best-effort; if discovery fails, skip adding bare 'models'
189
+ pass
182
190
 
183
191
  def _import_and_collect(modname: str):
184
192
  try:
@@ -191,9 +191,16 @@ def _collect_metadata() -> list[object]:
191
191
  if name not in pkgs:
192
192
  pkgs.append(name)
193
193
 
194
- # Always also try a bare 'models'
194
+ # Only attempt a bare 'models' import if discoverable to avoid noisy tracebacks
195
195
  if "models" not in pkgs:
196
- pkgs.append("models")
196
+ try:
197
+ spec = getattr(importlib, "util", None)
198
+ if spec is not None and getattr(spec, "find_spec", None) is not None:
199
+ if spec.find_spec("models") is not None:
200
+ pkgs.append("models")
201
+ except Exception:
202
+ # If discovery fails, skip adding bare 'models'
203
+ pass
197
204
 
198
205
  def _import_and_collect(modname: str):
199
206
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: svc-infra
3
- Version: 0.1.611
3
+ Version: 0.1.613
4
4
  Summary: Infrastructure for building and deploying prod-ready services
5
5
  License: MIT
6
6
  Keywords: fastapi,sqlalchemy,alembic,auth,infra,async,pydantic
@@ -117,10 +117,10 @@ svc_infra/billing/models.py,sha256=bnCGPKfnK__6x0f0bwKYQsG2GwXjJFi3YRXnq5JYs7c,6
117
117
  svc_infra/billing/service.py,sha256=3SDpPA3NF2lMYiOP4U99sgXpZAXaauexBfZQmYE2kvU,3727
118
118
  svc_infra/cache/README.md,sha256=ZgIpmE0UVlGktp2nXUYv6FKJATCdkR_01v-GGxHN6Ao,10795
119
119
  svc_infra/cache/__init__.py,sha256=Fz3NS81jrY5sLikRhITCeHDT4MlOLcbMed5EjVecSAg,956
120
- svc_infra/cache/backend.py,sha256=Vrza_8oi1AYUG1KdFmxg8S11WB4rKpKI246fZn4pdWs,4233
121
- svc_infra/cache/decorators.py,sha256=1lsQyEEGC3etwqKdh-GxUHmudfoZnVy3UjNTZjDOusA,7606
120
+ svc_infra/cache/backend.py,sha256=-dbZ2qkhebzbKosQqgvBNb01A-2_jGt6_0WmJhPoHy8,4418
121
+ svc_infra/cache/decorators.py,sha256=hsXTcdGo-Q1RKMrqQB0ROmFuce9A1JTt9sJAcWaHvMc,8330
122
122
  svc_infra/cache/demo.py,sha256=MX8LK-4Ju1xAxZtBh-p_Weh8yPNWmmPnDkOW5wAiGKI,2507
123
- svc_infra/cache/keys.py,sha256=6wczoSu4OFBAx4XZdNS94_mParNMox2WTrZRZHgUTpI,3146
123
+ svc_infra/cache/keys.py,sha256=8A122Te4VI40-CpLazEPOBgibX62cyjwClM5SIFeYac,3978
124
124
  svc_infra/cache/recache.py,sha256=adS9OK_dZNGaJKcG0caQlIm449GJ53zd3BkaB_dUF2c,8572
125
125
  svc_infra/cache/resources.py,sha256=BhvPAZvCQ-fitUdniGEOOE4g1ZvljdCA_R5pR8WfJz4,7421
126
126
  svc_infra/cache/tags.py,sha256=9URw4BRlnb4QFAYpDI36fMms6642xq4TeV9jqsEjzE8,2625
@@ -202,8 +202,8 @@ svc_infra/db/sql/templates/models_schemas/entity/models.py.tmpl,sha256=cSUAfYgAT
202
202
  svc_infra/db/sql/templates/models_schemas/entity/schemas.py.tmpl,sha256=xHTXk8u2uiqmQe8XpXjGAPg8pDpdr0rLtsSOC_fo9vo,1032
203
203
  svc_infra/db/sql/templates/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
204
204
  svc_infra/db/sql/templates/setup/alembic.ini.tmpl,sha256=7SHSOyUq9S7XqVdKpWLJW7gIWadv58t4AIooa306gDo,771
205
- svc_infra/db/sql/templates/setup/env_async.py.tmpl,sha256=inKnexIhdnvwQ9gy-ODBgK1mdSKpzw2Q3pdTS_9AN0A,12781
206
- svc_infra/db/sql/templates/setup/env_sync.py.tmpl,sha256=SP6OocHQIfkZl9g9iV0qVgkKOgQyViURQmTVqIIicPw,14195
205
+ svc_infra/db/sql/templates/setup/env_async.py.tmpl,sha256=XZ5jcZXaYdBca5cRaY_m4Zuhz5IGekO2cqLuwiVSK8Y,13201
206
+ svc_infra/db/sql/templates/setup/env_sync.py.tmpl,sha256=Q0GbhtHj45Kt3hep27V_pFqeZ53y08lamOZiWa7p0GU,14560
207
207
  svc_infra/db/sql/templates/setup/script.py.mako.tmpl,sha256=RiEMqF6dTN0S_lSRr90w5K2VtyK0_C81kBPZ02qQDZU,588
208
208
  svc_infra/db/sql/tenant.py,sha256=erCB_TjZ62NXXIiOjsTOV_u3mM8kj0-R7gy4RFc-NrE,2779
209
209
  svc_infra/db/sql/types.py,sha256=aDcYS-lEb3Aw9nlc8D67wyS5rmE9ZOkblxPjPFbMM_0,863
@@ -292,7 +292,7 @@ svc_infra/webhooks/fastapi.py,sha256=BCNvGNxukf6dC2a4i-6en-PrjBGV19YvCWOot5lXWsA
292
292
  svc_infra/webhooks/router.py,sha256=6JvAVPMEth_xxHX-IsIOcyMgHX7g1H0OVxVXKLuMp9w,1596
293
293
  svc_infra/webhooks/service.py,sha256=hWgiJRXKBwKunJOx91C7EcLUkotDtD3Xp0RT6vj2IC0,1797
294
294
  svc_infra/webhooks/signing.py,sha256=NCwdZzmravUe7HVIK_uXK0qqf12FG-_MVsgPvOw6lsM,784
295
- svc_infra-0.1.611.dist-info/METADATA,sha256=Y5HN5TofDIeh4AYGvJZxkB7wqEsbEF6K5Mueu0LKGCU,8106
296
- svc_infra-0.1.611.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
297
- svc_infra-0.1.611.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
298
- svc_infra-0.1.611.dist-info/RECORD,,
295
+ svc_infra-0.1.613.dist-info/METADATA,sha256=3sERXZccSqWjWt03Ceu0z12Q36BWFahfFlaiV6yom0U,8106
296
+ svc_infra-0.1.613.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
297
+ svc_infra-0.1.613.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
298
+ svc_infra-0.1.613.dist-info/RECORD,,