コード例 #1
0
ファイル: test_flow_run.py プロジェクト: tank0226/prefect
    def test_raises_success_state(self, mock_watch_flow_run, MockFlowRunView):
        MockFlowRunView.from_flow_run_id().get_latest().state = state.Success(
            message="foo")

        with prefect.Flow("test") as flow:
            ref = wait_for_flow_run("flow-run-id", raise_final_state=True)

        flow_state = flow.run()
        task_state = flow_state.result[ref]
        assert task_state.is_successful()
        assert task_state.message == 'flow-run-id finished in state <Success: "foo">'
        # The latest view is attached to the result
        assert task_state.result == MockFlowRunView.from_flow_run_id(
        ).get_latest()

        assert flow_state.is_successful()
with Flow(flow_run_name, schedule=schedule,
          run_config=parent_run_config) as parent_flow:
    flow_run = create_flow_run(
        flow_name="stream_harvest",
        run_name=flow_run_name,
        project_name=project_name,
        parameters={
            'config': config_json,
            'error_test': False,
            'export_da': True,
            'gh_write_da': True,
        },
        run_config=run_config,
    )
    wait_for_flow = wait_for_flow_run(flow_run, raise_final_state=True)  # noqa

now = datetime.datetime.utcnow()
image_registry = "cormorack"
image_name = "harvest"
image_tag = f"{flow_run_name}.{now:%Y%m%dT%H%M}"

parent_flow.storage = Docker(
    registry_url=image_registry,
    dockerfile=HERE.joinpath("Dockerfile"),
    image_name=image_name,
    prefect_directory="/home/jovyan/prefect",
    env_vars={'HARVEST_ENV': 'ooi-harvester'},
    python_dependencies=[
        'git+https://github.com/ooi-data/ooi-harvester.git@main'
    ],