# ExperimentAnalysis object cannot be regenerated or unpickled

**URL:** <https://discuss.ray.io/t/experimentanalysis-object-cannot-be-regenerated-or-unpickled/342>\
**Category:** Ray Tune\
**Created:** [December 29, 2020, 10:37pm UTC](https://discuss.ray.io/t/experimentanalysis-object-cannot-be-regenerated-or-unpickled/342 "2020-12-29T22:37:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amcleod](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/amcleod/32/190_2.png) [@amcleod](https://discuss.ray.io/u/amcleod)\
**Post date:** [December 29, 2020, 10:37pm UTC](https://discuss.ray.io/t/experimentanalysis-object-cannot-be-regenerated-or-unpickled/342/1 "2020-12-29T22:37:34Z")

</div>

I’m using tune.run() to do some hypertuning on a model (with a Pytorch backend, using both a search algorithm (hyperopt) and a scheduler (ASHA)), and I’m finding that the ExperimentAnalysis object that tune.run() returns cannot be unpickled:

```
>>> exper = pickle.load(open("/data/ray_tune_analysis.pkl", "rb"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...directories...]/python3.6/site-packages/ray/tune/trial.py", line 649, in __setstate__
    for key in self._nonjson_fields:
AttributeError: 'Trial' object has no attribute '_nonjson_fields'
>>> 

```

…But the object created by pointing the constructor of ExperimentAnalysis at the experiment\_state json never gets populated with a trials field, which makes the object of very limited usefulness:

```
>>> expa = ExperimentAnalysis(experiment_checkpoint_path="~/ray_results/SAC/experiment_state-2020-12-29_12-13-16.json")
No `self.trials`. Drawing logdirs from checkpoint file. This may result in some information that is out of sync, as checkpointing is periodic.
>>> expa.get_best_trial(metric="episode_reward_mean", mode="max")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...directories...]/python3.6/site-packages/ray/tune/analysis/experiment_analysis.py", line 535, in get_best_trial
for trial in self.trials:
TypeError: 'NoneType' object is not iterable

```

I can print the returned values of get\_best\_\*() methods to stdout from the ExperimentAnalysis object returned by tune.run(), but without a way to save or regenerate those results, stdout seems like a bad option to settle on.

Is there a way to serialize the analysis object, or make it regenerate properly from the experiment directory?
