feat(config): honour EFINANCE_CACHE_DIR env var#244
Open
enihcam wants to merge 2 commits into
Open
Conversation
Upstream hardcodes DATA_DIR = HERE/../data and unconditionally mkdir()s at import. RO rootfs (container, system Python) breaks the import with PermissionError. 3-step resolution: * $EFINANCE_CACHE_DIR (user override) * $XDG_CACHE_HOME/efinance * legacy default (unchanged behaviour) mkdir() is best-effort: OSError is logged, not raised. Default path and constants unchanged when no env var is set. Refs daily_stock_analysis#1977.
Author
|
@Micro-sheep please take a look. this is important for docker-friendly setup of efinance applications. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
efinance/config/__init__.py硬编码DATA_DIR = HERE / "../data",import 时无条件mkdir(parents=True, exist_ok=True)。在只读 rootfs(容器、system Python)下,import 阶段PermissionError,整个包无法加载。修改
3 步解析:
$EFINANCE_CACHE_DIR若设置(用户覆盖)$XDG_CACHE_HOME/efinance<site-packages>/efinance/../data(原默认,向后兼容)mkdir 改为 best-effort:失败只 log,不 raise。
MAX_CONNECTIONS = 50/SHOW_TICKFLOW_PROMPT = True不动;SEARCH_RESULT_CACHE_PATH字段名不动,值在 env 覆盖时跟随 env。efinance.utils.SEARCH_RESULT_CACHE_PATH等 re-export 路径不动。验证
相关
下游 daily_stock_analysis 容器化部署需要:ZhuLinsen/daily_stock_analysis#1977