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 1 commit
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
26 changes: 26 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,16 @@ export enum PythonVersion {
THREE_NINE = '3.9',
}

/**
* Runtime
*/
export enum Runtime {
/**
* Ray 2.4
*/
RAY_TWO_FOUR = 'Ray2.4',

Choose a reason for hiding this comment

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

This would be a repetitive operation, wondering if we want to move away from enums

Copy link
Contributor

Choose a reason for hiding this comment

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

should be an enum-like class:

export class Runtime {
  public static RAY_TWO_FOUR = new Runtime('Ray2.4');
  public constructor(public readonly runtime: string) {}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing the example. Reflected with minor change.

}

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

interface SharedJobExecutableProps {
/**
* Runtime.
Copy link
Contributor

Choose a reason for hiding this comment

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

stronger docs needed. need to know when is runtime required, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

*
*/
readonly runtime?: Runtime;
moomindani marked this conversation as resolved.
Show resolved Hide resolved

/**
* Glue version.
*
Expand Down Expand Up @@ -347,6 +363,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 == null && config.type === JobType.RAY) {
moomindani marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('Runtime is required for Ray');
kaizencc marked this conversation as resolved.
Show resolved Hide resolved
}
this.config = config;
}

Expand Down Expand Up @@ -388,6 +407,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,
},
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