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

[ISSUE-409] support submit job to ray cluster #439

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ private static Environment onLocalEnvironment(Map<String, String> config) {
return environment;
}

public static Environment onRayCommunityEnvironment() {
return (Environment) loadEnvironment(EnvType.RAY_COMMUNITY);
public static Environment onRayEnvironment() {
return (Environment) loadEnvironment(EnvType.RAY);
}

public static Environment onRayCommunityEnvironment(String[] args) {
Environment environment = (Environment) loadEnvironment(EnvType.RAY_COMMUNITY);
public static Environment onRayEnvironment(String[] args) {
Environment environment = (Environment) loadEnvironment(EnvType.RAY);
IEnvironmentArgsParser argsParser = loadEnvironmentArgsParser();
environment.getEnvironmentContext().withConfig(argsParser.parse(args));
return environment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public interface IEnvironment extends Serializable {
enum EnvType {

/**
* Community ray cluster.
* Ray cluster.
*/
RAY_COMMUNITY,
RAY,

/**
* K8s cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ protected void startContainers(int containerNum) {
@Override
public Map<String, ConnectAddress> startDrivers() {
int driverNum = clusterConfig.getDriverNum();
LOGGER.info("start driver number: {}", driverNum);
if (!clusterContext.isRecover()) {
Map<Integer, String> driverIds = new HashMap<>();
for (int driverIndex = 0; driverIndex < driverNum; driverIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class FoStrategyFactoryTest {

@Test(expectedExceptions = GeaflowRuntimeException.class)
public void testLoad() {
FailoverStrategyFactory.loadFailoverStrategy(EnvType.RAY_COMMUNITY, "");
FailoverStrategyFactory.loadFailoverStrategy(EnvType.RAY, "");
}

}
2 changes: 1 addition & 1 deletion geaflow/geaflow-deploy/geaflow-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</dependency>
<dependency>
<groupId>com.antgroup.tugraph</groupId>
<artifactId>geaflow-on-ray-community</artifactId>
<artifactId>geaflow-on-ray</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.tugraph</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>geaflow-on-ray-community</artifactId>
<artifactId>geaflow-on-ray</artifactId>
<packaging>jar</packaging>

<properties>
<ray.version>2.4.0</ray.version>
<ray.version>2.39.0</ray.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RayEnvironment extends AbstractEnvironment {

public RayEnvironment() {
context.getConfig().put(LOG_DIR, RAY_LOG_DIR);
context.getConfig().put(SUPERVISOR_ENABLE, Boolean.TRUE.toString());
context.getConfig().put(SUPERVISOR_ENABLE, Boolean.FALSE.toString());
}

@Override
Expand All @@ -35,6 +35,6 @@ protected IClusterClient getClusterClient() {

@Override
public EnvType getEnvType() {
return EnvType.RAY_COMMUNITY;
return EnvType.RAY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static ActorHandle<RayMasterRunner> createMaster(ClusterConfig clusterCon
.actor(RayMasterRunner::new, clusterConfig.getConfig())
.setMaxRestarts(clusterConfig.getMaxRestarts())
.setLifetime(ActorLifetime.DETACHED)
.setJvmOptions(jvmOptions).remote();
.remote();
LOGGER.info("master actor:{}, memoryMB:{}, jvmOptions:{}, foRestartTimes:{}",
masterRayActor.getId().toString(), totalMemoryMb, jvmOptions,
clusterConfig.getMaxRestarts());
Expand All @@ -68,7 +68,7 @@ public static ActorHandle<RayDriverRunner> createDriver(ClusterConfig clusterCon
.actor(RayDriverRunner::new, context)
.setMaxRestarts(clusterConfig.getMaxRestarts())
.setLifetime(ActorLifetime.DETACHED)
.setJvmOptions(jvmOptions).remote();
.remote();
LOGGER.info("driver actor:{}, memoryMB:{}, jvmOptions:{}, foRestartTimes:{}",
driverRayActor.getId().toString(), totalMemoryMb, jvmOptions,
clusterConfig.getMaxRestarts());
Expand All @@ -81,7 +81,6 @@ public static ActorHandle<RayContainerRunner> createContainer(ClusterConfig clus
.actor(RayContainerRunner::new, containerContext)
.setMaxRestarts(clusterConfig.getMaxRestarts())
.setLifetime(ActorLifetime.DETACHED)
.setJvmOptions(clusterConfig.getContainerJvmOptions().getJvmOptions())
.remote();
LOGGER.info("worker actor {} maxRestarts {}", rayContainer.getId().toString(),
clusterConfig.getMaxRestarts());
Expand All @@ -94,7 +93,6 @@ public static ActorHandle<RaySupervisorRunner> createSupervisor(ClusterConfig cl
.actor(RaySupervisorRunner::new, clusterConfig.getConfig(), envs)
.setMaxRestarts(clusterConfig.getMaxRestarts())
.setLifetime(ActorLifetime.DETACHED)
.setJvmOptions(clusterConfig.getSupervisorJvmOptions().getJvmOptions())
.remote();
LOGGER.info("supervisor actor {} maxRestarts {}", rayContainer.getId().toString(),
clusterConfig.getMaxRestarts());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class RayClusterManager extends GeaFlowClusterManager {
private String currentJobId;

public RayClusterManager() {
super(EnvType.RAY_COMMUNITY);
super(EnvType.RAY);
}

@Override
Expand Down Expand Up @@ -98,6 +98,7 @@ public void createNewContainer(int containerId, boolean isRecover) {

@Override
public void createNewDriver(int driverId, int driverIndex) {
LOGGER.info("create driver start, enable supervisor:{}", enableSupervisor);
if (enableSupervisor) {
String logFile = String.format("driver-%s-%s.log", currentJobId, driverId);
String command = getDriverShellCommand(driverId, driverIndex, classpath, logFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class RayClusterFailoverStrategy extends ClusterFailoverStrategy {

public RayClusterFailoverStrategy() {
super(EnvType.RAY_COMMUNITY);
super(EnvType.RAY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class RayComponentFailoverStrategy extends ComponentFailoverStrategy {

public RayComponentFailoverStrategy() {
super(EnvType.RAY_COMMUNITY);
super(EnvType.RAY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class RayDisableFailoverStrategy extends DisableFailoverStrategy {

public RayDisableFailoverStrategy() {
super(EnvType.RAY_COMMUNITY);
super(EnvType.RAY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2023 AntGroup CO., Ltd.
*
* 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.
*/

package com.antgroup.geaflow.cluster.ray.utils;

import static com.antgroup.geaflow.common.config.keys.ExecutionConfigKeys.JOB_WORK_PATH;

import com.antgroup.geaflow.cluster.config.ClusterConfig;
import com.antgroup.geaflow.cluster.ray.config.RayConfig;
import com.antgroup.geaflow.common.config.Configuration;
import io.ray.api.Ray;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RaySystemFunc implements Serializable {

private static final long serialVersionUID = -3708025618479190982L;

private static final Logger LOGGER = LoggerFactory.getLogger(RaySystemFunc.class);

private static final Object LOCK = new Object();
private static String appPath;

public static boolean isRestarted() {
return Ray.getRuntimeContext().wasCurrentActorRestarted();
}

public static boolean isLocalMode() {
return Ray.getRuntimeContext().isLocalMode();
}

public static String getWorkPath() {
if (appPath != null) {
return appPath;
}
synchronized (LOCK) {
if (Ray.getRuntimeContext().isLocalMode()) {
appPath = "/tmp/" + System.currentTimeMillis();
try {
FileUtils.forceMkdir(new File(appPath));
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
} else {
appPath = Ray.getRuntimeContext().getCurrentRuntimeEnv()
.get(RayConfig.RAY_JOB_WORKING_DIR, String.class);
}
}
return appPath;
}

public static void initRayEnv(ClusterConfig clusterConfig) {
LOGGER.info("clusterConfig:{}", clusterConfig);
Configuration config = clusterConfig.getConfig();

// Set working dir.
System.setProperty(
String.format("%s.%s", RayConfig.RAY_JOB_RUNTIME_ENV, RayConfig.RAY_JOB_WORKING_DIR),
config.getString(JOB_WORK_PATH));
Ray.init();
}
}
Loading
Loading