MCPcopy Create free account
hub / github.com/alibaba/GraphScope / Context

Class Context

python/graphscope/framework/context.py:597–707  ·  view source on GitHub ↗

Hold a handle of app querying context. After evaluating an app, the context (vertex data, partial results, etc.) are preserved, and can be referenced through a handle.

Source from the content-addressed store, hash-verified

595
596
597class Context(object):
598 """Hold a handle of app querying context.
599
600 After evaluating an app, the context (vertex data, partial results, etc.) are preserved,
601 and can be referenced through a handle.
602 """
603
604 def __init__(self, context_node, key, result_schema):
605 self._context_node = context_node
606 self._session = context_node.session
607 self._graph = self._context_node._graph
608 self._key = key
609 self._result_schema = result_schema
610 # copy and set op evaluated
611 self._context_node.op = deepcopy(self._context_node.op)
612 self._context_node.evaluated = True
613 self._context_node._unload_op = dag_utils.unload_context(self._context_node)
614 self._saved_signature = self.signature
615
616 @property
617 def op(self):
618 return self._context_node.op
619
620 @property
621 def key(self):
622 """Unique identifier of a context."""
623 return self._key
624
625 @property
626 def context_type(self):
627 return self._context_node.context_type
628
629 @property
630 def schema(self):
631 return self._context_node._build_schema(self._result_schema)
632
633 @property
634 def signature(self):
635 """Compute digest by key and graph signatures.
636 Used to ensure the critical information of context is untouched.
637 """
638 check_argument(
639 self._key is not None,
640 "Context key error, maybe it is not connected to engine.",
641 )
642 s = hashlib.sha256()
643 s.update(self._key.encode("utf-8", errors="ignore"))
644 if not isinstance(self._graph, DAGNode):
645 s.update(self._graph.signature.encode("utf-8", errors="ignore"))
646 return s.hexdigest()
647
648 def __repr__(self):
649 return f"graphscope.framework.context.{self.__class__.__name__} from graph {str(self._graph)}"
650
651 def _check_unmodified(self):
652 check_argument(self._saved_signature == self.signature)
653
654 def _check_selector(self, selector):

Callers 1

_rebuild_contextMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected