def LazyConsistentWatchDiff(blob_watched, handler): handler_uuid = str(uuid.uuid1()) lbi_and_uuid = LbiAndDiffWatcherUuidPair() lbi_and_uuid.lbi.CopyFrom(blob_watched.lbi) lbi_and_uuid.watcher_uuid = handler_uuid c_api_util.CurJobBuildAndInferCtx_AddLbiAndDiffWatcherUuidPair( lbi_and_uuid) watcher_util.BindUuidAndHandler(handler_uuid, blob_watched, handler)
def LazyConsistentWatchDiff(blob_watched, handler): handler_uuid = str(uuid.uuid1()) lbi_and_uuid = LbiAndDiffWatcherUuidPair() # Copy cfg LBI to proto LBI lbi_and_uuid.lbi.op_name = blob_watched.lbi.op_name() lbi_and_uuid.lbi.blob_name = blob_watched.lbi.blob_name() lbi_and_uuid.watcher_uuid = handler_uuid c_api_util.CurJobBuildAndInferCtx_AddLbiAndDiffWatcherUuidPair( lbi_and_uuid) watcher_util.BindUuidAndHandler(handler_uuid, blob_watched, handler)
def EagerWatchDiff(blob_watched, handler_or_prompt=None): handler = _CheckOrMakeHandler(blob_watched, handler_or_prompt) handler_uuid = str(uuid.uuid1()) lbi_and_uuid = LbiAndDiffWatcherUuidPair() lbi_and_uuid.lbi.CopyFrom(blob_watched.lbi) lbi_and_uuid.watcher_uuid = handler_uuid c_api_util.CurJobBuildAndInferCtx_AddLbiAndDiffWatcherUuidPair( lbi_and_uuid) uuid2watch_handler = session_ctx.GetDefaultSession().uuid2watch_handler uuid2watch_handler[handler_uuid] = lambda x: EagerWatch( x, handler_or_prompt)