|
PCART
v1.4
Automated Repair of Python API Parameter Compatibility Issues
|
Analyze API parameter changes and compatibility. More...
Classes | |
| class | Update |
| Update class for parameter change analysis 参数变更分析类 More... | |
Functions | |
| def | addValueForAPI (callAPI, projName, runPath, runCommand, currentEnv, targetEnv, errLst, callKey, *runtimePaths) |
| Add values stored by pkl file for API parameters 为API参数添加保存至pkl文件中的值 More... | |
| def | analyzeCompatibility (oldPara, newPara) |
| Analyze the compatibility of two APIs 判断两个重载API是否兼容 More... | |
| def | findDiffer (oldPara, newPara) |
| Determine difference of two parameters 输入两个api参数部分,判断参数部分有何不同 More... | |
| def | isCompatible (current, target) |
| Determine the compatibility of APIs from current and target versions 判断起始版本和目标版本API的兼容性 More... | |
| def | isDifferType (oldType, newType) |
| Determine parameter type change: compatible type means no type change 判断两个参数的类型是否发生了变更: 只要兼容,就认为相同 More... | |
| def | para2Obj (paraStr) |
| Convert parameter string to positional and keyword parameter objects 将参数字符串转换为位置和关键字参数对象 More... | |
| def | querySharedDict (callAPI, sharedDict) |
| Query API mapping dictionary 查询API映射字典 More... | |
| def | updateErrorLst (errorLog, errorLst) |
| Save error messages 保存错误信息 More... | |
| def | updateSharedDict (callAPI, currentDict, targetDict, sharedDict) |
| Update API mapping dictionary: add and revise 更新API映射字典: 添加和修改 More... | |
Analyze API parameter changes and compatibility.
Compares API signatures between library versions to detect 10 parameter change types (addition, removal, renaming, reordering, type change, pos↔key conversion). Core functions: isCompatible(), findDiffer(), addValueForAPI(). 比较库版本间API签名,检测10种参数变更类型(新增、删除、重命名、重排序、 类型变更、位置↔关键字转换)。核心函数:isCompatible()、findDiffer()、addValueForAPI()。
| def changeAnalyze.addValueForAPI | ( | callAPI, | |
| projName, | |||
| runPath, | |||
| runCommand, | |||
| currentEnv, | |||
| targetEnv, | |||
| errLst, | |||
| callKey, | |||
| * | runtimePaths | ||
| ) |
Add values stored by pkl file for API parameters 为API参数添加保存至pkl文件中的值
| callAPI | The API call |
| projName | The project name |
| runPath | The relative path of the run file |
| runCommand | The run command of the project |
| currentEnv | Virtual environment of the current version |
| targetEnv | Virtual environment of the target version |
| errLst | Error message logging list |
| callKey | Unique callsite artifact id |
| runtimePaths | Runtime artifact paths for the current PCART workspace |
Definition at line 636 of file changeAnalyze.py.
| def changeAnalyze.analyzeCompatibility | ( | oldPara, | |
| newPara | |||
| ) |
Analyze the compatibility of two APIs 判断两个重载API是否兼容
分位置参数和关键字参数进行分析 判断标准 位置参数:位置和名称相同,且类型兼容,认为兼容 关键字参数:名字相同且类型兼容,认为兼容
| oldPara | The old parameter from current version |
| newPara | The new parameter from target version |
Definition at line 493 of file changeAnalyze.py.
| def changeAnalyze.findDiffer | ( | oldPara, | |
| newPara | |||
| ) |
Determine difference of two parameters 输入两个api参数部分,判断参数部分有何不同
| oldPara | The old parameter from current version |
| newPara | The new parameter from target version |
Definition at line 302 of file changeAnalyze.py.
| def changeAnalyze.isCompatible | ( | current, | |
| target | |||
| ) |
Determine the compatibility of APIs from current and target versions 判断起始版本和目标版本API的兼容性
兼容返回空列表,不兼容返回则返回需要修复的字典,可能会有多个
| current | API parameter signature(s) from current version |
| target | API parameter signature(s) from target version |
Definition at line 556 of file changeAnalyze.py.
| def changeAnalyze.isDifferType | ( | oldType, | |
| newType | |||
| ) |
Determine parameter type change: compatible type means no type change
判断两个参数的类型是否发生了变更: 只要兼容,就认为相同
Union[int,float],表示类型是int或float Optional[int],表示变量的类型是int或值为None,等价于Union[int,None] None即可以表示类型也可以表示值 Optional[Union[int, str]]表示参数的类型为int,str或None Union[Callable[[torch.Tensor,str],torch.Tensor],torch.device,str,Dict[str,str],NoneType]=None
| oldType | The parameter type from the current version |
| newType | The parameter type from the target version |
Definition at line 162 of file changeAnalyze.py.
| def changeAnalyze.para2Obj | ( | paraStr | ) |
Convert parameter string to positional and keyword parameter objects 将参数字符串转换为位置和关键字参数对象
| paraStr | The full string of API parameters |
Definition at line 228 of file changeAnalyze.py.
| def changeAnalyze.querySharedDict | ( | callAPI, | |
| sharedDict | |||
| ) |
Query API mapping dictionary 查询API映射字典
| callAPI | The called API for query |
| sharedDict | The API mapping dictionary: multiprocessing.manager.dict() |
Definition at line 114 of file changeAnalyze.py.
| def changeAnalyze.updateErrorLst | ( | errorLog, | |
| errorLst | |||
| ) |
Save error messages 保存错误信息
| errorLog | Log file |
| errorLst | The error messages |
Definition at line 101 of file changeAnalyze.py.
| def changeAnalyze.updateSharedDict | ( | callAPI, | |
| currentDict, | |||
| targetDict, | |||
| sharedDict | |||
| ) |
Update API mapping dictionary: add and revise 更新API映射字典: 添加和修改
| callAPI | The called API for update |
| currentDict | The API signature of the current version |
| targetDict | The API signature of the target version |
| sharedDict | The API mapping dictionary: multiprocessing.manager.dict() |
Definition at line 132 of file changeAnalyze.py.