From 0f731f1fb1aa520e4cc445343d8b0f487de04a93 Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Sat, 31 Jan 2026 14:31:23 +0800 Subject: [PATCH] refactor: move string_hash function to internal.py The string_hash utility function was defined in context.py but belongs with other utility functions in internal.py. This improves code organization. --- oocana/oocana/context.py | 9 +-------- oocana/oocana/internal.py | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/oocana/oocana/context.py b/oocana/oocana/context.py index 40f4cac..3c3bb0d 100644 --- a/oocana/oocana/context.py +++ b/oocana/oocana/context.py @@ -10,21 +10,14 @@ from .throttler import throttle from .preview import PreviewPayload, DataFrame, PreviewPayloadInternal, ShapeDataFrame from .data import EXECUTOR_NAME -from .internal import random_string, InternalAPI +from .internal import random_string, InternalAPI, string_hash from .credential import CredentialInput import os.path import logging -import hashlib __all__ = ["Context", "HandleDefDict", "BlockJob", "BlockExecuteException"] -def string_hash(text: str) -> str: - """ - Generates a deterministic hash for a given string. - """ - return hashlib.sha256(text.encode('utf-8')).hexdigest() - class ToNode(TypedDict): node_id: str diff --git a/oocana/oocana/internal.py b/oocana/oocana/internal.py index cbecf74..466a322 100644 --- a/oocana/oocana/internal.py +++ b/oocana/oocana/internal.py @@ -3,6 +3,15 @@ import random import string import math +import hashlib + + +def string_hash(text: str) -> str: + """ + Generates a deterministic hash for a given string. + """ + return hashlib.sha256(text.encode('utf-8')).hexdigest() + class InternalAPI: