Skip to content

Conversation

@algorithm1832
Copy link
Contributor

@algorithm1832 algorithm1832 commented Jan 5, 2026

PR Category

User Experience

PR Types

Improvements

Description

  • Copy code from paddle.io to paddle.utils.data
  • Add unittests

Used AI Studio


Notes:

  • In unittests, TestTensorDataset failed due to tensor shape mismatch (but it has nothing to do with this PR)
  • New apis' EN docs should be made easy (with a link to the original API doc), but I am not sure so no changes made
  • I can only copy code to add function alias. If I use import, a circular import problem will raise, because paddle.base imports function from utils, and the dataset classes in paddle.io import paddle.base

@paddle-bot
Copy link

paddle-bot bot commented Jan 5, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Jan 5, 2026
_T = TypeVar('_T')


class Dataset(Generic[_T]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个与原来的实现的关系是?

这个需要只保留一份,另外一份作为别名使用。

保持代码复用,避免维护两套代码。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

实际上是函数别名,理论上在此处直接import就可以,不需要额外代码

但是直接import会出现循环依赖(现在这份代码其实也存在循环依赖,还在排查)

直接import出现循环依赖的原因是:paddle.base初始化的时候,会调用utils里面的一个函数,但utils里面import Dataset会进一步import paddle.base,从而导致循环依赖

@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 40.74074% with 32 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@4719302). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/utils/data/dataset.py 40.00% 30 Missing ⚠️
python/paddle/io/dataloader/dataset.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #77212   +/-   ##
==========================================
  Coverage           ?   40.74%           
==========================================
  Files              ?        3           
  Lines              ?       54           
  Branches           ?        0           
==========================================
  Hits               ?       22           
  Misses             ?       32           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhwesky2010
Copy link
Contributor

这个可能得设计一下这个import关系,比如解耦一些依赖。

@algorithm1832
Copy link
Contributor Author

utils可能需要重构,短时间内无法完成本PR涉及的API兼容性工作

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants