in src/sagemaker/FD_SL_DGL/clients_python/client_boto_demo.py [0:0]
def load_subgraph(file_path):
"""
Revise this function to fit with new input format
:param file_path:
:return:
"""
print('------------------ Loading Graph -------------------')
with open(file_path, 'rb') as f:
graph_dict = pickle.load(f)
# print(subgraph_dict)
subgraph_dict = graph_dict['subgraph_dict']
n_feat_dict = graph_dict['n_feat_dict']
# generate fake node features
# new_subgraph_dict = {}
# n_lists = {}
# for can_etype, e_lists in subgraph_dict.items():
# src_type, etype, dst_type = can_etype
# src_list, dst_list = e_lists
# src_list = [src_type + '-' + str(nid) for nid in src_list]
# dst_list = [dst_type + '-' + str(nid) for nid in dst_list]
#
# # change canonical etype from tuple to string
# new_subgraph_dict['{}<>{}'.format(src_type, dst_type)] = (src_list.tolist(), dst_list.tolist())
#
# if n_lists.get(src_type) is not None:
# n_lists[src_type] = np.append(n_lists.get(src_type), src_list)
# else:
# n_lists[src_type] = src_list
#
# if n_lists.get(dst_type) is not None:
# n_lists[dst_type] = np.append(n_lists.get(dst_type), dst_list)
# else:
# n_lists[dst_type] = dst_list
#
# n_feats = {}
# for ntype, n_list in n_lists.items():
# # print(np.unique(n_list))
# num_nodes = np.unique(n_list).size
# print(ntype, num_nodes)
# # n_feats[ntype] = np.random.randint(0,100, size=(num_nodes, 390)).tolist()
# n_feats[ntype] = np.random.rand(size=(num_nodes, 390)).astype(np.float32).tolist()
return subgraph_dict, n_feat_dict