RuntimeError: Failed to unpickle serialized exception

I am using ray library for parallelization. my code is as below.

import time    
import ray
from elasticsearch import Elasticsearch
import pandas as pd
import copy

from sklearn.metrics import accuracy_score, confusion_matrix, classification_report

from sklearn.model_selection import train_test_split

from xgboost_ray import RayXGBClassifier, RayParams


class anoDetecPro:
    def __init__(self):
        self.dict = dict()
        self.mainObj = list()
        self.allTime = time.time()

    def connectionES(self):
        es = Elasticsearch(hosts=["*********"])
        query = {
            "query": {
                "bool": {
                    "must": [
                        {"match": {"query.field.keyword": self.field}},
                        {"match": {"query.key.keyword": self.key}}

        self.log =, body=query, size=10000)

    def dataPro(self):
        for i in self.log['hits']['hits']:
            data = i['_source']['query']['records']
            for j in data:
                self.dict['value'] = j['value']
                self.dict['class'] = j['class']
        self.df = pd.DataFrame(self.mainObj)

    def testTrainData(self):
        x = self.df["value"].values.reshape(-1, 1)
        y = self.df["class"]

        seed = 123

        X_train, X_test, y_train, y_test = train_test_split(x, y, train_size=0.30, random_state=123)
        clf = RayXGBClassifier(
        ), y_train, ray_params=RayParams(num_actors=2))

        self.result = clf.predict(, ray_params=RayParams(num_actors=1))
        self.y_test_pred = clf.predict(X_test, ray_params=RayParams(num_actors=1))

    def run(self, field, key, ind, data, api_url, name):
        self.field = field
        self.key = key
        self.ind = ind = data
        self.apiurl = api_url = name
        return self.result

I import this file in a different project and run it as

predict = ray.get(, key, ind, data,

But I am getting this error

TypeError: init() missing 2 required positional arguments: ‘meta’ and ‘body’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/lib/python3.8/dist-packages/ray/”, line 332, in deserialize_objects
obj = self._deserialize_object(data, metadata, object_ref)
File “/usr/local/lib/python3.8/dist-packages/ray/”, line 258, in _deserialize_object
return RayError.from_bytes(obj)
File “/usr/local/lib/python3.8/dist-packages/ray/”, line 32, in from_bytes
return RayError.from_ray_exception(ray_exception)
File “/usr/local/lib/python3.8/dist-packages/ray/”, line 41, in from_ray_exception
raise RuntimeError(msg) from e
RuntimeError: Failed to unpickle serialized exception

Do you know what should i do?

A debugging tip:

  1. Try running this without ray.remote. Do you still see the same exception?
  2. Try isolating the logic that causes this error. You have a callstack that looks like run -> connectionES -> dataPro -> testTrainData. What if you call them all one by one? Which function produces the error?