mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(emr-containers): run the Scala kernel on a managed endpoint's gateway (#9276)
Interactive endpoints "support the following kernels: Python 3, PySpark on Kubernetes, Apache Spark with Scala" (EMR on EKS Development Guide, "Overview of interactive endpoints"). A Floci endpoint's gateway had no Scala kernel. - The gateway program writes a spark-scala-kubernetes kernel spec, "Apache Spark with Scala", a name of Floci's beside the guide's spark-python-kubernetes, as the guide gives the Scala kernel none. It runs the image's Apache Toree, beside Jupyter Enterprise Gateway's Scala launcher, under spark-submit as Toree's own kernel spec does: org.apache.toree.Main with the connection file as its profile, after KERNEL_EXTRA_SPARK_OPTS. Its spark is a Spark session in Spark's local mode on Floci's S3, as the PySpark kernel's is. - The docs move the Scala kernel out of "Not emulated yet", and the endpoint role every kernel runs with out of it too: "All kernels and users that connect to the interactive endpoint utilize the role that you specified when you created the endpoint". - The nightly check lists the new kernel spec and counts an S3 file's lines in the Scala kernel. Kernel start, connection and deletion become helpers. The method's timeout and the docker-runner group's budget grow by its four minutes.
This commit is contained in:
1 parent
39fbc98efe
commit
5c7ab956f9
4 files changed
+97
-60
No files matched your search
@@ -20,14 +20,16 @@ import java.util.Map;
|
||||
/**
|
||||
* What runs a managed endpoint's Jupyter Enterprise Gateway in the docker runner mode. "The interactive endpoint is
|
||||
* backed by a Jupyter Enterprise Gateway that provides the remote kernel lifecycle management capability that
|
||||
* interactive clients need", with the kernels "Python 3" and "PySpark on Kubernetes" (EMR on EKS Development Guide,
|
||||
* "Overview of interactive endpoints"), which run in the release's {@code notebook-spark} image ("the base image URI
|
||||
* in your Docker file must use notebook-spark in place of spark", "Custom kernel image with interactive endpoint").
|
||||
* That image holds jupyter_server and ipykernel but no Enterprise Gateway, so a Python program of Floci's own serves
|
||||
* the gateway's kernels API on jupyter_server in a container of it, its kernels in the same container: the image's
|
||||
* {@code python3} kernel, and a {@code spark-python-kubernetes} one, the name the guide's
|
||||
* {@code jupyter-kernel-overrides} example gives the PySpark kernel, whose {@code spark} and {@code sc} are a Spark
|
||||
* session in Spark's local mode, on Floci's S3, with the endpoint's execution role's credentials.
|
||||
* interactive clients need", with the kernels "Python 3", "PySpark on Kubernetes" and "Apache Spark with Scala" (EMR
|
||||
* on EKS Development Guide, "Overview of interactive endpoints"), which run in the release's {@code notebook-spark}
|
||||
* image ("the base image URI in your Docker file must use notebook-spark in place of spark", "Custom kernel image with
|
||||
* interactive endpoint"). That image holds jupyter_server and ipykernel but no Enterprise Gateway, so a Python
|
||||
* program of Floci's own serves the gateway's kernels API on jupyter_server in a container of it, its kernels in the
|
||||
* same container: the image's {@code python3} kernel; a {@code spark-python-kubernetes} one, the name the guide's
|
||||
* {@code jupyter-kernel-overrides} example gives the PySpark kernel; and a {@code spark-scala-kubernetes} one, a name
|
||||
* of Floci's beside it, as the guide gives the Scala kernel none, which runs the image's Apache Toree, beside Jupyter
|
||||
* Enterprise Gateway's Scala launcher. The Spark kernels' {@code spark} and {@code sc} are a Spark session in Spark's
|
||||
* local mode, on Floci's S3, with the endpoint's execution role's credentials.
|
||||
*
|
||||
* <p>As Jupyter Enterprise Gateway does, a kernel gets the {@code KERNEL_} variables of the {@code env} its start
|
||||
* request carries, as a Jupyter client sends those of its own environment: {@code KERNEL_EXTRA_SPARK_OPTS}, "additional
|
||||
@@ -115,6 +117,8 @@ final class EmrContainersGateways {
|
||||
SESSION_HEADER = "@SESSION_HEADER@"
|
||||
# The image's %%configure magic, beside Jupyter Enterprise Gateway's kernel launchers.
|
||||
MAGICS = "/usr/local/bin/kernel-launchers/python/scripts"
|
||||
# The image's Apache Toree, which Jupyter Enterprise Gateway's Scala launcher runs.
|
||||
TOREE = "/usr/local/bin/kernel-launchers/scala/lib/toree-assembly-*.jar"
|
||||
# Where the magic posts its cell's settings when no ENDPOINT_IP names its gateway: its own host's port.
|
||||
CONFIGURE_PORT = 18888
|
||||
# The magic's signature of a post: the SHA-256 of its body, encrypted with its kernel's AES key.
|
||||
@@ -155,6 +159,15 @@ final class EmrContainersGateways {
|
||||
"{connection_file}"],
|
||||
"env": {"PYTHONPATH": MAGICS},
|
||||
}))
|
||||
# As Toree's own kernel spec starts it, its connection file its profile.
|
||||
write(HOME + "/kernels/spark-scala-kubernetes/kernel.json", json.dumps({
|
||||
"display_name": "Apache Spark with Scala",
|
||||
"language": "scala",
|
||||
"argv": ["/bin/bash", "-c",
|
||||
'exec "$SPARK_HOME/bin/spark-submit" $KERNEL_EXTRA_SPARK_OPTS --class org.apache.toree.Main '
|
||||
+ TOREE + ' --profile "$0"',
|
||||
"{connection_file}"],
|
||||
}))
|
||||
|
||||
|
||||
# Whether the request being served carries the session token the kernel was started with.
|
||||
@@ -349,6 +362,7 @@ final class EmrContainersGateways {
|
||||
"--ServerApp.allow_remote_access=True",
|
||||
"--KernelSpecManager.allowed_kernelspecs=python3",
|
||||
"--KernelSpecManager.allowed_kernelspecs=spark-python-kubernetes",
|
||||
"--KernelSpecManager.allowed_kernelspecs=spark-scala-kubernetes",
|
||||
] + sys.argv[1:], kernel_manager_class=RemoteMappingKernelManager))
|
||||
""".replace("@HOME@", HOME).replace("@PORT@", String.valueOf(PORT))
|
||||
.replace("@PROGRAM_VARIABLE@", PROGRAM_VARIABLE).replace("@SESSION_HEADER@", SESSION_HEADER);
|
||||
|
||||
Reference in new issue
Block a user