Пример #1
0
 def extract_outputs(nb: str) -> LiteralMap:
     """
     Parse Outputs from Notebook.
     This looks for a cell, with the tag "outputs" to be present.
     """
     with open(nb) as json_file:
         data = json.load(json_file)
         for p in data["cells"]:
             meta = p["metadata"]
             if "outputs" in meta["tags"]:
                 outputs = " ".join(p["outputs"][0]["data"]["text/plain"])
                 m = _pb2_LiteralMap()
                 _text_format.Parse(outputs, m)
                 return LiteralMap.from_flyte_idl(m)
     return None
Пример #2
0
 def extract_outputs(nb: str) -> LiteralMap:
     """
     Parse Outputs from Notebook.
     This looks for a cell, with the tag "outputs" to be present.
     """
     with open(nb) as json_file:
         data = json.load(json_file)
         for p in data["cells"]:
             meta = p["metadata"]
             if "outputs" in meta["tags"]:
                 # Sometimes log messages will be in the list of outputs, so iterate to find where
                 # the data is.
                 for record in p["outputs"]:
                     if "data" in record:
                         outputs = " ".join(record["data"]["text/plain"])
                         m = _pb2_LiteralMap()
                         _text_format.Parse(outputs, m)
                         return LiteralMap.from_flyte_idl(m)
     return None