aws / aws/sagemaker-python-sdk
Importing sagemaker seems to enable rich tracebacks
- 主要语言
- Python
- 星标
- 2.3k
- 派生
- 1.3k
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 35
描述
**Describe the bug**
Whenever sagemaker is imported, it seems to modify and automatically enable [rich](https://github.com/Textualize/rich) tracebacks.
**To reproduce**
Make a new environment
```console
$ python -m venv .venv
$ source /.venv/bin/activate
$ python -m pip install sagemaker rich
```
Make a file that returns a traceback
```python
"""rich_sage.py"""
import sagemaker
def main() -> None:
raise ValueError
if __name__ == "__main__":
main()
```
Run the file
```console
$ python rich_sage.py
sagemaker.config INFO - Not applying SDK defaults from location: /Library/Application Support/sagemaker/config.yaml
sagemaker.config INFO - Not applying SDK defaults from location: /Users/pawlu/Library/Application Support/sagemaker/config.yaml
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/pawlu/Documents/scratch/rich_sage/sage_me.py:9 in │
│ │
│ 6 │
│ 7 │
│ 8 if __name__ == "__main__": │
│ ❱ 9 │ main() │
│ 10 │
│ │
│ /Users/pawlu/Documents/scratch/rich_sage/sage_me.py:5 in main │
│ │
│ 2 │
│ 3 │
│ 4 def main() -> None: │
│ ❱ 5 │ raise ValueError │
│ 6 │
│ 7 │
│ 8 if __name__ == "__main__": │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError
```
If the import statement is removed,
```diff
- import sagemaker
```
then the traceback renders as expected
```console
$ python rich_sage.py
Traceback (most recent call last):
File "/Users/pawlu/Documents/scratch/rich_sage/sage_me.py", line 8, in
main()
File "/Users/pawlu/Documents/scratch/rich_sage/sage_me.py", line 4, in main
raise ValueError
ValueError
```
**Expected behavior**
Ideally, tracebacks shouldn't be modified without users input. At worst there should be a way to opt out of this. But we shouldn't be modifying tracebacks automatically at import. It's a tricky behavior that's hard to debug.
**Screenshots or logs**
**System information**
A description of your system. Please provide:
- **SageMaker Python SDK version**: 2.244.0
- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**: Rich
- **Framework version**: 14.0.0
- **Python version**: 3.12.9
- **CPU or GPU**: M3 (macbook)
- **Custom Docker image (Y/N)**: N
---
Thank you very much!
贡献指南
调研方向
使用报告的 SageMaker 和 Rich 版本运行 rich_sage.py 中的复现,并比较有无 import sagemaker 时的 traceback 输出。追踪 SageMaker 包中的导入副作用,并验证导入它不再会在没有用户操作的情况下启用 Rich tracebacks。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- machine-learning
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100