def decode_options( options: ray_client_pb2.TaskOptions) -> Optional[Dict[str, Any]]: if options.json_options == "": return None opts = json.loads(options.json_options) assert isinstance(opts, dict) if opts.get("placement_group", None): # Placement groups in Ray client options are serialized as dicts. # Convert the dict to a PlacementGroup. opts["placement_group"] = PlacementGroup.from_dict( opts["placement_group"]) return opts
def pg_to_dict_to_pg(pg_in): pg_dict = pg_in.to_dict() pg_out = PlacementGroup.from_dict(pg_dict) assert pg_out.id == pg_in.id assert pg_out.bundle_cache == pg_in.bundle_cache
def dict_to_pg_to_dict(pg_dict_in): pg = PlacementGroup.from_dict(pg_dict_in) pg_dict_out = pg.to_dict() assert pg_dict_in == pg_dict_out