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?
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-buildsHowever, 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/repositoryIf 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:
to:
Is my understanding correct, or is there something I'm missing about how UV_CACHE_DIR is intended to be used in ClearML?