mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
DatabaseToolSourceStore: populate identity_hash + scalar tool columns (new upstream schema)
This commit is contained in:
@@ -67,11 +67,19 @@ def get_or_create_tool_source(session: Session, tool) -> ToolSource:
|
||||
|
||||
def tool_source_identity_hash(tool: Any) -> str:
|
||||
dynamic_tool = getattr(tool, "dynamic_tool", None)
|
||||
identity: tuple[str, ...]
|
||||
if dynamic_tool is not None and dynamic_tool.id is not None:
|
||||
identity = ("dynamic", str(dynamic_tool.id))
|
||||
else:
|
||||
identity = ("static", tool.id or "", tool.version or "")
|
||||
return hashlib.sha256("\0".join(identity).encode("utf-8")).hexdigest()
|
||||
return static_tool_source_identity_hash(tool.id, tool.version)
|
||||
|
||||
|
||||
def static_tool_source_identity_hash(tool_id: str | None, tool_version: str | None) -> str:
|
||||
"""Identity hash for a persisted source with no dynamic-tool linkage.
|
||||
|
||||
Shared with ``galaxy.tool_source_store`` writers, which persist
|
||||
config-file tool sources and therefore always carry a static identity.
|
||||
"""
|
||||
identity = ("static", tool_id or "", tool_version or "")
|
||||
return hashlib.sha256("\0".join(identity).encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ from sqlalchemy import (
|
||||
)
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from galaxy.managers.tool_source import static_tool_source_identity_hash
|
||||
from galaxy.model import (
|
||||
ToolIndexCache,
|
||||
ToolSource as ToolSourceModel,
|
||||
@@ -112,6 +113,11 @@ class DatabaseToolSourceStore(ToolSourceStore):
|
||||
hash=tool_source.hash,
|
||||
source=source_data,
|
||||
source_class=tool_source.tool_source_class,
|
||||
tool_id=tool_source.tool_id,
|
||||
tool_version=tool_source.tool_version,
|
||||
# Same "static" identity as galaxy.managers.tool_source.tool_source_identity_hash —
|
||||
# store-backed sources never carry a dynamic tool.
|
||||
identity_hash=static_tool_source_identity_hash(tool_source.tool_id, tool_source.tool_version),
|
||||
)
|
||||
session.add(model)
|
||||
session.flush()
|
||||
|
||||
Reference in New Issue
Block a user