示例#1
0
def ticktock():

    try:
        print('In ticktock')
        running_pipelines = [(uid, status, steps)
                             for (uid, (status, steps)) in PIPELINES.items()
                             if status == 'running']

        print('running_pipelines', running_pipelines)
        for uid, status, steps in running_pipelines:
            refreshed_steps = refresh_pipeline_steps(steps)
            print('refreshed_steps', refreshed_steps)
            runnables = get_runnable_steps(refreshed_steps)
            running = get_running_steps(refreshed_steps)

            if len(runnables) == 0 and len(running) == 0:
                update_pipeline_state(uid,
                                      state='finished')  # May be not a success
                print('Pipeline "{}" finished'.format(uid))

            elif runnables:
                start_steps(runnables)
                print('Started', runnables)

            else:
                print('Nothing starts but things are running')
    except Exception as e:
        import traceback
        print('OH NOES!', e)
        traceback.print_exc()
示例#2
0
def ticktock():

    try:
        print("In ticktock")
        running_pipelines = [
            (uid, status, steps) for (uid, (status, steps)) in PIPELINES.items() if status == "running"
        ]

        print("running_pipelines", running_pipelines)
        for uid, status, steps in running_pipelines:
            refreshed_steps = refresh_pipeline_steps(steps)
            print("refreshed_steps", refreshed_steps)
            runnables = get_runnable_steps(refreshed_steps)
            running = get_running_steps(refreshed_steps)

            if len(runnables) == 0 and len(running) == 0:
                update_pipeline_state(uid, state="finished")  # May be not a success
                print('Pipeline "{}" finished'.format(uid))

            elif runnables:
                start_steps(runnables)
                print("Started", runnables)

            else:
                print("Nothing starts but things are running")
    except Exception as e:
        import traceback

        print("OH NOES!", e)
        traceback.print_exc()
示例#3
0
def test_refresh_pipeline_steps(pipeline_steps, monkeypatch):
    def mock_get_request(url, verify):
        get_response = MagicMock()
        get_response.json.return_value = {'state': 'completed'} if 'signoff1' in url else {'state': 'busted'}
        return get_response

    monkeypatch.setattr(requests, 'get', mock_get_request)

    pipeline_steps[0].state = 'running'
    pipeline_steps = refresh_pipeline_steps(pipeline_steps)
    assert pipeline_steps[0].state == 'completed'
    assert pipeline_steps[1].state == 'pending'
    assert pipeline_steps[2].state == 'pending'