|
PCART
v1.4
Automated Repair of Python API Parameter Compatibility Issues
|
Repair and validate API parameter compatibility issues
More...
Functions | |
| def | findName (pos, dic) |
| Find parameter name by its position 通过位置查找参数名 More... | |
| def | fix (callAPI, repairDict, node, starFlag, twoStarFlag) |
| Perform parameter repair operations through AST 通过AST执行参数修复操作 More... | |
| def | mapName (name, dic) |
| Get repair operation dictionary of keyword parameter 获取关键字参数的修复操作字典 More... | |
| def | mapPos (pos, dic) |
| Get repair operation dictionary of positional parameter 获取位置参数的修复操作字典 More... | |
| def | mirrorAPI (fixedAPI, dic) |
| Create mirror for the fixed API by adding all parameter names 给修复后API的参数填上参数名 More... | |
| def | repairTask (root, callAPI, apiWithValue, projName, runPath, runCommand, repairLst, virtualEnv, errLst, callKey, *runtimePaths) |
| Task of repairing parameter compatibility issues 参数兼容性问题修复任务 More... | |
| def | validateByRun (callAPI, apiWithValue, projName, virtualEnv, runPath, runCommand, callKey, *runtimePaths) |
| Dynamic validation 动态验证 More... | |
| def | validateByStr (fixedAPI, repairDict, targetAPIDefinition, starFlag, twoStarFlag) |
| Static validation 静态验证 More... | |
Repair and validate API parameter compatibility issues
Repairs API parameter compatibility issues at the AST level. Uses a two-stage validation strategy: static validation (signature check via mirrorAPI) and dynamic validation (running repaired code in targetEnv via validateByRun). The fix() function applies repair operations (delete, rename, reorder, pos↔key conversion) directly on AST nodes. 在AST层面修复API参数兼容性问题。采用两阶段验证策略:静态验证(通过mirrorAPI 进行签名检查)和动态验证(通过validateByRun在targetEnv中运行修复后代码)。 fix()函数直接在AST节点上应用修复操作(删除、重命名、重排序、位置↔关键字转换)。
| def repair.findName | ( | pos, | |
| dic | |||
| ) |
| def repair.fix | ( | callAPI, | |
| repairDict, | |||
| node, | |||
| starFlag, | |||
| twoStarFlag | |||
| ) |
Perform parameter repair operations through AST 通过AST执行参数修复操作
| callAPI | The API call |
| repairDict | Repair operation dictionary |
| node | The AST node of the API call |
| starFlag | Flag of * |
| twoStarFlag | Flag of ** |
Definition at line 142 of file repair.py.
| def repair.mapName | ( | name, | |
| dic | |||
| ) |
Get repair operation dictionary of keyword parameter 获取关键字参数的修复操作字典
Here, keyword parameter means that the parameter is passed by parameter name 此处,关键字参数指带参数名进行传递的参数
| name | Parameter name |
| dic | Repair operation dictionary |
Definition at line 54 of file repair.py.
| def repair.mapPos | ( | pos, | |
| dic | |||
| ) |
Get repair operation dictionary of positional parameter 获取位置参数的修复操作字典
Here, positional parameter means that the parameter is passed by position without parameter name 此处,位置参数指按位置而不带参数名进行传递的参数
| pos | Parameter position |
| dic | Repair operation dictionary |
Definition at line 34 of file repair.py.
| def repair.mirrorAPI | ( | fixedAPI, | |
| dic | |||
| ) |
| def repair.repairTask | ( | root, | |
| callAPI, | |||
| apiWithValue, | |||
| projName, | |||
| runPath, | |||
| runCommand, | |||
| repairLst, | |||
| virtualEnv, | |||
| errLst, | |||
| callKey, | |||
| * | runtimePaths | ||
| ) |
Task of repairing parameter compatibility issues 参数兼容性问题修复任务
Checks whether apiWithValue is available. Repair success = formal fix + successful run. Returns 3 values: repair result, formal compatibility, and whether the repair succeeded. Note: after a static-only fix, the return value alone cannot distinguish dynamic success from static-only validation — an extra label is returned for this purpose. 需要判断一下apiWithValue是否为空。修复成功=形式上修复成功+成功运行。 函数返回3个值:修复结果,形式上的兼容性,是否修复成功。 修完之后无法通过返回值判断是动态修复成功还是只经过了静态验证,因此额外返回标签。
| root | The AST root of the source file |
| callAPI | The API call |
| apiWithValue | The API call with value added by loading the pkl file |
| projName | The project name |
| runPath | The relative path of the run file |
| runCommand | The run command of the project |
| repairLst | List of repair operation dictionary |
| virtualEnv | The virtual environment of the target lib version |
| errLst | List of error messages |
| callKey | Unique callsite artifact id |
| runtimePaths | Runtime artifact paths for the current PCART workspace |
Definition at line 383 of file repair.py.
| def repair.validateByRun | ( | callAPI, | |
| apiWithValue, | |||
| projName, | |||
| virtualEnv, | |||
| runPath, | |||
| runCommand, | |||
| callKey, | |||
| * | runtimePaths | ||
| ) |
Dynamic validation 动态验证
| callAPI | The API call |
| apiWithValue | The API call with value added by loading the pkl file |
| projName | The project name |
| virtualEnv | The virtual environment of the target lib version |
| runPath | The relative path of the run file |
| runCommand | The run command of the project |
| callKey | Unique callsite artifact id |
| runtimePaths | Runtime artifact paths for the current PCART workspace |
Definition at line 278 of file repair.py.
| def repair.validateByStr | ( | fixedAPI, | |
| repairDict, | |||
| targetAPIDefinition, | |||
| starFlag, | |||
| twoStarFlag | |||
| ) |
Static validation 静态验证
| fixedAPI | The fixed API |
| repairDict | Repair operation dictionary |
| targetAPIDefinition | API definition of target lib version |
| starFlag | Flag of * |
| twoStarFlag | Flag of ** |
Definition at line 332 of file repair.py.