From 26f6b2f453422ebdc42933013a0b96c40ff78fa7 Mon Sep 17 00:00:00 2001 From: Mark Hamilton Date: Wed, 17 Apr 2024 16:09:55 -0400 Subject: [PATCH] chore: add conda env caching --- templates/conda.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/templates/conda.yml b/templates/conda.yml index 7522196fb5..2f2942adb7 100644 --- a/templates/conda.yml +++ b/templates/conda.yml @@ -2,19 +2,21 @@ steps: - bash: echo "##vso[task.prependpath]$CONDA/bin" displayName: Add conda to PATH retryCountOnTaskFailure: 1 - # - bash: sudo chown -R $(whoami):$(id -ng) $(CONDA_CACHE_DIR) -# displayName: Fix directory permissions -# - task: Cache@2 -# displayName: Use cached Anaconda environment -# inputs: -# key: 'conda | "$(Agent.OS)" | environment.yml' -# restoreKeys: | -# python | "$(Agent.OS)" -# python -# path: $(CONDA_CACHE_DIR) -# cacheHitVar: CONDA_CACHE_RESTORED + - bash: sudo chown -R $(whoami):$(id -ng) $(CONDA_CACHE_DIR) + displayName: Fix directory permissions + - task: Cache@2 + displayName: Use cached Anaconda environment + inputs: + key: 'conda | "$(Agent.OS)" | environment.yml' + restoreKeys: | + python | "$(Agent.OS)" + python + path: $(CONDA_CACHE_DIR) + cacheHitVar: CONDA_CACHE_RESTORED + timeoutInMinutes: 20 + retryCountOnTaskFailure: 1 - bash: | (timeout 30m conda env create --force -f environment.yml -v) || (timeout 30m conda env create --force -f environment.yml -v) displayName: Create Anaconda environment retryCountOnTaskFailure: 1 -# condition: eq(variables.CONDA_CACHE_RESTORED, 'false') + condition: eq(variables.CONDA_CACHE_RESTORED, 'false')