| 26 | |
| 27 | |
| 28 | def bind_datasource_in_batch(graph_identifier: str, datasource: dict) -> str: |
| 29 | # upload files |
| 30 | for mapping in itertools.chain( |
| 31 | datasource["vertex_mappings"], datasource["edge_mappings"] |
| 32 | ): |
| 33 | for index, location in enumerate(mapping["inputs"]): |
| 34 | # path begin with "@" represents the local file |
| 35 | if location.startswith("@"): |
| 36 | location = location[1:] |
| 37 | mapping["inputs"][index] = upload_file(location) |
| 38 | # bind data source |
| 39 | context = get_current_context() |
| 40 | with graphscope.flex.rest.ApiClient( |
| 41 | graphscope.flex.rest.Configuration(context.coordinator_endpoint) |
| 42 | ) as api_client: |
| 43 | api_instance = graphscope.flex.rest.DataSourceApi(api_client) |
| 44 | return api_instance.bind_datasource_in_batch( |
| 45 | graph_identifier, SchemaMapping.from_dict(datasource) |
| 46 | ) |
| 47 | |
| 48 | |
| 49 | def get_datasource_by_id(graph_identifier: str) -> SchemaMapping: |