You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS SageMaker Studio中Git GUI兼容pre-commit钩子问题排查

AWS SageMaker Studio中Git GUI无法兼容pre-commit钩子问题

我们已在传统开发环境中配置并启用pre-commit运行Git钩子,且运行正常,但在AWS SageMaker Studio的内置Git GUI中,pre-commit(或Git钩子)无法正常工作。

问题详情

Git GUI无法正常提交,但通过SageMaker Studio的Jupyter Notebook单元格执行shell命令可正常运行:

  • 暂存变更后,点击Git GUI的提交按钮立即报错:/opt/conda/bin/python: No module named pre_commit
  • 在Notebook单元格中执行!git commit -m <message>时,提交及钩子可正常运行。

这表明Git面板的环境独立于Notebook内核环境,但Notebook单元格执行!git status和系统终端执行git status显示的暂存/变更/未跟踪文件完全一致。

尝试在系统终端执行pip install pre-commit后,原报错消失,但出现新错误:

An error has occurred: InvalidManifestError: =====> /root/.cache/pre-commit/repogox81zzt/.pre-commit-hooks.yaml is not a file Check the log at /home/sagemaker-user/.cache/pre-commit/pre-commit.log

日志信息

pre-commit version: 3.5.0
git --version: git version 2.40.1
sys.version:
3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 08:45:29)
[GCC 10.4.0]
sys.executable: /opt/conda/bin/python3.9
os.name: posix
sys.platform: linux

### error information

An error has occurred: InvalidManifestError:
=====> /root/.cache/pre-commit/repogox81zzt/.pre-commit-hooks.yaml is not a file
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/opt/conda/lib/python3.9/site-packages/pre_commit/main.py", line 386, in main
return hook_impl(
File "/opt/conda/lib/python3.9/site-packages/pre_commit/commands/hook_impl.py", line 271, in hook_impl
return retv | run(config, store, ns)
File "/opt/conda/lib/python3.9/site-packages/pre_commit/commands/run.py", line 425, in run
for hook in all_hooks(config, store)
File "/opt/conda/lib/python3.9/site-packages/pre_commit/repository.py", line 252, in all_hooks
return tuple(
File "/opt/conda/lib/python3.9/site-packages/pre_commit/repository.py", line 255, in <genexpr>
for hook in _repository_hooks(repo, store, root_config)
File "/opt/conda/lib/python3.9/site-packages/pre_commit/repository.py", line 230, in _repository_hooks
return _cloned_repository_hooks(repo_config, store, root_config)
File "/opt/conda/lib/python3.9/site-packages/pre_commit/repository.py", line 197, in _cloned_repository_hooks
by_id = {hook['id']: hook for hook in load_manifest(manifest_path)}
File "/opt/conda/lib/python3.9/site-packages/cfgv.py", line 416, in load_from_filename
return apply_defaults(data, schema)
File "/opt/conda/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/opt/conda/lib/python3.9/site-packages/cfgv.py", line 45, in reraise_as
raise tp(e).with_traceback(tb) from None
File "/opt/conda/lib/python3.9/site-packages/cfgv.py", line 42, in reraise_as
yield
File "/opt/conda/lib/python3.9/site-packages/cfgv.py", line 401, in load_from_filename
raise ValidationError(f'{display_filename} is not a file')
pre_commit.clientlib.InvalidManifestError:
=====> /root/.cache/pre-commit/repogox81zzt/.pre-commit-hooks.yaml is not a file

补充说明

  • 使用AWS托管的标准Data Science 3.0内核创建Notebook
  • 项目的.pre-commit-config.yaml配置如下:
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.4.0
  hooks:
  - id: trailing-whitespace
  - id: end-of-file-fixer
  - id: check-yaml
- repo: https://github.com/psf/black
  rev: 23.9.1
  hooks:
  - id: black
    args: [
    "--line-length", "88"
    ]
- repo: https://github.com/asottile/reorder-python-imports
  rev: v3.12.0
  hooks:
  - id: reorder-python-imports
- repo: local
  hooks:
  -   id: pytest
      name: Run pytest
      entry: pytest -v --ignore="docs/*"
      language: python
      pass_filenames: false
      additional_dependencies: [aioboto3==11.2.0]

内容的提问来源于stack exchange,提问作者alecbn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 15:45:08