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

Class App

python/graphscope/framework/app.py:430–479  ·  view source on GitHub ↗

An application that can run on graphs and produce results. Analytical engine will build the app dynamic library when instantiate a app instance. And the dynamic library will be reused if subsequent app's signature matches one of previous ones.

Source from the content-addressed store, hash-verified

428
429
430class App(object):
431 """An application that can run on graphs and produce results.
432
433 Analytical engine will build the app dynamic library when instantiate a app instance.
434 And the dynamic library will be reused if subsequent app's signature matches one of
435 previous ones.
436 """
437
438 def __init__(self, app_node, key):
439 self._app_node = app_node
440 self._session = self._app_node.session
441 self._key = key
442 # copy and set op evaluated
443 self._app_node.op = deepcopy(self._app_node.op)
444 self._app_node.evaluated = True
445 self._app_node._unload_op = unload_app(self._app_node)
446 self._session.dag.add_op(self._app_node.op)
447 self._saved_signature = self.signature
448
449 def __getattr__(self, name):
450 if hasattr(self._app_node, name):
451 return getattr(self._app_node, name)
452 raise AttributeError("{0} not found.".format(name))
453
454 @property
455 def key(self):
456 """A unique identifier of App."""
457 return self._key
458
459 @property
460 def signature(self):
461 """Signature is computed by all critical components of the App."""
462 return hashlib.sha256(
463 "{}.{}".format(self._app_assets.signature, self._graph.template_str).encode(
464 "utf-8", errors="ignore"
465 )
466 ).hexdigest()
467
468 def _unload(self):
469 return self._session._wrapper(self._app_node._unload())
470
471 def __del__(self):
472 """Unload app. Both on engine side and python side. Set the key to None."""
473 try:
474 self.session.run(self._unload())
475 except Exception: # pylint: disable=broad-except
476 pass
477
478 def __call__(self, *args, **kwargs):
479 return self._session._wrapper(self._app_node(*args, **kwargs))
480
481
482class UnloadedApp(DAGNode):

Callers 1

_rebuild_appMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected