allow for overriding strategy

This commit is contained in:
Ben Rudolph
2018-03-23 17:45:47 -07:00
parent d5b3c2e303
commit 5cab4effea

View File

@ -41,6 +41,9 @@ class ETLCommand(BaseCommand):
def get_services(self): def get_services(self):
return {} return {}
def get_strategy(self):
return None
def info(self, *args, **kwargs): def info(self, *args, **kwargs):
self.logger.info(*args, **kwargs) self.logger.info(*args, **kwargs)
@ -48,6 +51,7 @@ class ETLCommand(BaseCommand):
results = [] results = []
with bonobo.parse_args(options) as options: with bonobo.parse_args(options) as options:
services = self.get_services() services = self.get_services()
strategy = self.get_strategy()
graph_coll = self.get_graph(*args, **options) graph_coll = self.get_graph(*args, **options)
if not isinstance(graph_coll, GeneratorType): if not isinstance(graph_coll, GeneratorType):
@ -56,7 +60,7 @@ class ETLCommand(BaseCommand):
for i, graph in enumerate(graph_coll): for i, graph in enumerate(graph_coll):
assert isinstance(graph, bonobo.Graph), 'Invalid graph provided.' assert isinstance(graph, bonobo.Graph), 'Invalid graph provided.'
print(term.lightwhite('{}. {}'.format(i + 1, graph.name))) print(term.lightwhite('{}. {}'.format(i + 1, graph.name)))
result = bonobo.run(graph, services=services) result = bonobo.run(graph, services=services, strategy=strategy)
results.append(result) results.append(result)
print(term.lightblack(' ... return value: ' + str(result))) print(term.lightblack(' ... return value: ' + str(result)))
print() print()