Skip to content

Conversation

ysiraichi
Copy link
Collaborator

This PR replaces calls of the deprecated function GetComputationClientOrDie() with calls to the GetComputationClient() function. The difference between them is that the former throws an exception on error, while the latter returns an status object.

Key Changes:

  • Remove GetComputationClientOrDie() function

In general, this PR applies the following replacement pattern:

  • Create a new ComputationClient* variable using XLA_ASSIGN_OR_THROW() macro
  • Replaces all GetComputationClientOrDie() with the new variable
/* Before */
runtime::ComputationClient::ComputationPtr computation =
    runtime::GetComputationClientOrDie()->DeserializeComputation(
    serialization);

/* After */
XLA_ASSIGN_OR_THROW(runtime::ComputationClient * absl_nonnull client,
                    runtime::GetComputationClient());
runtime::ComputationClient::ComputationPtr computation =
    client->DeserializeComputation(serialization);

Note: this is the part 2 out of 2 PRs. Together, they will phase out GetComputationClientOrDie() function

@ysiraichi ysiraichi force-pushed the ysiraichi/replace-getcomputationclientordie-with-macros-part2 branch from 503f0bd to 0e018a1 Compare September 5, 2025 18:48
@ysiraichi ysiraichi changed the base branch from ysiraichi/replace-getcomputationclientordie-with-macros-part1 to master September 5, 2025 20:37
@ysiraichi ysiraichi force-pushed the ysiraichi/replace-getcomputationclientordie-with-macros-part2 branch from 0e018a1 to b968cca Compare September 5, 2025 20:41
Copy link
Collaborator

@zhanyong-wan zhanyong-wan left a comment

Choose a reason for hiding this comment

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

Thanks!

@qihqi qihqi merged commit aba96d8 into master Sep 9, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants