-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): Unify the graph level load_from and save to API & Bump …
…up vineyard to v0.22.0 (#3610) ## What do these changes do? Unify the `load_from` and `save_to` API to support different kind of datasource. related discussion issue: #2836 #2920 ### `save_to` ```python def save_to(self, path, format="serialization", **kwargs) ``` We use `save_to` to dump graph to certain format data, currently support `graphar` and `serialization` and it's extensible to add a new format. - `path` output dir, support local,oss,s3,hdfs - `format` format to save, default is 'serialization' - related configurations the writing of each format may attach some related configurations. We set these configurations with naming strategy "format_config1", "format_config2". For example, graphar provide configuration: - graphar_graph_name - graphar_vertex_chunk_size - graphar_edge_chunk_size - graphar_file_type - graphar_store_in_local - `selector` to dump subgraph with selected vertices and edges User can define `selector` to only dump certain set of vertex and edge, example: ```python selector = { "vertices": { "person": ["id", "firstName", "secondName"], "comment": None, # select all properties }, "edges": { "knows": ["CreationDate"], "replyOf": None, }, } ``` - return format ```python {"type": format, "URI": "format+file:///tmp/graph/xxx"} ``` Example: ```ptyhon # graphar g.save_to("/tmp/graphar/", format="graphar", graphar_graph_name="ldbc", vertex_chunk_size=1024, graphar_edge_chunk_size=4096, graphar_file_type="parquet", graphar_store_in_local=False) {'type': 'grpahar', 'URI': 'graphar+file:///tmp/graphar/ldbc.graph.yml'} # graphar with selector selector = { "vertices": { "person": ["id", "firstName", "secondName"], "comment": None, # select all properties }, "edges": { "knows": ["CreationDate"], "replyOf": None, }, } g.save_to("/tmp/graphar/", format="graphar", selector=selector, graphar_graph_name="ldbc") {'type': 'grpahar', 'URI': 'graphar+file:///tmp/graphar/ldbc.graph.yml'} # serialization g.save_to("/tmp/serialization/") {'type':'serialization', 'URI': '/tmp/serialization/'} ``` ### `load_from` ```python def load_from(uri, **kwargs) ``` We use `load_from` to load graph to certain format data source, currently support `graphar` and `serialization` and it's extensible to add a new data source. - uri examples ```python graphar+file:///tmp/graphar/ldbc.graph.yaml graphar+oss://bucket/graphar/ldbc.graphar.yaml /tmp/serialization ``` - related configurations the loading of each format may attach some related configurations. We set these configurations with naming strategy "format_config1", "format_config2". For example, graphar provide configuration:`storage_options`. for example graphar can set configurations: ```python - graphar_store_in_local # the graphar files are store in local file system of workers, only support for local file system. ``` - `selector` to load subgraph with selected vertices and edges User can define `selector` to only load certain set of vertex and edge. example: ```python selector = { "vertices": { "person": None # select all properties "comment": None }, "edges": { "knows": None "replyOf": None }, } ``` - return A new Graph Example: ```ptyhon # graphar ```python Graph.load_from("graphar+file:///tmp/graphar/ldbc.graph.yml", graphar_store_in_local=True) # graphar with selector selector = { "vertices": { "person": None # select all properties "comment": None }, "edges": { "knows": None "replyOf": None }, } Graph.load_from("graphar+file:///tmp/graphar/ldbc.graph.yml", selector=selector) # serialization g.load_from("/tmp/serialization/") ``` ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes #2836 Fixes #2920 --------- Signed-off-by: acezen <[email protected]>
- Loading branch information
Showing
24 changed files
with
725 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.