-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Typing] Ensure packaging tensor.pyi
into wheel
#64575
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/CMakeLists.txt
Outdated
COMMAND | ||
${CMAKE_COMMAND} -E copy | ||
${PADDLE_BINARY_DIR}/python/paddle/tensor/tensor.pyi | ||
${PADDLE_SOURCE_DIR}/python/paddle/tensor/tensor.pyi |
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.
话说这几部分有可以复用的么?是否可以写成函数?
from paddle import _C_ops | ||
|
||
try: | ||
from paddle import version |
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.
这里同样,删掉 version import,改成 paddle.version
就好了
Update 20240525
@SigureMo 请评审 ~ |
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.
其余感觉没啥问题,等 6.2 拉分支之后会合入看看效果,如果 QA 那边没有反馈更多非 CI 流水线监控硬件编译问题,就没啥问题了~
tools/gen_tensor_stub.py
Outdated
def generate_stub_file(input_file=None, output_file=None): | ||
if input_file is None or output_file is None: | ||
args = parse_args() | ||
input_file = args.input_file | ||
output_file = args.output_file |
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.
可以考虑改成
def generate_stub_file(input_file, output_file): ...
def main():
args = parse_args()
generate_stub_file(args.input_file, args.output_file)
这样分层应该会更合理些
tools/gen_tensor_stub.py
Outdated
try: | ||
import paddle | ||
except ImportError: | ||
sys.stderr.write( | ||
'''ERROR: Can NOT import paddle. | ||
We could import paddle without installation, with all libs (.dll or .so) copied into dir `paddle/libs`, | ||
or path already been set for the system. | ||
''' | ||
) | ||
raise |
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.
可以考虑抽成函数:
def try_import_paddle() -> types.ModuleType | None: ...
def get_tensor_members():
paddle = try_import_paddle()
if not paddle:
raise Xxx()
...
python/paddle/__init__.py
Outdated
@@ -14,12 +14,16 @@ | |||
|
|||
import typing | |||
|
|||
is_paddle_installed = False |
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.
这里从其他开发者角度来看会有点奇怪,为什么没有安装却可以调用呢?这里是否可以赋予更细致的语义?比如这里应该是信息已生成,是否可以用 __is_metainfo_generated
?加 __
以免误 import,毕竟这是 __init__
Update 20240528
这里只有一处不同,原 def check_build_dependency():
missing_modules = '''Missing build dependency: {dependency}
Please run 'pip install -r python/requirements.txt' to make sure you have all the dependencies installed.
'''.strip()
with open(TOP_DIR + '/python/requirements.txt') as f: 取的目录是 而由于 def check_build_dependency():
missing_modules = '''Missing build dependency: {dependency}
Please run 'pip install -r python/requirements.txt' to make sure you have all the dependencies installed.
'''.strip()
with open('${PADDLE_SOURCE_DIR}' + '/python/requirements.txt') as f: 这两个目录应该是一样的,如有特殊情况还望告知 ~ |
tensor.pyi
into wheel
… type_hint_pack
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.
tensor.pyi
into wheeltensor.pyi
into wheel
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.
LGTM
PR Category
User Experience
PR Types
Bug fixes
Description
@SigureMo 请评审 ~
Related links