codeant-ai-for-open-source[bot] commented on code in PR #45100:
URL: https://github.com/apache/superset/pull/45100#discussion_r4235495806
##########
superset/semantic_layers/models.py:
##########
@@ -166,6 +168,55 @@ class ColumnMetadata:
extra: str | None = None
+_METADATA_IDENTITY_KEY: str = "semantic_layer_cache_identity"
+
+
+@dataclass
+class _MetadataCacheIdentity:
+ """Session-local identities, captured before discovery and forgotten on
Save."""
+
+ tokens: dict[uuid.UUID, str] = field(default_factory=dict)
+
+ @classmethod
+ def for_session(cls, session: Session) -> _MetadataCacheIdentity:
+ """Keep the memo's storage convention in one place."""
+ if _METADATA_IDENTITY_KEY not in session.info:
+ session.info[_METADATA_IDENTITY_KEY] = cls()
+ return cast(_MetadataCacheIdentity,
session.info[_METADATA_IDENTITY_KEY])
+
+ def capture(self, layer: SemanticLayer, session: Session) -> str:
+ """Web, task and MCP operations share a credential-independent
identity."""
+ if layer.uuid not in self.tokens:
+ namespace: str | Callable[[], str] = current_app.config.get(
+ "SEMANTIC_LAYER_CACHE_NAMESPACE", ""
+ )
+ if callable(namespace):
+ namespace = namespace()
+ if not isinstance(namespace, str):
+ raise TypeError(
+ "SEMANTIC_LAYER_CACHE_NAMESPACE must resolve to a string"
+ )
+ url: sa.engine.URL =
session.get_bind(mapper=SemanticLayer).engine.url
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not flag `.engine` access on SQLAlchemy `Engine` or `Connection`
objects as an API mismatch; in SQLAlchemy 2.0, both expose an engine property.
**Applied to:**
- `superset/semantic_layers/**`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]