Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bundle:
name: test-bundle

artifacts:
my_test_code:
type: whl
path: "./my_test_code"
build: python setup.py bdist_wheel
dynamic_version: true

resources:
pipelines:
test_pipeline:
name: "My Wheel Pipeline"
environment:
dependencies:
- ./my_test_code/dist/*.whl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from setuptools import setup, find_packages

import src

setup(
name="my_test_code",
version=src.__version__,
author=src.__author__,
url="https://databricks.com",
author_email="john.doe@databricks.com",
description="my test wheel",
packages=find_packages(include=["src"]),
entry_points={"group_1": "run=src.__main__:main"},
install_requires=["setuptools"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "0.0.1"
__author__ = "Databricks"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
The entry point of the Python Wheel
"""

import sys


def main():
# This method will print the provided arguments
print("Hello from my func")
print("Got arguments:")
print(sys.argv)


if __name__ == "__main__":
main()

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

>>> [CLI] bundle deploy
Building my_test_code...
Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> find.py --expect 2 whl
.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl
my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl

=== Expecting the patched wheel in the pipeline environment
>>> print_requests.py --keep //api/2.0/pipelines
{
"method": "POST",
"path": "/api/2.0/pipelines",
"body": {
"channel": "CURRENT",
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
},
"edition": "ADVANCED",
"environment": {
"dependencies": [
"/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl"
]
},
"name": "My Wheel Pipeline"
}
}

=== Expecting the patched and original wheels to be uploaded
>>> jq .path
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl"
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl"
13 changes: 13 additions & 0 deletions acceptance/bundle/artifacts/pipelines_environments_dynamic/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trace $CLI bundle deploy

trace find.py --expect 2 whl

title "Expecting the patched wheel in the pipeline environment"
trace print_requests.py --keep //api/2.0/pipelines | contains.py \
'artifacts/.internal/my_test_code-0.0.1+' \
'!artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl'

title "Expecting the patched and original wheels to be uploaded"
trace jq .path < out.requests.txt | grep import | grep whl | sort

rm out.requests.txt
21 changes: 21 additions & 0 deletions bundle/libraries/switch_to_patched_wheels.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ func (c switchToPatchedWheels) Apply(ctx context.Context, b *bundle.Bundle) diag
}
}

for pipelineName, pipelineRef := range b.Config.Resources.Pipelines {
if pipelineRef == nil {
continue
}

env := pipelineRef.Environment
if env == nil {
continue
}

for depInd, dep := range env.Dependencies {
repl := replacements[dep]
if repl != "" {
log.Debugf(ctx, "Updating resources.pipelines.%s.environment.dependencies[%d] from %s to %s", pipelineName, depInd, dep, repl)
env.Dependencies[depInd] = repl
} else {
log.Debugf(ctx, "Not updating resources.pipelines.%s.environment.dependencies[%d] from %s. Available replacements: %v", pipelineName, depInd, dep, slices.Sorted(maps.Keys(replacements)))
}
}
}

return nil
}

Expand Down
Loading