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

fix(glue): support Ray jobs with Runtime parameter #25867

Merged
merged 8 commits into from
Jun 29, 2023
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
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-glue-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ new glue.Job(this, 'RayJob', {
executable: glue.JobExecutable.pythonRay({
glueVersion: glue.GlueVersion.V4_0,
pythonVersion: glue.PythonVersion.THREE_NINE,
runtime: glue.Runtime.RAY_TWO_FOUR,
script: glue.Code.fromAsset(path.join(__dirname, 'job-script/hello_world.py')),
}),
workerType: glue.WorkerType.Z_2X,
Expand Down
44 changes: 44 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/job-executable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,34 @@ export enum PythonVersion {
THREE_NINE = '3.9',
}

/**
* AWS Glue runtime determines the runtime engine of the job.
*
*/
export class Runtime {
/**
* Runtime for a Glue for Ray 2.4.
*/
public static readonly RAY_TWO_FOUR = new Runtime('Ray2.4');

/**
* Custom runtime
* @param runtime custom runtime
*/
public static of(runtime: string): Runtime {
return new Runtime(runtime);
}

/**
* The name of this Runtime.
*/
public readonly name: string;

private constructor(name: string) {
this.name = name;
}
}

/**
* The job type.
*
Expand Down Expand Up @@ -150,6 +178,12 @@ interface PythonExecutableProps {
}

interface SharedJobExecutableProps {
/**
* Runtime. It is required for Ray jobs.
*
*/
readonly runtime?: Runtime;
moomindani marked this conversation as resolved.
Show resolved Hide resolved

/**
* Glue version.
*
Expand Down Expand Up @@ -347,6 +381,9 @@ export class JobExecutable {
if (config.pythonVersion === PythonVersion.THREE && config.type === JobType.RAY) {
throw new Error('Specified PythonVersion PythonVersion.THREE is not supported for Ray');
}
if (config.runtime === undefined && config.type === JobType.RAY) {
throw new Error('Runtime is required for Ray jobs.');
}
this.config = config;
}

Expand Down Expand Up @@ -388,6 +425,13 @@ export interface JobExecutableConfig {
*/
readonly pythonVersion?: PythonVersion;

/**
* The Runtime to use.
Copy link
Contributor

Choose a reason for hiding this comment

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

better docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our public doc does not have much information about this property, but I tried to add as much as possible.

*
* @default - no runtime specified
*/
readonly runtime?: Runtime;

/**
* The script that is executed by a job.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ export class Job extends JobBase {
name: executable.type.name,
scriptLocation: this.codeS3ObjectUrl(executable.script),
pythonVersion: executable.pythonVersion,
runtime: executable.runtime ? executable.runtime.name : undefined,
},
glueVersion: executable.glueVersion.name,
workerType: props.workerType?.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "29.0.0",
"version": "32.0.0",
"files": {
"432033e3218068a915d2532fa9be7858a12b228a2ae6e5c10faccd9097b1e855": {
"source": {
Expand All @@ -14,15 +14,15 @@
}
}
},
"b553fef631f82898c826f3c20e1de0d155dbd3a35339ef92d0893052a5be69ce": {
"e99fb38377ba41ea9e74da162cf01b6821baa17e8e3d003c711b03d822356b89": {
"source": {
"path": "aws-glue-job.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "b553fef631f82898c826f3c20e1de0d155dbd3a35339ef92d0893052a5be69ce.json",
"objectKey": "e99fb38377ba41ea9e74da162cf01b6821baa17e8e3d003c711b03d822356b89.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
"Tags": {
"key": "value"
},
"WorkerType": "G.025X"
"WorkerType": "G.1X"
}
},
"EtlJob30ServiceRole8E675579": {
Expand Down Expand Up @@ -1415,6 +1415,7 @@
"Command": {
"Name": "glueray",
"PythonVersion": "3.9",
"Runtime": "Ray2.4",
"ScriptLocation": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"29.0.0"}
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "29.0.0",
"version": "32.0.0",
"testCases": {
"integ.job": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "29.0.0",
"version": "32.0.0",
"artifacts": {
"aws-glue-job.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b553fef631f82898c826f3c20e1de0d155dbd3a35339ef92d0893052a5be69ce.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e99fb38377ba41ea9e74da162cf01b6821baa17e8e3d003c711b03d822356b89.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Loading