Skip to content

Commit

Permalink
provide more information to improve the code while xparl fails to ini…
Browse files Browse the repository at this point in the history
…tialize the instance (#1072)
  • Loading branch information
TomorrowIsAnOtherDay authored Mar 10, 2023
1 parent eb1ebbf commit 89a72cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion parl/remote/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RemoteError(Exception):
"""

def __init__(self, func_name, error_info):
self.error_info = "[PARL remote error when calling " +\
self.error_info = "[Error occured in xparl, when calling " +\
"function `{}`]:\n{}".format(func_name, error_info)

def __str__(self):
Expand Down
22 changes: 16 additions & 6 deletions parl/remote/remote_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __init__(self, *args, **kwargs):
else:
raise Exception("Can not submit job to the master. " "Please check if master is still alive.")


if job_info is None:
raise ResourceError("Cannot submit the job to the master. "
"Please add more computation resources to the "
Expand All @@ -85,11 +84,22 @@ def __init__(self, *args, **kwargs):
for key in list(kwargs.keys()):
if key.startswith(XPARL_RESERVED_PREFIX):
del kwargs[key]
self.job_socket.send_multipart([
remote_constants.INIT_OBJECT_TAG,
dump_remote_class(cls),
cloudpickle.dumps([args, kwargs]),
])
serlization_finished = True
try:
self.job_socket.send_multipart([
remote_constants.INIT_OBJECT_TAG,
dump_remote_class(cls),
cloudpickle.dumps([args, kwargs]),
])
except TypeError:
serlization_finished = False
logger.error("[xparl] fail to serialize the arguments for class initialization. \n\
For more information, please check the documentation in: \n\
https://parl.readthedocs.io/en/latest/questions/distributed_training.html#recommended-data-types-in-xparl"
)
if not serlization_finished:
raise RemoteSerializeError('__init__', "fail to finish serialization.")

message = self._receive_from_remote_instance('__init__')
tag = message[0]
if tag == remote_constants.NORMAL_TAG:
Expand Down

0 comments on commit 89a72cf

Please sign in to comment.