Deduplication without a running Ray cluster fails with only "Failed to look up actor"
Describe the bug
Running fuzzy or exact deduplication (or calling create_id_generator_actor()) without a Ray cluster already running fails with Ray's generic Failed to look up actor error. The message doesn't say that a Ray cluster has to be started first, so users have opened issues about it and were told there to start a cluster first (#1216, #1292); the reporter of #1292 also asked for "a more meaningful error message".
Starting the cluster first is the intended usage, as explained in #1216, and the tutorials now do it. This issue is only about the error message for people who miss that step.
Steps/Code to reproduce bug
from nemo_curator.stages.deduplication.id_generator import create_id_generator_actor, get_id_generator_actor
create_id_generator_actor() # no Ray cluster is running yet
get_id_generator_actor()
Output on main (09c8a1c):
ValueError: Failed to look up actor with name 'curator_deduplication_id_generator'. This could because 1. You are trying to look up a named actor you didn't create. 2. The named actor died. 3. You did not use a namespace matching the namespace of the actor.
TextDuplicatesRemovalWorkflow(id_generator_path=...).run() without a cluster ends with the same error.
Expected behavior
An error that says the actor needs a Ray cluster that is already running, and how to start one, similar to the message added for resumability in #2063 ("start one with RayClient().start()").
Additional context
Why it happens
create_id_generator_actor()callsray.init(), creates the detached actor, and then callsray.shutdown()(id_generator.py#L106-L132). If no cluster is running in a separate process,ray.init()starts a local one in this process (or reuses one the script started withray.init()), andray.shutdown()stops it, which removes the actor too.- The next
get_id_generator_actor()call can't find it and raises Ray's message (L89-L90). InTextDuplicatesRemovalWorkflow, this happens inkill_id_generator_actor()in thefinallyblock (removal_workflow.py#L203-L213), so this is the error the user sees in the end. From reading the code, the fuzzy and exact workflows do the same (they need a GPU, so I only ran the removal workflow).
Suggested fix
- In
get_id_generator_actor(), catch theValueErrorand raise a newValueErrorwith a clearer message (create the actor while a Ray cluster is running in a separate process, for example one started withRayClient().start()), chained to Ray's original error. - Keeping the type means callers that already catch
ValueError(BaseReader.setup(),MinHashStage,ExactDuplicateIdentification) behave as before. This doesn't change when or how the actor is created.
Environment: main (09c8a1c), Python 3.11.17, Ray 2.57.0, Ubuntu 20.04 on WSL2, CPU only.
I have a small fix with a test ready and will open a PR today. Thank you for taking a look!
AI assistance: Co-found and drafted with Claude Code (Claude Opus 5.5). The output above is from running the script on main (09c8a1c9).