-
Notifications
You must be signed in to change notification settings - Fork 8
Connect run.py to DataprocSubmitter.scala so that offline jobs can be run on Dataproc #186
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
Changes from 27 commits
f941a6f
a6b154b
e3b0c48
7472f45
61eba99
a8525bc
67d2159
49b60a7
ad3207c
f9ef45f
957afad
8d0257a
0096de2
d7c82c3
f3da7d7
f96d062
3d1d6ff
fc40e7d
01ba185
96a748a
263899c
fe13f57
e5282e0
a1463cd
047c21e
903c23f
431b7e1
20141ea
14ec11b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| click | ||
| thrift==0.13.0 | ||
| thrift==0.21.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| # SHA1:1d44bb5a0f927ef885e838e299990ba7ecd68dda | ||
| # SHA1:e6acf05ccde0547fea15f1185172abe12ea24af2 | ||
| # | ||
| # This file is autogenerated by pip-compile-multi | ||
| # To update, run: | ||
| # | ||
| # pip-compile-multi | ||
| # | ||
| click==8.1.7 | ||
| click==8.1.8 | ||
| # via -r requirements/base.in | ||
| six==1.16.0 | ||
| six==1.17.0 | ||
| # via thrift | ||
| thrift==0.20.0 | ||
| thrift==0.21.0 | ||
| # via -r requirements/base.in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,7 @@ black | |
| pre-commit | ||
| isort | ||
| autoflake | ||
| zipp==3.19.1 | ||
| importlib-metadata==8.4.0 | ||
| google-cloud-storage==2.19.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ZIPLINE_CUSTOMER_ID=canary | ||
| ZIPLINE_GCP_PROJECT_ID=canary-443022 | ||
| ZIPLINE_GCP_REGION=us-central1 | ||
| ZIPLINE_GCP_DATAPROC_CLUSTER_NAME=zipline-canary-cluster |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -88,6 +88,13 @@ object DataprocSubmitter { | |||||||||||||||||||||||||||||||||||||||||
| new DataprocSubmitter(jobControllerClient, conf) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def apply(conf: SubmitterConf): DataprocSubmitter = { | ||||||||||||||||||||||||||||||||||||||||||
| val jobControllerClient = JobControllerClient.create( | ||||||||||||||||||||||||||||||||||||||||||
| JobControllerSettings.newBuilder().setEndpoint(conf.endPoint).build() | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| new DataprocSubmitter(jobControllerClient, conf) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private[cloud_gcp] def loadConfig: SubmitterConf = { | ||||||||||||||||||||||||||||||||||||||||||
| val inputStreamOption = Option(getClass.getClassLoader.getResourceAsStream("dataproc-submitter-conf.yaml")) | ||||||||||||||||||||||||||||||||||||||||||
| val yamlLoader = new Yaml() | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -105,6 +112,48 @@ object DataprocSubmitter { | |||||||||||||||||||||||||||||||||||||||||
| .getOrElse(throw new IllegalArgumentException("Yaml conf not found or invalid yaml")) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| def main(args: Array[String]): Unit = { | ||||||||||||||||||||||||||||||||||||||||||
| val chrononJarUri = args.filter(_.startsWith("--chronon_jar_uri"))(0).split("=")(1) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // search args array for prefix `--gcs_files` | ||||||||||||||||||||||||||||||||||||||||||
| val gcsFiles = args | ||||||||||||||||||||||||||||||||||||||||||
| .filter(_.startsWith("--gcs_files"))(0) | ||||||||||||||||||||||||||||||||||||||||||
| .split("=")(1) | ||||||||||||||||||||||||||||||||||||||||||
| .split(",") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+116
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate command-line arguments to prevent exceptions Check for missing or malformed arguments to avoid crashes.
Comment on lines
+115
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add argument validation Add bounds and format checking to prevent runtime exceptions. - val chrononJarUri = args.filter(_.startsWith("--chronon_jar_uri"))(0).split("=")(1)
+ val chrononJarUriArg = args.find(_.startsWith("--chronon_jar_uri"))
+ .getOrElse(throw new IllegalArgumentException("Missing required argument: --chronon_jar_uri"))
+ val chrononJarUri = chrononJarUriArg.split("=").lift(1)
+ .getOrElse(throw new IllegalArgumentException("Invalid format for --chronon_jar_uri"))
- val gcsFiles = args
- .filter(_.startsWith("--gcs_files"))(0)
- .split("=")(1)
- .split(",")
+ val gcsFilesArg = args.find(_.startsWith("--gcs_files"))
+ .getOrElse(throw new IllegalArgumentException("Missing required argument: --gcs_files"))
+ val gcsFiles = gcsFilesArg.split("=").lift(1)
+ .getOrElse(throw new IllegalArgumentException("Invalid format for --gcs_files"))
+ .split(",")📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| val userArgs = args.filter(f => !f.startsWith("--gcs_files") && !f.startsWith("--chronon_jar_uri")) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| val required_vars = List.apply( | ||||||||||||||||||||||||||||||||||||||||||
| "ZIPLINE_GCP_PROJECT_ID", | ||||||||||||||||||||||||||||||||||||||||||
| "ZIPLINE_GCP_REGION", | ||||||||||||||||||||||||||||||||||||||||||
| "ZIPLINE_GCP_DATAPROC_CLUSTER_NAME" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| val missing_vars = required_vars.filter(!sys.env.contains(_)) | ||||||||||||||||||||||||||||||||||||||||||
| if (missing_vars.nonEmpty) { | ||||||||||||||||||||||||||||||||||||||||||
| throw new Exception(s"Missing required environment variables: ${missing_vars.mkString(", ")}") | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| val projectId = sys.env.getOrElse("ZIPLINE_GCP_PROJECT_ID", throw new Exception("ZIPLINE_GCP_PROJECT_ID not set")) | ||||||||||||||||||||||||||||||||||||||||||
| val region = sys.env.getOrElse("ZIPLINE_GCP_REGION", throw new Exception("ZIPLINE_GCP_REGION not set")) | ||||||||||||||||||||||||||||||||||||||||||
| val clusterName = sys.env | ||||||||||||||||||||||||||||||||||||||||||
| .getOrElse("ZIPLINE_GCP_DATAPROC_CLUSTER_NAME", throw new Exception("ZIPLINE_GCP_DATAPROC_CLUSTER_NAME not set")) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| val submitterConf = SubmitterConf( | ||||||||||||||||||||||||||||||||||||||||||
| projectId, | ||||||||||||||||||||||||||||||||||||||||||
| region, | ||||||||||||||||||||||||||||||||||||||||||
| clusterName, | ||||||||||||||||||||||||||||||||||||||||||
| chrononJarUri, | ||||||||||||||||||||||||||||||||||||||||||
| "ai.chronon.spark.Driver" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| val a = DataprocSubmitter(submitterConf) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| val jobId = a.submit( | ||||||||||||||||||||||||||||||||||||||||||
| gcsFiles.toList, | ||||||||||||||||||||||||||||||||||||||||||
| userArgs: _* | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| println("Dataproc submitter job id: " + jobId) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| object DataprocAuth extends JobAuth {} | ||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.