MCPcopy
hub / github.com/celery/celery / to_dot

Method to_dot

celery/utils/graph.py:164–190  ·  view source on GitHub ↗

Convert the graph to DOT format. Arguments: fh (IO): A file, or a file-like object to write the graph to. formatter (celery.utils.graph.GraphFormatter): Custom graph formatter to use.

(self, fh, formatter=None)

Source from the content-addressed store, hash-verified

162 return result
163
164 def to_dot(self, fh, formatter=None):
165 """Convert the graph to DOT format.
166
167 Arguments:
168 fh (IO): A file, or a file-like object to write the graph to.
169 formatter (celery.utils.graph.GraphFormatter): Custom graph
170 formatter to use.
171 """
172 seen = set()
173 draw = formatter or self.formatter
174
175 def P(s):
176 print(bytes_to_str(s), file=fh)
177
178 def if_not_seen(fun, obj):
179 if draw.label(obj) not in seen:
180 P(fun(obj))
181 seen.add(draw.label(obj))
182
183 P(draw.head())
184 for obj, adjacent in self.items():
185 if not adjacent:
186 if_not_seen(draw.terminal_node, obj)
187 for req in adjacent:
188 if_not_seen(draw.node, obj)
189 P(draw.edge(obj, req))
190 P(draw.tail())
191
192 def format(self, obj):
193 return self.formatter(obj) if self.formatter else obj

Callers 3

workersFunction · 0.95
test_to_dotMethod · 0.80
bootstepsFunction · 0.80

Calls 4

headMethod · 0.80
tailMethod · 0.80
itemsMethod · 0.45
edgeMethod · 0.45

Tested by 1

test_to_dotMethod · 0.64