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

Method restore_from_pvc

python/graphscope/client/session.py:1049–1093  ·  view source on GitHub ↗

Restores the graphs from the given path in the given PVC. Notice, before calling this function, the KUBECONFIG environment variable should be set to the path of your kubeconfig file. Args: path: The path in the pv to which the pvc is bound. p

(self, path: str, pvc_name: str)

Source from the content-addressed store, hash-verified

1047 )
1048
1049 def restore_from_pvc(self, path: str, pvc_name: str):
1050 """
1051 Restores the graphs from the given path in the given PVC.
1052 Notice, before calling this function, the KUBECONFIG environment variable
1053 should be set to the path of your kubeconfig file.
1054
1055 Args:
1056 path: The path in the pv to which the pvc is bound.
1057 pvc_name: The name of the PVC.
1058
1059 Raises:
1060 RuntimeError: If the cluster type is not Kubernetes.
1061 """
1062 if self._cluster_type != types_pb2.K8S:
1063 raise RuntimeError("Only support kubernetes cluster")
1064 vineyard_deployment_name = self._config.vineyard.deployment_name
1065 namespace = self._config.kubernetes_launcher.namespace
1066 self._ensure_vineyard_deployment_exists(vineyard_deployment_name, namespace)
1067 self._ensure_pvc_exists(pvc_name, namespace)
1068 random_suffix = random_string(6)
1069 vineyard.deploy.vineyardctl.deploy.recover_job(
1070 recover_name="vineyard-recover-" + random_suffix,
1071 vineyard_deployment_name=vineyard_deployment_name,
1072 vineyard_deployment_namespace=namespace,
1073 namespace=namespace,
1074 recover_path=path,
1075 pvc_name=pvc_name,
1076 )
1077
1078 _core_api = kube_client.CoreV1Api(self._get_api_client())
1079 try:
1080 config_map = _core_api.read_namespaced_config_map(
1081 name="vineyard-recover-" + random_suffix + "-mapping-table",
1082 namespace=namespace,
1083 )
1084 except kube_client.rest.ApiException as e:
1085 if e.status == 404:
1086 raise RuntimeError(
1087 f"ConfigMap vineyard-recover-{random_suffix}-mapping-table not found in namespace {namespace}"
1088 ) from e
1089 else:
1090 raise e
1091
1092 # parse configmap data to the self._vineyard_object_mapping_table
1093 self._vineyard_object_mapping_table = config_map.data
1094
1095 def get_vineyard_object_mapping_table(self):
1096 """

Callers 1

Calls 4

_ensure_pvc_existsMethod · 0.95
_get_api_clientMethod · 0.95
random_stringFunction · 0.90

Tested by 1