In the end, the fix was quite simple. Recently, there is a new field on pipelines to specify details of the DLT environment.

Note the environment.dependencies subfield and the use of "${workspace.artifact_path}/.internal/my_package-*-py3-none-any.whl" to depend on the dynamic-versioned bundle wheel file. This works perfectly, and runs before any of the spark cluster nodes start to process, thereby avoiding the race condition of the previous solution.

 

resources:
  pipelines:
    my_pipeline:
      name: my_pipeline
      catalog: ${var.bronze_catalog}
      schema: ${resources.schemas.bronze.name}
      configuration:
        bronze_catalog: ${var.bronze_catalog}
        silver_catalog: ${var.silver_catalog}
        gold_catalog: ${var.gold_catalog}
        bronze_schema: ${resources.schemas.bronze.name}
        silver_schema: ${resources.schemas.silver.name}
        gold_schema: ${resources.schemas.gold.name}
      serverless: true
      photon: true
      continuous: false
      environment:
        dependencies:
          - "${workspace.artifact_path}/.internal/my_package-*-py3-none-any.whl"
      libraries:
        - file:
            path: ../../src/my_package/pipelines/p10_my_package_streaming_pipeline.py

      permissions:
        - service_principal_name: ${var.service_principal_name}
          level: CAN_MANAGE

 Here's the documentation: https://docs.databricks.com/api/workspace/pipelines/create#environment

One caveat: It can't handle spaces in the artifact path currently.

View solution in original post