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

chore(glue): timeout and worker type validation for Ray jobs #32119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,17 @@ export class Job extends JobBase {
}
}

// Validate Ray job properties
// See https://github.com/aws/aws-cdk/issues/29612
if (executable.type.name === JobType.RAY.name) {
if (props.workerType !== WorkerType.Z_2X) {
throw new Error(`WorkerType must be Z_2X for Ray jobs, got: ${props.workerType}`);
}
if (props.timeout !== undefined) {
throw new Error('Timeout cannot be set for Ray jobs');
}
}

let maxCapacity = props.maxCapacity;
if (maxCapacity !== undefined && (props.workerType && props.workerCount !== undefined)) {
throw new Error('maxCapacity cannot be used when setting workerType and workerCount');
Expand Down
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/test/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,38 @@ describe('Job', () => {
workerCount: 2,
})).toThrow('Runtime is required for Ray jobs');
});

test.each([
glue.WorkerType.G_025X,
glue.WorkerType.G_1X,
glue.WorkerType.G_2X,
glue.WorkerType.G_4X,
glue.WorkerType.G_8X,
])('throw error for unsupported worker type', (workerType) => {
expect(() => new glue.Job(stack, 'Job', {
executable: glue.JobExecutable.pythonRay({
glueVersion: glue.GlueVersion.V4_0,
pythonVersion: glue.PythonVersion.THREE_NINE,
runtime: glue.Runtime.RAY_TWO_FOUR,
script,
}),
workerType,
workerCount: 2,
})).toThrow(`WorkerType must be Z_2X for Ray jobs, got: ${workerType}`);
});
});

test('throw error for specifying timeout', () => {
expect(() => new glue.Job(stack, 'Job', {
executable: glue.JobExecutable.pythonRay({
glueVersion: glue.GlueVersion.V4_0,
pythonVersion: glue.PythonVersion.THREE_NINE,
runtime: glue.Runtime.RAY_TWO_FOUR,
script,
}),
workerType: glue.WorkerType.Z_2X,
timeout: cdk.Duration.minutes(5),
})).toThrow('Timeout cannot be set for Ray jobs');
});

test('etl job with all props should synthesize correctly', () => {
Expand Down
Loading