Skip to content

Non-ascii character in function body leads to UnicodeError on hashing #9585

@aaarne

Description

@aaarne

What is the problem?

I use a non-ascii character in a function body (not in the function name), which is decorated @ray.remote. When calling that function I get a UnicodeEncodeError. As I understand it, the function manager hashes the function body in order to check if the remote version matches the local one. The hashing function cannot handle the non-ascii character in the body.

Versions

  • python version: 3.6.9
  • OS: openSUSE Leap 15
  • ray version: 0.8.6

Reproduction (REQUIRED)

Script

import ray; ray.init()

@ray.remote
def print_false_statement():
    print("π is exactly 3.")

ray.get(print_false_statement.remote())

Traceback

---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-6-b5dd33a57b06> in <module>
----> 1 fut = test.remote()

~/l/anaconda3/lib/python3.6/site-packages/ray/remote_function.py in _remote_proxy(*args, **kwargs)
     93         @wraps(function)
     94         def _remote_proxy(*args, **kwargs):
---> 95             return self._remote(args=args, kwargs=kwargs)
     96 
     97         self.remote = _remote_proxy

~/l/anaconda3/lib/python3.6/site-packages/ray/remote_function.py in _remote(self, args, kwargs, num_return_vals, is_direct_call, num_cpus, num_gpus, memory, object_store_memory, resources, max_retries)
    174 
    175             self._last_export_session_and_job = worker.current_session_and_job
--> 176             worker.function_actor_manager.export(self)
    177 
    178         kwargs = {} if kwargs is None else kwargs

~/l/anaconda3/lib/python3.6/site-packages/ray/function_manager.py in export(self, remote_function)
    149                 "function": pickled_function,
    150                 "collision_identifier": self.compute_collision_identifier(
--> 151                     function),
    152                 "max_calls": remote_function._max_calls
    153             })

~/l/anaconda3/lib/python3.6/site-packages/ray/function_manager.py in compute_collision_identifier(self, function_or_class)
    121 
    122         # Return a hash of the identifier in case it is too large.
--> 123         return hashlib.sha1(collision_identifier.encode("ascii")).digest()
    124 
    125     def export(self, remote_function):

UnicodeEncodeError: 'ascii' codec can't encode character '\u03c6' in position 101: ordinal not in range(128)
  • I have verified my script runs in a clean environment and reproduces the issue.
  • I have verified the issue also occurs with the latest wheels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to be working; but isn'tgood-first-issueGreat starter issue for someone just starting to contribute to Ray

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions