<#308 [ImageBuilder] Add project_install_mode arg ...
# flyte-github
a
#308 [ImageBuilder] Add project_install_mode arg to Poetry layer in Image spec Pull request opened by popojk ## Issue Referencing to UV project, we should add a
project_install_mode
which is either "dependencies_only" or "install_project". The arg will be defaulted to "dependencies_only" so that poetry will be installed with
--no-root
arg, which tells poetry only install dependencies, otherwise it will also install the project. ## Changes Local docker builder and remote docker builder ## Tests Use this script to run task. The poetry
project_install_mode
config in Image spec is set to "dependencies_only". We expect that poetry will install with
--no-root
mode.
Copy code
env = flyte.TaskEnvironment(
    name="poetry_example",
    resources=flyte.Resources(memory="250Mi"),
    image=(
        flyte.Image.from_debian_base().with_poetry_project(
            pyproject_file=pathlib.Path("pyproject.toml"),
            poetry_lock=pathlib.Path("poetry.lock"),
            project_install_mode="dependencies_only",
        )
    ),
)


@env.task
def calculate(x: int) -> int:
    ...task code

@env.task
def fetch_data(url: str) -> str:
    ...task code

@env.task
def main(x_list: list[int]) -> dict:
    """Main workflow that processes a list of numbers."""
    print("hi")
    import numpy as np

    x_len = len(x_list)
    if x_len < 5:
        raise ValueError(f"x_list needs at least 5 items, found: {x_len}")

    # Run calculations in parallel using flyte.map
    results = list(flyte.map(calculate, x_list))

    # Calculate statistics using numpy
    y_mean = float(np.mean(results))
    y_std = float(np.std(results))

    # Fetch some example data
    data_info = fetch_data("<https://httpbin.org/get>")

    return {
        "mean": y_mean,
        "std": y_std,
        "results": results,
        "data_info": data_info,
    }


if __name__ == "__main__":
    # Initialize remote connection
    flyte.init_from_config()

    # Run the workflow remotely
    run = flyte.run(main, x_list=list(range(10)))

    # Wait for completion and stream logs
    run.wait(run)
Local builder execute poetry install with
--no-root
mode: [截圖 2025-10-31 下午4 42 16](https://private-user-images.githubusercontent.com/66259759/508124205-1ff517d0-988a-4759-9926-c1a36762b639.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjIyMTgzODIsIm5iZiI6MTc2MjIxODA4MiwicGF0aCI6Ii82NjI1OTc1OS81MDgxMjQyMDUtMWZmNTE3ZDAtOTg4YS00NzU5LTk5MjYtYzFhMzY3NjJiNjM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTExMDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMTA0VDAxMDEyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAwZDM2Y2YzMjg1NWI0NDBmOTZmMTE5ODJjMzVmMDAwYzYxZjFlZGZiNjhkM2MzMWMyNWJiYzM5MmI4Y2IzZTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.dFgGUD8CoeadZ_cgajMBHYf0xnbHWAZ6yazZ7PX4JP0) Remote builder poetry install everything without project itself: [截圖 2025-10-31 下午5 15 52](https://private-user-images.githubusercontent.com/66259759/508124613-58b665a8-a585-433c-a79f-39e1b836d1dc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjIyMTgzODIsIm5iZiI6MTc2MjIxODA4MiwicGF0aCI6Ii82NjI1OTc1OS81MDgxMjQ2MTMtNThiNjY1YTgtYTU4NS00MzNjLWE3OWYtMzllMWI4MzZkMWRjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTExMDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMTA0VDAxMDEyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlYTQxZGM4Mzc1MmFlMGE4MGVmODZiZDkzNGQ5ZTQzYzExOGFlNGQxMGY4NTA3ZjBlZmRhMDZkNDkzMzg1NzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.dT93Tdil_7wp7BaB0K5s1p61YsxeuH9wbl6vXiw0Rbs) flyteorg/flyte-sdk