Repository navigation
Escape generated build environment metadata #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mr-Neutr0n
wants to merge
2
commits into
deepseek-ai:main
Choose a base branch
from
Mr-Neutr0n:fix/persistent-env-escaping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import importlib.util | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def load_setup_module(): | ||
| path = Path(__file__).parents[2] / 'setup.py' | ||
| spec = importlib.util.spec_from_file_location('deep_ep_setup_under_test', path) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 suggestion: load_setup_module 会执行 setup.py 的全部顶层代码,包括 import torch.utils.cpp_extension 和加载 find_pkgs 模块,测试因此隐式依赖 torch 安装。当前环境可用(已验证 2 passed),但若未来希望在无 torch 的 CI 上运行这些 host-only 测试,可考虑把 render_default_envs 与 persistent_env_names 移入独立的轻量模块。非阻塞。 🤖 v5 |
||
| module = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(module) | ||
| return module | ||
|
|
||
|
|
||
| class PersistentEnvironmentTests(unittest.TestCase): | ||
| def test_values_round_trip_through_generated_python(self): | ||
| setup = load_setup_module() | ||
| expected = { | ||
| 'EP_JIT_CACHE_DIR': "/tmp/o'neil\\jit-cache", | ||
| 'EP_NCCL_ROOT_DIR': '/opt/NCCL dir', | ||
| } | ||
|
|
||
| source = setup.render_default_envs(expected) | ||
| namespace = {} | ||
| exec(compile(source, 'envs.py', 'exec'), namespace) | ||
|
|
||
| self.assertEqual(namespace['persistent_envs'], expected) | ||
|
|
||
| def test_ignores_unrelated_environment_values(self): | ||
| setup = load_setup_module() | ||
| source = setup.render_default_envs({'UNRELATED': 'value'}) | ||
| namespace = {} | ||
| exec(compile(source, 'envs.py', 'exec'), namespace) | ||
|
|
||
| self.assertEqual(namespace['persistent_envs'], {}) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 suggestion: generate_default_envs 中 build_include_dir 变量创建后仅用于 os.makedirs,随后 open 又重新用 os.path.join(self.build_lib, 'deep_ep', ...) 拼了一次相同路径;可复用 build_include_dir 减少重复。非阻塞。
🤖 v5