Skip to content

Commit a1ae5a0

Browse files
authored
refactor(oocana): move string_hash function to internal.py (#459)
The string_hash utility function was defined in context.py but belongs with other utility functions in internal.py. This improves code organization.
1 parent e95a527 commit a1ae5a0

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

oocana/oocana/context.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
from .throttler import throttle
1111
from .preview import PreviewPayload, DataFrame, PreviewPayloadInternal, ShapeDataFrame
1212
from .data import EXECUTOR_NAME
13-
from .internal import random_string, InternalAPI
13+
from .internal import random_string, InternalAPI, string_hash
1414
from .credential import CredentialInput
1515
import os.path
1616
import logging
17-
import hashlib
1817

1918
__all__ = [
2019
"Context",
@@ -33,12 +32,6 @@
3332
]
3433

3534

36-
def string_hash(text: str) -> str:
37-
"""
38-
Generates a deterministic hash for a given string.
39-
"""
40-
return hashlib.sha256(text.encode('utf-8')).hexdigest()
41-
4235
class ToNode(TypedDict):
4336
node_id: str
4437

oocana/oocana/internal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import random
44
import string
55
import math
6+
import hashlib
7+
68

79
class InternalAPI:
810

@@ -30,3 +32,10 @@ async def update_node_weight(self, node_id: str, weight: int | float) -> None:
3032

3133
def random_string(length=8):
3234
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
35+
36+
37+
def string_hash(text: str) -> str:
38+
"""
39+
Generates a deterministic hash for a given string.
40+
"""
41+
return hashlib.sha256(text.encode('utf-8')).hexdigest()

0 commit comments

Comments
 (0)