Create an execution step with a net containing read operators. The execution step will contain a `stop_blob` that knows how to stop the execution loop when end of data was reached. E.g.: read_step, fields = reader.execution_step() consume_net = core
(self, reader_net_name=None, external_should_stop=None)
| 105 | return should_stop, fields |
| 106 | |
| 107 | def execution_step(self, reader_net_name=None, external_should_stop=None): |
| 108 | """Create an execution step with a net containing read operators. |
| 109 | |
| 110 | The execution step will contain a `stop_blob` that knows how to stop |
| 111 | the execution loop when end of data was reached. |
| 112 | |
| 113 | E.g.: |
| 114 | |
| 115 | read_step, fields = reader.execution_step() |
| 116 | consume_net = core.Net('consume') |
| 117 | consume_net.Print(fields[0], []) |
| 118 | p = core.Plan('reader') |
| 119 | p.AddStep(read_step.AddNet(consume_net)) |
| 120 | core.RunPlan(p) |
| 121 | |
| 122 | Args: |
| 123 | reader_net_name: (optional) the name of the reader_net to be |
| 124 | created. The execution step will |
| 125 | be named accordingly. |
| 126 | |
| 127 | Returns: |
| 128 | A tuple (read_step, fields), with: |
| 129 | read_step: A newly created execution step containing a net with |
| 130 | read operations. The step will have `stop_blob` set, |
| 131 | in order to stop the loop on end of data. |
| 132 | fields: A tuple of BlobReference containing the latest batch |
| 133 | of data that was read. |
| 134 | """ |
| 135 | reader_net = core.Net(reader_net_name or 'reader') |
| 136 | should_stop, fields = self.read_record(reader_net) |
| 137 | if external_should_stop is not None: |
| 138 | should_stop = reader_net.Or([external_should_stop, should_stop]) |
| 139 | read_step = core.execution_step( |
| 140 | '{}_step'.format(reader_net_name), |
| 141 | reader_net, |
| 142 | should_stop_blob=should_stop) |
| 143 | return (read_step, fields) |
| 144 | |
| 145 | |
| 146 | class Writer: |