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][Java Label Schedduling 1/n]Java worker add set & get node labels api #38011

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

larrylian
Copy link
Contributor

@larrylian larrylian commented Aug 2, 2023

Why are these changes needed?

Java worker add set & get node labels API.

  1. Set node labels for ray.init()
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
  1. Get node labels
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);

Related issue number

#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.

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
Contributor

@SongGuyang SongGuyang left a comment

Choose a reason for hiding this comment

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

Overall looks good.

Map<String, String> labels = new HashMap<>();
labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
Assert.assertEquals(nodeInfos.get(0).labels, labels);
Ray.shutdown();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use "try catch" in tests to improve the robustness, referencing to java/test/src/main/java/io/ray/test/RuntimeEnvTest.java.

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Attention: External code changed

A previous version of this PR changed code that is used or cited in external sources, e.g. blog posts.

It looks like these changes have been reverted or are otherwise not present in this PR anymore. Please still carefully review the changes to make sure code we use in external sources still works.

@SongGuyang SongGuyang merged commit d290a3f into ray-project:master Aug 7, 2023
3 of 5 checks passed
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
…ls api (ray-project#38011)

## Why are these changes needed?
Java worker add set & get node labels API.

1. Set node labels for ray.init()
```
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
```

2. Get node labels
```
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);
```

## Related issue number
ray-project#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.

Signed-off-by: NripeshN <[email protected]>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…ls api (ray-project#38011)

## Why are these changes needed?
Java worker add set & get node labels API.

1. Set node labels for ray.init()
```
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
```

2. Get node labels
```
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);
```

## Related issue number
ray-project#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.

Signed-off-by: harborn <[email protected]>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…ls api (ray-project#38011)

## Why are these changes needed?
Java worker add set & get node labels API.

1. Set node labels for ray.init()
```
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
```

2. Get node labels 
```
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);
```

## Related issue number
ray-project#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
…ls api (ray-project#38011)

## Why are these changes needed?
Java worker add set & get node labels API.

1. Set node labels for ray.init()
```
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
```

2. Get node labels
```
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);
```

## Related issue number
ray-project#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.

Signed-off-by: e428265 <[email protected]>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
…ls api (ray-project#38011)

## Why are these changes needed?
Java worker add set & get node labels API.

1. Set node labels for ray.init()
```
    System.setProperty("ray.labels", "{\"gpu_type\":\"A100\",\"azone\":\"azone-1\"}");
    Ray.init();
```

2. Get node labels
```
    List<NodeInfo> nodeInfos = Ray.getRuntimeContext().getAllNodeInfo();
    Assert.assertTrue(nodeInfos.size() == 1);
    Map<String, String> labels = new HashMap<>();
    labels.put("ray.io/node_id", nodeInfos.get(0).nodeId.toString());
    labels.put("gpu_type", "A100");
    labels.put("azone", "azone-1");
    Assert.assertEquals(nodeInfos.get(0).labels, labels);
```

## Related issue number
ray-project#34894
(P3)Implement the node affinity with labels interface in Java and transparently transmit it to the CoreWorker.

Signed-off-by: Victor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants