def test_build_no_default(monkeypatch): storage = Docker(registry_url="reg") monkeypatch.setattr("prefect.environments.storage.Docker._build_image", MagicMock()) output = storage.build() assert output.registry_url == storage.registry_url assert output.image_name assert output.image_tag.startswith(str(pendulum.now("utc").year))
def test_build_sets_informative_image_name_for_weird_name_flows(monkeypatch): storage = Docker(registry_url="reg") storage.add_flow(Flow("!&& ~~ cool flow :shades:")) monkeypatch.setattr("prefect.environments.storage.Docker._build_image", MagicMock()) output = storage.build() assert output.registry_url == storage.registry_url assert output.image_name == "cool-flow-shades" assert output.image_tag.startswith(str(pendulum.now("utc").year))
def test_build_respects_user_provided_image_name_and_tag(monkeypatch): storage = Docker(registry_url="reg", image_name="CUSTOM", image_tag="TAG") storage.add_flow(Flow("test")) monkeypatch.setattr("prefect.environments.storage.Docker._build_image", MagicMock()) output = storage.build() assert output.registry_url == storage.registry_url assert output.image_name == "CUSTOM" assert output.image_tag == "TAG"
def test_build_sets_image_name_for_multiple_flows(monkeypatch): storage = Docker(registry_url="reg") storage.add_flow(Flow("test")) storage.add_flow(Flow("test2")) monkeypatch.setattr("prefect.environments.storage.Docker._build_image", MagicMock()) output = storage.build() assert output.registry_url == storage.registry_url assert isinstance(output.image_name, str) assert output.image_tag.startswith(str(pendulum.now("utc").year))
def test_build_no_default(monkeypatch): storage = Docker(registry_url="reg") build_image = MagicMock(return_value=("1", "2")) monkeypatch.setattr("prefect.environments.storage.Docker.build_image", build_image) output = storage.build() assert output.registry_url == storage.registry_url assert output.image_name == "1" assert output.image_tag == "2"
from myflows.thisflow import flow as tflow1 # from myflows.thisflow import flow as tflow2 # tflow.storage.build() from prefect.environments.storage import Docker import copy tflow2 = copy.deepcopy(tflow1) tflow2.name = "222" d = Docker() d.add_flow(tflow1) d.add_flow(tflow2) d.build()
@task def numbers_task(): return [1, 2, 3] @task def map_task(x): return x + 1 @task def reduce_task(x): return sum(x) with Flow("Map / Reduce 🤓") as mr_flow: numbers = numbers_task() first_map = map_task.map(numbers) second_map = map_task.map(first_map) reduction = reduce_task(second_map) storage.add_flow(etl_flow) storage.add_flow(mr_flow) storage = storage.build(push=False) etl_flow.storage = storage mr_flow.storage = storage etl_flow.deploy(build="False") mr_flow.deploy(build="False")