Pre-stage Spark-NLP fat jar via spark.jars (no per-job Ivy resolution)#6
Open
d0choa wants to merge 2 commits into
Open
Pre-stage Spark-NLP fat jar via spark.jars (no per-job Ivy resolution)#6d0choa wants to merge 2 commits into
d0choa wants to merge 2 commits into
Conversation
The pts and pts_literature clusters declared Spark-NLP as a Spark package (spark:spark.jars.packages), which lands in spark-defaults.conf and makes every pts spark-submit re-run Ivy dependency resolution against Maven Central before its session starts — even though only ~9 of ~40 steps use Spark-NLP. This wastes driver time and, more importantly, puts Maven Central on the critical path of every pts step (opentargets/issues#4453). Load Spark-NLP from a pre-resolved fat jar via spark.jars instead. Orchestration stages the version-pinned John Snow Labs assembly jar into the pipelines bucket before cluster creation (idempotent), and the clusters localize it from in-region GCS — no dependency resolution, no Maven Central on any runtime path. - operators/gcs.py: UploadRemoteFileOperator gains skip_if_exists (idempotent staging) and a configurable timeout (hard timeout=10 was unsafe for ~629 MB). - utils/utils.py: resolve_jar_staging(spark_jars, registry, managed_prefix), a pure resolver over a cluster's rendered spark.jars. Registered jar -> staged; jar under the managed prefix with no registered source -> raises (DAG fails at parse time); jar outside the prefix -> left alone. - config/unified_pipeline.py: staged_jars registry {dst_uri -> src_url} + staged_jar_prefix; spark_nlp_version wired into the clusters template context. - dags/unified_pipeline.py: read the real spark:spark.jars, resolve against the registry, fan out one upload per jar upstream of create_cluster. - clusters.yaml: pts + pts_literature spark.jars.packages -> spark.jars staged jar. - unified_pipeline.yaml: spark_nlp_version 6.1.5 (matches OnToma's spark-nlp dep). - tests/test_jar_staging.py: unit tests for the resolver (no Airflow needed). Refs opentargets/issues#4453
OnToma 2.5.2 (opentargets/OnToma#60) validates Spark NLP by probing the JVM classpath instead of requiring spark.jars.packages to name spark-nlp. That lets the pts / pts_literature clusters load Spark NLP from a pre-staged fat jar via spark.jars (no per-job Ivy resolution against Maven Central) while OnToma-using steps still start. Companion to the orchestration jar-staging change; refs opentargets/issues#4453.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stop the
pts/pts_literatureDataproc clusters re-running Spark-NLP Ivyresolution against Maven Central on every
spark-submit. Load Spark-NLP from apre-resolved fat jar via
spark.jars(staged by orchestration into thepipelines bucket) instead of resolving the package via
spark.jars.packages.This is the monorepo home of the work previously split across
opentargets-archive/orchestration#217 and opentargets-archive/pts#146 — both now closed
in favour of this PR. Business logic is equivalent, ported onto
pipelineandadapted to its layout / code style (single quotes, current cluster APIs).
Why
A
spark:cluster property lands inspark-defaults.conf, sospark.jars.packagesmade every ptsspark-submitre-run Ivy dependencyresolution against Maven Central before its session started — even though only
~9 of ~40 steps use Spark-NLP. Evidence (run
up-pts-38bc6): 17/17 jobs ranIvy resolution, ~3–7 s each, with Maven Central on the critical path of every
step. A pre-resolved fat jar is localized from in-region GCS at submit time — no
dependency resolution, no Maven Central on any runtime path. Details:
opentargets/issues#4453.
Changes
orchestration (
orchestration: pre-stage Spark-NLP fat jar via spark.jars)operators/gcs.py—UploadRemoteFileOperatorgainsskip_if_exists(idempotent staging) and a configurable
timeout(hardtimeout=10was unsafefor a ~629 MB stream).
utils/utils.py—resolve_jar_staging(spark_jars, registry, managed_prefix),a pure resolver over a cluster's rendered
spark.jars: registered jar → staged;jar under the managed prefix with no registered source → raises (DAG fails
at parse time); jar outside the prefix → left alone.
config/unified_pipeline.py— astaged_jarsregistry ({dst_uri: src_url})staged_jar_prefix;spark_nlp_versionwired into the clusters templatecontext. Adding a staged jar is a one-line registry entry.
dags/unified_pipeline.py— read the realspark:spark.jars, resolve againstthe registry, fan out one
UploadRemoteFileOperator(skip_if_exists=True)perjar upstream of
create_cluster.pts,pts_literature, and any futurecluster referencing a registered jar are covered automatically.
clusters.yaml—pts+pts_literaturespark.jars.packages→spark.jars.unified_pipeline.yaml—spark_nlp_version: '6.1.5'.tests/test_jar_staging.py— resolver unit tests (no Airflow needed).pts (
pts: require ontoma>=2.5.2 for classpath-based Spark NLP check)pyproject.toml—ontoma>=2.5.1→>=2.5.2. Becausespark.jarsdoesn'tpopulate
spark.jars.packages, OnToma ≤2.5.1 (which guarded on that configstring) would refuse to run. OnToma 2.5.2 (fix: validate Spark NLP by classpath probe, not spark.jars.packages string OnToma#60) validates
Spark-NLP by probing the JVM classpath, so it accepts jars loaded via
spark.jarstoo.Coordination / merge order
OnToma is a separate repo (not part of
pipeline), so its fix stays its own PR:ontoma>=2.5.2pts/uv.lock.Validation
resolve_jar_stagingunit tests pass (registered / external / under-prefix-raises/ comma-list / empty).
ruff checkandty checkpass on all changed orchestration files.tests/test_dag_validation.pypasses — the DAG builds with the staging fan-out.UnifiedPipelineConfig:ptsandpts_literatureeachresolve to exactly the
(JSL S3 source → gs://…/spark-nlp-assembly-6.1.5.jar)pair; no
spark.jars.packagesremains.PTS Dataproc jobs re-run Spark-NLP Ivy resolution on every step issues#4453): no Ivy
:: resolution report ::block; OnToma stepsstill map diseases; non-OnToma steps start clean.
Refs opentargets/issues#4453