A Node context is used to indicate that all Tasks instantiated within will run on the given node name. (Only the name of the node actually counts.) Example: with TaskGroup() as tg: with Node('node1'): s1 = execution_step(...) Task(ste
| 52 | |
| 53 | |
| 54 | class Node(context.DefaultManaged): |
| 55 | """ |
| 56 | A Node context is used to indicate that all Tasks instantiated within will |
| 57 | run on the given node name. (Only the name of the node actually counts.) |
| 58 | Example: |
| 59 | |
| 60 | with TaskGroup() as tg: |
| 61 | with Node('node1'): |
| 62 | s1 = execution_step(...) |
| 63 | Task(step=s1) |
| 64 | with Node('node2'): |
| 65 | s2 = execution_step(...) |
| 66 | with Node('node1'): |
| 67 | s3 = execution_step(...) |
| 68 | |
| 69 | In this example, all three execution steps will run in parallel. |
| 70 | Moreover, s1 and s3 will run on the same node, and can see each |
| 71 | others blobs. |
| 72 | |
| 73 | Additionally, a Node can be passed implementation-specific kwargs, |
| 74 | in order to specify properties of the node. |
| 75 | """ |
| 76 | |
| 77 | def __init__(self, node='local', **kwargs): |
| 78 | self._name = str(node) |
| 79 | self._kwargs = kwargs |
| 80 | Cluster.current().add_node(self) |
| 81 | |
| 82 | def __str__(self): |
| 83 | return self._name |
| 84 | |
| 85 | def __repr__(self): |
| 86 | return "Node(name={}, kwargs={})".format(self._name, self._kwargs) |
| 87 | |
| 88 | def kwargs(self): |
| 89 | return self._kwargs |
| 90 | |
| 91 | |
| 92 | class WorkspaceType: |
no outgoing calls
searching dependent graphs…