Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions oocana/oocana/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions oocana/oocana/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import random
import string
import math
import hashlib


class InternalAPI:

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

def random_string(length=8):
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))


def string_hash(text: str) -> str:
"""
Generates a deterministic hash for a given string.
"""
return hashlib.sha256(text.encode('utf-8')).hexdigest()