def process(self, result_obj: ActivityRecord, data: List[ExecutionData], status: Dict[str, Any], metadata: Dict[str, Any]) -> ActivityRecord: """Method to update a result object based on code and result data Args: result_obj(ActivityNote): An object containing the note data(list): A list of ExecutionData instances containing the data for this record status(dict): A dict containing the result of git status from gitlib metadata(str): A dictionary containing Dev Env specific or other developer defined data Returns: ActivityNote """ with result_obj.inspect_detail_objects() as detail_objs: orig_num = result_obj.num_detail_objects if result_obj.num_detail_objects > 255: result_obj.trim_detail_objects(255) adr = ActivityDetailRecord(ActivityDetailType.NOTE, show=True, importance=0, action=ActivityAction.NOACTION) adr.add_value('text/markdown', f"This activity produced {orig_num} detail records, " f"but was truncated to the top 255 items. Inspect your code to make " f"sure that this was not accidental. In Jupyter for example, you can" f" use a `;` at the end of a line to suppress output from functions" f" that print excessively.") result_obj.add_detail_object(adr) return result_obj
def process(self, result_obj: ActivityRecord, data: List[ExecutionData], status: Dict[str, Any], metadata: Dict[str, Any]) -> ActivityRecord: with result_obj.inspect_detail_objects() as old_details: for idx, detail in enumerate(old_details): if detail.type is ActivityDetailType.CODE_EXECUTED: code = detail.data['text/markdown'] res = self.comment_re.search(code) if res: directive = res[1] if directive == 'auto': # This is the default behavior pass elif directive in ['show', 'hide', 'ignore']: for tag in detail.tags: # currently, the 'ex1' type tags are the only ones... if tag.startswith('ex'): result_obj.modify_tag_visibility( tag, directive) else: # TODO DC Currently we don't have a mechanism to highlight any problem to users. # But this is where we could signal an unknown comment directive. Another place # would be in the jupyterlab extension. We need to think through this UX! pass return result_obj
def process(self, result_obj: ActivityRecord, data: List[ExecutionData], status: Dict[str, Any], metadata: Dict[str, Any]) -> ActivityRecord: """Method to update a result object based on code and result data Args: result_obj(ActivityNote): An object containing the note data(list): A list of ExecutionData instances containing the data for this record status(dict): A dict containing the result of git status from gitlib metadata(str): A dictionary containing Dev Env specific or other developer defined data Returns: ActivityNote """ result_obj.show = False with result_obj.inspect_detail_objects() as details: for detail in details: if detail.show: result_obj.show = True break return result_obj