Skip to content

Commit

Permalink
setstate
Browse files Browse the repository at this point in the history
  • Loading branch information
MaoZiming committed Dec 10, 2023
1 parent c36820b commit a17a02c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sky/serve/replica_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,11 @@ def json(self) -> Dict[str, Any]:
class ReplicaInfo:
"""Replica info for each replica."""

_VERSION = 2

def __init__(self, replica_id: int, cluster_name: str, replica_port: str,
is_spot: bool, zone: Optional[str]) -> None:
self._version = self._VERSION
self.replica_id: int = replica_id
self.cluster_name: str = cluster_name
self.replica_port: str = replica_port
Expand Down Expand Up @@ -486,6 +489,18 @@ def probe(
f'{common_utils.format_exception(e)}.')
return self, False, probe_time

def __setstate__(self, state):
"""Set state from pickled state, for backward compatibility."""
self._version = self._VERSION

version = state.pop('_version', None)
# Handle old version(s) here.
if version is None:
version = -1

if version < 2:
self.is_spot = False
self.zone = None

class ReplicaManager:
"""Each replica manager monitors one service."""
Expand Down

0 comments on commit a17a02c

Please sign in to comment.