PCART  v1.4
Automated Repair of Python API Parameter Compatibility Issues
Classes | Functions
changeAnalyze Namespace Reference

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

Detailed Description

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()。

Function Documentation

◆ addValueForAPI()

def changeAnalyze.addValueForAPI (   callAPI,
  projName,
  runPath,
  runCommand,
  currentEnv,
  targetEnv,
  errLst,
  callKey,
runtimePaths 
)

Add values stored by pkl file for API parameters 为API参数添加保存至pkl文件中的值

Parameters
callAPIThe API call
projNameThe project name
runPathThe relative path of the run file
runCommandThe run command of the project
currentEnvVirtual environment of the current version
targetEnvVirtual environment of the target version
errLstError message logging list
callKeyUnique callsite artifact id
runtimePathsRuntime artifact paths for the current PCART workspace
Returns
lst[0] The API call string with added parameter values (load from pkl file)

Definition at line 636 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ analyzeCompatibility()

def changeAnalyze.analyzeCompatibility (   oldPara,
  newPara 
)

Analyze the compatibility of two APIs 判断两个重载API是否兼容

分位置参数和关键字参数进行分析 判断标准 位置参数:位置和名称相同,且类型兼容,认为兼容 关键字参数:名字相同且类型兼容,认为兼容

Parameters
oldParaThe old parameter from current version
newParaThe new parameter from target version
Returns
True/False Compatible or not

Definition at line 493 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findDiffer()

def changeAnalyze.findDiffer (   oldPara,
  newPara 
)

Determine difference of two parameters 输入两个api参数部分,判断参数部分有何不同

Parameters
oldParaThe old parameter from current version
newParaThe new parameter from target version
Returns
ansDict The dictionary of parameter changes for each parameter

Definition at line 302 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCompatible()

def changeAnalyze.isCompatible (   current,
  target 
)

Determine the compatibility of APIs from current and target versions 判断起始版本和目标版本API的兼容性

兼容返回空列表,不兼容返回则返回需要修复的字典,可能会有多个

Parameters
currentAPI parameter signature(s) from current version
targetAPI parameter signature(s) from target version
Returns
tempLst1/2 The repair operation dictionary if incompatible

Definition at line 556 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDifferType()

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

Parameters
oldTypeThe parameter type from the current version
newTypeThe parameter type from the target version
Returns
newType Return newType if type difference exists or return False

Definition at line 162 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ para2Obj()

def changeAnalyze.para2Obj (   paraStr)

Convert parameter string to positional and keyword parameter objects 将参数字符串转换为位置和关键字参数对象

Parameters
paraStrThe full string of API parameters
Returns
(posParameters, keyParameters) Tuple of positional and keyword parameter lists

Definition at line 228 of file changeAnalyze.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ querySharedDict()

def changeAnalyze.querySharedDict (   callAPI,
  sharedDict 
)

Query API mapping dictionary 查询API映射字典

Parameters
callAPIThe called API for query
sharedDictThe API mapping dictionary: multiprocessing.manager.dict()
Returns
ansDict The query result

Definition at line 114 of file changeAnalyze.py.

Here is the caller graph for this function:

◆ updateErrorLst()

def changeAnalyze.updateErrorLst (   errorLog,
  errorLst 
)

Save error messages 保存错误信息

Parameters
errorLogLog file
errorLstThe error messages
Returns
None

Definition at line 101 of file changeAnalyze.py.

Here is the caller graph for this function:

◆ updateSharedDict()

def changeAnalyze.updateSharedDict (   callAPI,
  currentDict,
  targetDict,
  sharedDict 
)

Update API mapping dictionary: add and revise 更新API映射字典: 添加和修改

Parameters
callAPIThe called API for update
currentDictThe API signature of the current version
targetDictThe API signature of the target version
sharedDictThe API mapping dictionary: multiprocessing.manager.dict()
Returns
None

Definition at line 132 of file changeAnalyze.py.

Here is the caller graph for this function: