Skip to content

Trace api - #70752

Merged
wanghuancoder merged 14 commits into
PaddlePaddle:developfrom
wanghuancoder:trace_api
Jan 20, 2025
Merged

Trace api#70752
wanghuancoder merged 14 commits into
PaddlePaddle:developfrom
wanghuancoder:trace_api

Conversation

@wanghuancoder

@wanghuancoder wanghuancoder commented Jan 9, 2025 •

Copy link
Copy Markdown
Contributor

PR Category

Execute Infrastructure

PR Types

New features

Description

增加抓取API调用配置的能力,抓取的API配置可用于自动化测试。

用法:

export FLAGS_trace_api="/data/api.yaml,/data/api_config.txt"

# api.yaml
apis:
  -  paddle.abs
  -  paddle.abs_
  -  paddle.acos
  -  paddle.acosh
  -  paddle.addmm
  -  paddle.all
  -  paddle.amax

Pcard-67164

@paddle-bot

paddle-bot Bot commented Jan 9, 2025

Copy link
Copy Markdown

你的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.

def start_api_tracer(api_path, save_config_path):
import paddle

print(paddle.__version__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

建议使用 logging

setattr(HookAPIMap, api, getattr(eval(parent_package), method_name))
setattr(eval(parent_package), method_name, wrapped_api(api))
except Exception as err:
print("[api_tracer error] : start_api_tracer ", api, str(err))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上

Comment thread python/paddle/__init__.py
save_config_path = os.environ.get(
"FLAGS_trace_api_save_config_path", "api_configs.txt"
)
start_api_tracer(api_path, save_config_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

建议整合一下 FLAG

result = result + key + "=" + tmp + ", "

result = result + ")"
# self.file.write(") -> ")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Delete unused code

zhangbo9674
zhangbo9674 previously approved these changes Jan 16, 2025

@zhangbo9674 zhangbo9674 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants