YARN-8798. [Submarine] Job should not be submitted if --input_path option is missing. (Zhankun Tang via wangda)
Change-Id: I7ae0e44eb5179b04a6ac861ec1c65f3b18c38f0f
(cherry picked from commit 143d74775b
)
This commit is contained in:
parent
920401b296
commit
aa23c8d739
|
@ -62,6 +62,12 @@ public class RunJobParameters extends RunParameters {
|
||||||
if (parsedCommandLine.getOptionValue(CliConstants.N_WORKERS) != null) {
|
if (parsedCommandLine.getOptionValue(CliConstants.N_WORKERS) != null) {
|
||||||
nWorkers = Integer.parseInt(
|
nWorkers = Integer.parseInt(
|
||||||
parsedCommandLine.getOptionValue(CliConstants.N_WORKERS));
|
parsedCommandLine.getOptionValue(CliConstants.N_WORKERS));
|
||||||
|
// Only check null value.
|
||||||
|
// Training job shouldn't ignore INPUT_PATH option
|
||||||
|
// But if nWorkers is 0, INPUT_PATH can be ignored because user can only run Tensorboard
|
||||||
|
if (null == input && 0 != nWorkers) {
|
||||||
|
throw new ParseException("\"--" + CliConstants.INPUT_PATH + "\" is absent");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nPS = 0;
|
int nPS = 0;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.yarn.submarine.client.cli;
|
package org.apache.hadoop.yarn.submarine.client.cli;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
||||||
|
@ -135,6 +136,44 @@ public class TestRunJobCliParsing {
|
||||||
Assert.assertTrue(jobRunParameters.isWaitJobFinish());
|
Assert.assertTrue(jobRunParameters.isWaitJobFinish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoInputPathOptionSpecified() throws Exception {
|
||||||
|
RunJobCli runJobCli = new RunJobCli(getMockClientContext());
|
||||||
|
String expectedErrorMessage = "\"--" + CliConstants.INPUT_PATH + "\" is absent";
|
||||||
|
String actualMessage = "";
|
||||||
|
try {
|
||||||
|
runJobCli.run(
|
||||||
|
new String[]{"--name", "my-job", "--docker_image", "tf-docker:1.1.0",
|
||||||
|
"--checkpoint_path", "hdfs://output",
|
||||||
|
"--num_workers", "1", "--worker_launch_cmd", "python run-job.py",
|
||||||
|
"--worker_resources", "memory=4g,vcores=2", "--tensorboard",
|
||||||
|
"true", "--verbose", "--wait_job_finish"});
|
||||||
|
} catch (ParseException e) {
|
||||||
|
actualMessage = e.getMessage();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Assert.assertEquals(expectedErrorMessage, actualMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* when only run tensorboard, input_path is not needed
|
||||||
|
* */
|
||||||
|
@Test
|
||||||
|
public void testNoInputPathOptionButOnlyRunTensorboard() throws Exception {
|
||||||
|
RunJobCli runJobCli = new RunJobCli(getMockClientContext());
|
||||||
|
boolean success = true;
|
||||||
|
try {
|
||||||
|
runJobCli.run(
|
||||||
|
new String[]{"--name", "my-job", "--docker_image", "tf-docker:1.1.0",
|
||||||
|
"--num_workers", "0", "--tensorboard", "--verbose",
|
||||||
|
"--tensorboard_resources", "memory=2G,vcores=2",
|
||||||
|
"--tensorboard_docker_image", "tb_docker_image:001"});
|
||||||
|
} catch (ParseException e) {
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
Assert.assertTrue(success);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLaunchCommandPatternReplace() throws Exception {
|
public void testLaunchCommandPatternReplace() throws Exception {
|
||||||
RunJobCli runJobCli = new RunJobCli(getMockClientContext());
|
RunJobCli runJobCli = new RunJobCli(getMockClientContext());
|
||||||
|
|
Loading…
Reference in New Issue