-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from bjwswang/ray
feat: able to list rayclusters configured in arcadia config
- Loading branch information
Showing
12 changed files
with
782 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# list | ||
query listRayClusters($input: ListCommonInput!){ | ||
RayCluster { | ||
listRayClusters(input: $input) { | ||
totalCount | ||
hasNextPage | ||
nodes { | ||
__typename | ||
... on RayCluster { | ||
index | ||
name | ||
headAddress | ||
dashboardHost | ||
pythonVersion | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
"""RayCluster集群""" | ||
type RayCluster { | ||
""" | ||
Ray集群的索引 | ||
""" | ||
index: Int! | ||
""" | ||
名称 | ||
规则: 遵循k8s命名 | ||
""" | ||
name: String! | ||
""" | ||
Ray集群head节点的地址 | ||
规则: 遵循k8s命名 | ||
""" | ||
headAddress: String | ||
""" | ||
Ray集群dashboard的地址 | ||
""" | ||
dashboardHost: String | ||
""" | ||
Ray集群应用要求的python版本 | ||
""" | ||
pythonVersion: String | ||
} | ||
|
||
|
||
type RayClusterQuery { | ||
listRayClusters(input: ListCommonInput!): PaginatedResult! | ||
} | ||
|
||
extend type Query { | ||
RayCluster: RayClusterQuery | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2023 KubeAGI. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package ray | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"k8s.io/client-go/dynamic" | ||
|
||
"github.com/kubeagi/arcadia/apiserver/graph/generated" | ||
"github.com/kubeagi/arcadia/pkg/config" | ||
) | ||
|
||
func ListRayClusters(ctx context.Context, c dynamic.Interface, input generated.ListCommonInput) (*generated.PaginatedResult, error) { | ||
clusters, err := config.GetRayClusters(ctx, nil, c) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var results = make([]generated.PageNode, 0, len(clusters)) | ||
for index, cluster := range clusters { | ||
// skip if keyword not in cluster name | ||
if input.Keyword != nil { | ||
if !strings.Contains(cluster.Name, *input.Keyword) { | ||
continue | ||
} | ||
} | ||
|
||
results = append(results, &generated.RayCluster{ | ||
Index: index, | ||
Name: cluster.Name, | ||
HeadAddress: &cluster.HeadAddress, | ||
DashboardHost: &cluster.DashboardHost, | ||
PythonVersion: &cluster.PythonVersion, | ||
}) | ||
} | ||
|
||
return &generated.PaginatedResult{ | ||
TotalCount: len(results), | ||
Nodes: results, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters