def __init__(self, current_frame):
"""
Init the MetaPrameterRecord with "Agent" parameters by passing inspect.currentframe() from Agent Class
The Init will search back to find the parent class to capture all passed parameters and store
them in "self.meta_params".
NOTE: Currently only optimized for TensorBoard output
TODO: Add JSON Export, TEXT EXPORT
Args:
current_frame: frame value from class to obtain metaparameters[= inspect.currentframe()]
"""
self.ignore_unknown_dtypes = False
self.meta_params = dict()
self.method_calling = inspect.getframeinfo(current_frame)[2]
_, _, __, self.vals_current = inspect.getargvalues(current_frame)
# self is the class name of the frame involved
if 'self' in self.vals_current:
self.recorded_class_type = self.vals_current['self']
# Add explicit AgentName item so class can be deleted
self.meta_params['AgentName'] = str(self.vals_current['self'])
frame_list = inspect.getouterframes(current_frame)
for frame in frame_list:
# Rather than frame.frame (named tuple), use [0] for python2
args, varargs, keywords, vals =inspect.getargvalues(frame[0])
if 'self' in vals:
if self.recorded_class_type == vals['self']:
for i in args:
self.meta_params[i] = vals[i]
# Remove the "CLASS" from the dictionary, has no value "AgentName" contains STR of Class
del self.meta_params['self']
meta_parameter_recorder.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录