Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Fix worker crash when getting actor name from runtime context #45194

Merged
merged 5 commits into from
May 21, 2024

Conversation

982945902
Copy link
Contributor

@982945902 982945902 commented May 8, 2024

Why are these changes needed?

Currently calling get_runtime_context().get_actor_name() from driver will crash. Instead of crashing, this PR returns None in this case.

Related issue number

Closes #45174

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about updating runtime_context.py instead of core_worker.cc to keep the behavior consistent with other functions such as get_task_id and get_actor_id?

To elaborate,

    def get_actor_name(self) -> Optional[str]:
        """Get the current actor name of this worker.

        This shouldn't be used in a driver process.
        The name is in string format.

        Returns:
            The current actor name of this worker.
            If a current worker is an actor, and
            if actor name doesn't exist, it returns an empty string.
            If a current worker is not an actor, it returns None.
        """
        # only worker mode has actor_id
        if self.worker.mode != ray._private.worker.WORKER_MODE:
            logger.warning(
                "This method is only available when the process is a "
                f"worker. Current mode: {self.worker.mode}"
            )
            return None <---- Add this line
        actor_id = self.worker.actor_id
        return self.worker.actor_name if not actor_id.is_nil() else None

You can refer to get_task_id as an example.

@kevin85421 kevin85421 self-assigned this May 8, 2024
@982945902
Copy link
Contributor Author

@kevin85421 that good !

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a test in test_runtime_context.py? Btw, you can add -s in your git commit command to avoid the DCO failure in CI.

@982945902
Copy link
Contributor Author

@kevin85421 ok

scottsun94 and others added 3 commits May 9, 2024 14:35
)

Change it back to anyscale website:
- the preview sign-up form is available on anyscale website now
- anyscale website will be the only link for getting access to hosted Anyscale Cloud down the road

Signed-off-by: 982945902 <982945902@qq.com>
Signed-off-by: 982945902 <982945902@qq.com>
Signed-off-by: 982945902 <982945902@qq.com>
@@ -1,4 +1,4 @@
<a id="try-anyscale-href" href="https://forms.gle/DFin3AzKEDB19uXZ6">
<a id="try-anyscale-href" href="https://www.anyscale.com">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line change is unrelated? could you rebase properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevin85421
Copy link
Member

Would you mind rebasing with the master branch?

@982945902
Copy link
Contributor Author

Would you mind rebasing with the master branch?

@kevin85421 not mind, how need i do

@kevin85421
Copy link
Member

Take a look at your commit history. It seems to be that you don't sync with the master branch correctly. You may not need to rebase with the master branch, but you need to fix your commit history.

Signed-off-by: chuanzhisongshu <49055103+982945902@users.noreply.github.com>
@kevin85421
Copy link
Member

Hi @982945902, would you mind fixing the CI failure?

@982945902
Copy link
Contributor Author

982945902 commented May 14, 2024

@kevin85421 It seems that some of the test cases timed out, causing the use cases to fail, how should I re-triggered the C test

@kevin85421
Copy link
Member

It seems that some of the test cases timed out, causing the use cases to fail, how should I re-triggered the C test

I re-triggered CI pipeline multiple times for this PR. It always fails. Could you try to reproduce in your local env?

@982945902
Copy link
Contributor Author

@kevin85421 These test cases have bugs, and someone merged and fixed them two days ago

1 similar comment
@982945902
Copy link
Contributor Author

@kevin85421 These test cases have bugs, and someone merged and fixed them two days ago

@kevin85421
Copy link
Member

Would you mind rebasing with the master branch? Thanks!

@982945902
Copy link
Contributor Author

Would you mind rebasing with the master branch? Thanks!

@kevin85421 not mind, how need i do

@kevin85421
Copy link
Member

@kevin85421 not mind, how need i do

Sync your branch with the upstream master branch.

@982945902
Copy link
Contributor Author

@kevin85421 done

@kevin85421 kevin85421 added the go add ONLY when ready to merge, run all tests label May 20, 2024
@jjyao jjyao changed the title when actor_id_ is nil ,call ray.get_runtime_context().actor_name will cause raise [Core] Fix worker crash when getting actor name from runtime context May 21, 2024
@jjyao jjyao merged commit a9fb64f into ray-project:master May 21, 2024
7 checks passed
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 6, 2024
…ay-project#45194)

Currently calling get_runtime_context().get_actor_name() from driver will crash. Instead of crashing, this PR returns None in this case.

Signed-off-by: 982945902 <982945902@qq.com>
Co-authored-by: Huaiwei Sun <scottsun94@gmail.com>
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 6, 2024
…ay-project#45194)

Currently calling get_runtime_context().get_actor_name() from driver will crash. Instead of crashing, this PR returns None in this case.

Signed-off-by: 982945902 <982945902@qq.com>
Co-authored-by: Huaiwei Sun <scottsun94@gmail.com>
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 7, 2024
…ay-project#45194)

Currently calling get_runtime_context().get_actor_name() from driver will crash. Instead of crashing, this PR returns None in this case.

Signed-off-by: 982945902 <982945902@qq.com>
Co-authored-by: Huaiwei Sun <scottsun94@gmail.com>
GabeChurch pushed a commit to GabeChurch/ray that referenced this pull request Jun 11, 2024
…ay-project#45194)

Currently calling get_runtime_context().get_actor_name() from driver will crash. Instead of crashing, this PR returns None in this case.

Signed-off-by: 982945902 <982945902@qq.com>
Co-authored-by: Huaiwei Sun <scottsun94@gmail.com>
Signed-off-by: gchurch <gabe1church@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Worker] Worker crash when getting an actor name
5 participants