Skip to content

Setting UV_CACHE_DIR to agent.venvs_dir generate experiments conflicts in docker with multiple agents. #256

Description

@ffvogmv

By default, UV_CACHE_DIR is set to agent.venvs, which is also the directory where the experiment task repository is cloned and executed. In Docker environments, if we want this folder to be shared (e.g., mounted as a volume), we typically do something like:

-v host_venvs_build:/root/.clearml/venvs-builds

However, this setup causes conflicts when multiple experiments run concurrently on the same host. This is because the repository is cloned into:

/root/.clearml/venvs-builds/3.11/task_repository/repository

If this folder is shared across experiments, files may be modified simultaneously by different tasks using the same repository, leading to race conditions and unexpected behavior.

To resolve this, I used the uv_sync_extra_args configuration option:

uv_sync_extra_args: ["--cache-dir", "/root/.clearml/venvs-cache"]

This forces uv to use /root/.clearml/venvs-cache as the cache directory, which I believe is the intended default used by the framework.

Suggested Fix:

In clearml_agent/helper/package/uv_api.py, I suggest changing:

cache_dir = self.session.config.get("agent.venvs_dir", None)
if cache_dir is not None:
    kwargs["env"]["UV_CACHE_DIR"] = cache_dir

to:


cache_dir = self.session.config.get("agent.venvs_cache.path", None)
if cache_dir is not None:
    kwargs["env"]["UV_CACHE_DIR"] = cache_dir

Is my understanding correct, or is there something I'm missing about how UV_CACHE_DIR is intended to be used in ClearML?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions