Skip to content

Commit

Permalink
feat(python): support ITKWASM_CACHE_DIR for cache directory
Browse files Browse the repository at this point in the history
Provide a way to specify the cache directory on AWS Lambda, where the
user_cache_dir is not writable.
  • Loading branch information
thewtex committed May 21, 2024
1 parent d26d8c8 commit f05fe5d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/python/itkwasm/itkwasm/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import List, Union, Dict, Tuple, Set
import ctypes
import sys
import os

import numpy as np
try:
Expand Down Expand Up @@ -32,7 +33,10 @@

from wasmtime import Config, Store, Engine, Module, WasiConfig, Linker, WasmtimeError

_module_store_dir = Path(user_cache_dir("itkwasm"))
# Get the value of the ITKWASM_CACHE_DIR environment variable
# If it is not set, use the default cache directory
_module_store_dir = os.environ.get("ITKWASM_CACHE_DIR", user_cache_dir("itkwasm"))
_module_store_dir = Path(_module_store_dir)
_module_store_dir.mkdir(parents=True, exist_ok=True)

def array_like_to_bytes(arr: ArrayLike) -> bytes:
Expand Down

0 comments on commit f05fe5d

Please sign in to comment.