Repository: voxel51/fiftyone
Issue: [BUG] Error loading FiftyOneDataset export with brain results

There is a bug in `fiftyone==0.8.0.1` that prevents importing an export of a dataset in `FiftyOneDataset` format that includes a brain result such as from `fiftyone.brain.compute_uniqueness()` whose RunResult is `None`:

```py
import fiftyone as fo
import fiftyone.zoo as foz
import fiftyone.brain as fob

dataset = foz.load_zoo_dataset("quickstart").clone()

fob.compute_uniqueness(dataset, uniqueness_field="uniqueness2")

# includes a `brain/uniqueness2.json` file in the export that simply contains `null`
dataset.export("/tmp/quick", fo.types.FiftyOneDataset)

# error: the `null` is not properly handled
dataset2 = fo.Dataset.from_dir("/tmp/quick", fo.types.FiftyOneDataset)
```


Changed files:
fiftyone/utils/data/importers.py, fiftyone/utils/data/exporters.py, fiftyone/core/runs.py

diff --git a/fiftyone/core/runs.py b/fiftyone/core/runs.py
index e7e241e28..8b2165358 100644
--- a/fiftyone/core/runs.py
+++ b/fiftyone/core/runs.py
@@ -513,6 +513,9 @@ class RunResults(etas.Serializable):
         Returns:
             a :class:`RunResults`
         """
+        if d is None:
+            return None
+
         run_results_cls = etau.get_class(d["cls"])
         return run_results_cls._from_dict(d, samples)
 
diff --git a/fiftyone/utils/data/exporters.py b/fiftyone/utils/data/exporters.py
index c81af8dd8..372139a15 100644
--- a/fiftyone/utils/data/exporters.py
+++ b/fiftyone/utils/data/exporters.py
@@ -996,14 +996,16 @@ def _export_evaluation_results(sample_collection, eval_dir):
     for eval_key in sample_collection.list_evaluations():
         results_path = os.path.join(eval_dir, eval_key + ".json")
         results = sample_collection.load_evaluation_results(eval_key)
-        etas.write_json(results, results_path)
+        if results is not None:
+            etas.write_json(results, results_path)
 
 
 def _export_brain_results(sample_collection, brain_dir):
     for brain_key in sample_collection.list_brain_runs():
         results_path = os.path.join(brain_dir, brain_key + ".json")
         results = sample_collection.load_brain_results(brain_key)
-        etas.write_json(results, results_path)
+        if results is not None:
+            etas.write_json(results, results_path)
 
 
 class ImageDirectoryExporter(UnlabeledImageDatasetExporter):
diff --git a/fiftyone/utils/data/importers.py b/fiftyone/utils/data/importers.py
index 9597a210b..73414b595 100644
--- a/fiftyone/utils/data/importers.py
+++ b/fiftyone/utils/data/importers.py
@@ -1203,16 +1203,9 @@ def _import_evaluation_results(dataset, eval_dir, eval_keys=None):
 
     for eval_key in eval_keys:
         json_path = os.path.join(eval_dir, eval_key + ".json")
-        if not os.path.exists(json_path):
-            logger.warning(
-                "Evaluation results for eval_key='%s' not found at '%s'",
-                eval_key,
-                json_path,
-            )
-            continue
-
-        results = fors.RunResults.from_json(json_path, dataset)
-        foe.EvaluationMethod.save_run_results(dataset, eval_key, results)
+        if os.path.exists(json_path):
+            results = fors.RunResults.from_json(json_path, dataset)
+            foe.EvaluationMethod.save_run_results(dataset, eval_key, results)
 
 
 def _import_brain_results(dataset, brain_dir, brain_keys=None):
@@ -1223,16 +1216,9 @@ def _import_brain_results(dataset, brain_dir, brain_keys=None):
 
     for brain_key in brain_keys:
         json_path = os.path.join(brain_dir, brain_key + ".json")
-        if not os.path.exists(json_path):
-            logger.warning(
-                "Brain results for brain_key='%s' not found at '%s'",
-                brain_key,
-                json_path,
-            )
-            continue
-
-        results = fors.RunResults.from_json(json_path, dataset)
-        fob.BrainMethod.save_run_results(dataset, brain_key, results)
+        if os.path.exists(json_path):
+            results = fors.RunResults.from_json(json_path, dataset)
+            fob.BrainMethod.save_run_results(dataset, brain_key, results)
 
 
 class ImageDirectoryImporter(UnlabeledImageDatasetImporter):