| 1 |
# Copyright (C) 2013 Yahoo! Inc. All Rights Reserved. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
# not use this file except in compliance with the License. You may obtain |
| 5 |
# a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 |
# License for the specific language governing permissions and limitations |
| 13 |
# under the License. |
| 14 |
|
| 15 |
import logging |
| 16 |
import os |
| 17 |
import sys |
| 18 |
|
| 19 |
logging.basicConfig(level=logging.ERROR) |
| 20 |
|
| 21 |
self_dir = os.path.abspath(os.path.dirname(__file__)) |
| 22 |
top_dir = os.path.abspath( |
| 23 |
os.path.join(self_dir, os.pardir, os.pardir, os.pardir)) |
| 24 |
example_dir = os.path.abspath(os.path.join(self_dir, os.pardir)) |
| 25 |
|
| 26 |
sys.path.insert(0, top_dir) |
| 27 |
sys.path.insert(0, example_dir) |
| 28 |
|
| 29 |
|
| 30 |
import taskflow.engines |
| 31 |
from taskflow import states |
| 32 |
|
| 33 |
import example_utils # noqa |
| 34 |
|
| 35 |
|
| 36 |
FINISHED_STATES = (states.SUCCESS, states.FAILURE, states.REVERTED) |
| 37 |
|
| 38 |
|
| 39 |
def resume(flowdetail, backend): |
| 40 |
print(f'Resuming flow {flowdetail.name} {flowdetail.uuid}') |
| 41 |
engine = taskflow.engines.load_from_detail(flow_detail=flowdetail, |
| 42 |
backend=backend) |
| 43 |
engine.run() |
| 44 |
|
| 45 |
|
| 46 |
def main(): |
| 47 |
with example_utils.get_backend() as backend: |
| 48 |
logbooks = list(backend.get_connection().get_logbooks()) |
| 49 |
for lb in logbooks: |
| 50 |
for fd in lb: |
| 51 |
if fd.state not in FINISHED_STATES: |
| 52 |
resume(fd, backend) |
| 53 |
|
| 54 |
|
| 55 |
if __name__ == '__main__': |
| 56 |
main() |