Initialize the graph object in local mode or distributed mode. If deployed in local mode, just call `g.init()` without any parameters. If in distributed, you should care about WORKER mode and SERVER mode. Args: task_index (int): Current task index. If in WORKER mode, it
(self, task_index=0, task_count=1,
cluster="", job_name="", **kwargs)
| 373 | self._edge_sources.append(edge_source_reverse) |
| 374 | |
| 375 | def init(self, task_index=0, task_count=1, |
| 376 | cluster="", job_name="", **kwargs): |
| 377 | """ Initialize the graph object in local mode or distributed mode. |
| 378 | |
| 379 | If deployed in local mode, just call `g.init()` without any parameters. |
| 380 | If in distributed, you should care about WORKER mode and SERVER mode. |
| 381 | |
| 382 | Args: |
| 383 | task_index (int): Current task index. |
| 384 | If in WORKER mode, it means the current worker index. |
| 385 | If in SERVER mode, it means the current server index. |
| 386 | task_count (int): Total task count. Only needed in WORKER mode. |
| 387 | It means in the total worker count. |
| 388 | cluster (dict | json string): Only needed in SERVER mode. |
| 389 | 3 kinds of schemas are supported: |
| 390 | cluster = { |
| 391 | "server_count": 2, |
| 392 | "client_count": 4, |
| 393 | "tracker": "root://graphlearn" |
| 394 | } |
| 395 | cluster = { |
| 396 | "server": "127.0.0.2:6666,127.0.0.3:7777", |
| 397 | "client": "127.0.0.4:8888,127.0.0.5:9999" |
| 398 | } |
| 399 | cluster = { |
| 400 | "server": "127.0.0.2:6666,127.0.0.3:7777", |
| 401 | "client_count", 2 |
| 402 | } |
| 403 | server_count (int): count of servers. |
| 404 | client_count (int): count of clients. |
| 405 | server (string): hosts of servers, split by ','. |
| 406 | job_name (str): `client` or `server`. Only needed in SERVER mode. |
| 407 | kwargs: |
| 408 | tracker (string): Optional tracker path for WORKER mode. |
| 409 | hosts (string): Optional worker hosts for WORKER mode. |
| 410 | """ |
| 411 | if self._with_vineyard: |
| 412 | pywrap.set_storage_mode(8) |
| 413 | pywrap.set_tracker_mode(0) |
| 414 | |
| 415 | if not cluster and task_count == 1: |
| 416 | # Local mode |
| 417 | pywrap.set_deploy_mode(pywrap.DeployMode.LOCAL) |
| 418 | self.deploy_in_local_mode(task_index) |
| 419 | elif not cluster: |
| 420 | if task_count > 1 or kwargs.get("hosts") is not None: |
| 421 | # WORKER mode |
| 422 | pywrap.set_deploy_mode(pywrap.DeployMode.WORKER) |
| 423 | tracker = kwargs.get("tracker", "root://graphlearn") |
| 424 | hosts = kwargs.get("hosts") |
| 425 | self.deploy_in_worker_mode(tracker, hosts, task_index, task_count) |
| 426 | else: |
| 427 | # SERVER mode |
| 428 | pywrap.set_deploy_mode(pywrap.DeployMode.SERVER) |
| 429 | self.deploy_in_server_mode(task_index, cluster, job_name) |
| 430 | return self |
| 431 | |
| 432 | def deploy_in_local_mode(self, task_index): |