Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions python/ray/tune/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,24 @@ def __init__(self,
self.error_file = None
self.num_failures = 0

# AutoML fields
self.results = None
self.best_result = None
self.param_config = None
self.extra_arg = None

self._nonjson_fields = [
"_checkpoint",
"config",
"loggers",
"sync_function",
"last_result",
"results",
"best_result",
"param_config",
"extra_arg",
]

self.trial_name = None
if trial_name_creator:
self.trial_name = trial_name_creator(self)
Expand Down Expand Up @@ -509,17 +527,8 @@ def __getstate__(self):
state = self.__dict__.copy()
state["resources"] = resources_to_json(self.resources)

# These are non-pickleable entries.
pickle_data = {
"_checkpoint": self._checkpoint,
"config": self.config,
"loggers": self.loggers,
"sync_function": self.sync_function,
"last_result": self.last_result
}

for key, value in pickle_data.items():
state[key] = binary_to_hex(cloudpickle.dumps(value))
for key in self._nonjson_fields:
state[key] = binary_to_hex(cloudpickle.dumps(state.get(key)))

state["runner"] = None
state["result_logger"] = None
Expand All @@ -535,10 +544,7 @@ def __getstate__(self):
def __setstate__(self, state):
logger_started = state.pop("__logger_started__")
state["resources"] = json_to_resources(state["resources"])
for key in [
"_checkpoint", "config", "loggers", "sync_function",
"last_result"
]:
for key in self._nonjson_fields:
state[key] = cloudpickle.loads(hex_to_binary(state[key]))

self.__dict__.update(state)
Expand Down