Unverified Commit 7ab3d993 authored by Ligeng Zhu's avatar Ligeng Zhu Committed by GitHub
Browse files

Change the absolute path to relative one in `part_config.json` (#2690)



* Update partition.py

* fix lint.
Co-authored-by: default avatarDa Zheng <zhengda1936@gmail.com>
parent 16861063
......@@ -79,6 +79,9 @@ def load_partition(part_config, part_id):
List[str]
The edge types
'''
config_path = os.path.dirname(part_config)
relative_to_config = lambda path: os.path.join(config_path, path)
with open(part_config) as conf_f:
part_metadata = json.load(conf_f)
assert 'part-{}'.format(part_id) in part_metadata, "part-{} does not exist".format(part_id)
......@@ -86,9 +89,9 @@ def load_partition(part_config, part_id):
assert 'node_feats' in part_files, "the partition does not contain node features."
assert 'edge_feats' in part_files, "the partition does not contain edge feature."
assert 'part_graph' in part_files, "the partition does not contain graph structure."
node_feats = load_tensors(part_files['node_feats'])
edge_feats = load_tensors(part_files['edge_feats'])
graph = load_graphs(part_files['part_graph'])[0][0]
node_feats = load_tensors(relative_to_config(part_files['node_feats']))
edge_feats = load_tensors(relative_to_config(part_files['edge_feats']))
graph = load_graphs(relative_to_config(part_files['part_graph']))[0][0]
# In the old format, the feature name doesn't contain node/edge type.
# For compatibility, let's add node/edge types to the feature names.
node_feats1 = {}
......@@ -687,9 +690,10 @@ def partition_graph(g, graph_name, num_parts, out_path, num_hops=1, part_method=
node_feat_file = os.path.join(part_dir, "node_feat.dgl")
edge_feat_file = os.path.join(part_dir, "edge_feat.dgl")
part_graph_file = os.path.join(part_dir, "graph.dgl")
part_metadata['part-{}'.format(part_id)] = {'node_feats': node_feat_file,
'edge_feats': edge_feat_file,
'part_graph': part_graph_file}
part_metadata['part-{}'.format(part_id)] = {
'node_feats': os.path.relpath(node_feat_file, out_path),
'edge_feats': os.path.relpath(edge_feat_file, out_path),
'part_graph': os.path.relpath(part_graph_file, out_path)}
os.makedirs(part_dir, mode=0o775, exist_ok=True)
save_tensors(node_feat_file, node_feats)
save_tensors(edge_feat_file, edge_feats)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment