Skip to content

Fix processing short pip flags in environment dependencies - #3708

Merged
andrewnester merged 6 commits into
mainfrom
fix/env-pip-option
Oct 3, 2025
Merged

Fix processing short pip flags in environment dependencies#3708
andrewnester merged 6 commits into
mainfrom
fix/env-pip-option

Conversation

@andrewnester

Copy link
Copy Markdown
Contributor

Changes

Fix processing short pip flags in environment dependencies

Why

Fixes#3674

Tests

Added unit test case

Comment threadbundle/libraries/local_path.go Outdated

func containsPipFlag(input string) bool {
re := regexp.MustCompile(`--[a-zA-Z0-9-]+`)
re := regexp.MustCompile(`--?[a-zA-Z0-9-]+`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller of this function can now be simplified. It checks for -r right after.

Btw, how do we do local relative path interpretation for -r, and can we extend that to -e as well?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pietern fixed here f62f9e3
We do translation in TranslatePaths, added a comment about it

{path: "s3://mybucket/path/to/package", expected: false},
{path: "dbfs:/mnt/path/to/package", expected: false},
{path: "beautifulsoup4", expected: false},
{path: "-e some/local/path", expected: false},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some more tricky cases that we should cover here :-/ AI might help identify and handle them

-i http://myindexurl.com
--trusted-host pypi.org
--platform win_amd64
-e ${workspace.file_path}
-e /Workspace/path/to
-e /Volumes/path/to

Btw, Andrew, please consider how to incorporate such cases. It could be that what you have here is just net-better than what we have now and that we should have a followup with refinements. It could also be that we just need to revise this PR to cover things like -i properly, also to make sure we don't regress anything.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have quite a good coverage for this overall, but I've added some additional cases for unit / acceptacne tests

Comment threadbundle/config/mutator/normalize_paths_test.go
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator

Run: 18222671618

Env✅​pass🙈​skip
✅​aws linux320537
✅​aws windows321536
✅​aws-ucws linux436433
✅​aws-ucws windows437432
✅​azure linux320536
✅​azure windows321535
✅​azure-ucws linux436432
✅​azure-ucws windows437431
✅​gcp linux319538
✅​gcp windows320537

TranslateModeEnvironmentPipFlag,
func(s string) bool {
_, ok := libraries.IsLocalRequirementsFile(s)
_, _, ok := libraries.IsLocalPathInPipFlag(s)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the same change for pipeline environment dependencies?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't handle any flags there yet, so could be a separate follow-up PR with dedicated changelog entry.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this as a follow-up for this PR

Comment threadbundle/libraries/local_path.go Outdated
Comment threadbundle/libraries/local_path_test.go
Comment threadNEXT_CHANGELOG.md
### Dependency updates

### Bundles
* Fix processing short pip flags in environment dependencies ([#3708](https://github.com/databricks/cli/pull/3708))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR now also handles relative paths for -e. We can include additional entries for the same PR, for different user-visible changes (eg call out -e specifically).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here fa7327c


func IsLocalPathInPipFlag(dep string) (string, string, bool) {
for _, flag := range PipFlagsWithLocalPaths {
dep, ok := strings.CutPrefix(dep, flag+" ")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dep aliases the input. It works because of := but is error-prone. Recommend to use a different name.

// Trailing space means the the flag takes an argument or there's multiple arguments in input
// Alternatively it could be a flag with no argument and no space after it
// For example: -r myfile.txt or --index-url http://myindexurl.com or -i
re := regexp.MustCompile(`--?[a-zA-Z0-9-]+(\s|$)`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made me realize we also need ^ on the regex (or ^\s*), or we risk also matching foo-bar.

While unlikely to be a valid filename, it is never a flag.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, it should be ^\s* indeed, will add an use case for this

@andrewnester
andrewnester added this pull request to the merge queueOct 3, 2025
Merged via the queue into main with commit 4246149Oct 3, 2025
13 checks passed
@andrewnester
andrewnester deleted the fix/env-pip-option branch October 3, 2025 13:29
github-merge-queueBot pushed a commit that referenced this pull request Oct 3, 2025
## Changes
Added ^\s* for pip flag regexp so we don't match `foo-bar` as a flag
Renamed variable to avoid shadowing
## Why
Followups for #3708
andrewnester added a commit that referenced this pull request Oct 8, 2025
## Changes
Fix PIP flag processing in pipeline environment dependencies
## Why
Follow up for #3708
## Tests
Added an acceptance test
<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
deco-sdk-taggingBot added a commit that referenced this pull request Oct 8, 2025
## Release v0.272.0
### Bundles
* Fix processing short pip flags in environment dependencies ([#3708](#3708))
* Add support for referencing local files in -e pip flag for environment dependencies ([#3708](#3708))
* Add error for when an etag is specified in dashboard configuration. Setting etags was never supported / valid in bundles but now users will see this error during validation rather than deployment. ([#3723](#3723))
* Fix PIP flag processing in pipeline environment dependencies ([#3734](#3734))
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
Fix processing short pip flags in environment dependencies
## Why
Fixes#3674
## Tests
Added unit test case
<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
Added ^\s* for pip flag regexp so we don't match `foo-bar` as a flag
Renamed variable to avoid shadowing
## Why
Followups for #3708
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
Fix PIP flag processing in pipeline environment dependencies
## Why
Follow up for #3708
## Tests
Added an acceptance test
<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
denik pushed a commit that referenced this pull request May 20, 2026
## Release v0.272.0
### Bundles
* Fix processing short pip flags in environment dependencies ([#3708](#3708))
* Add support for referencing local files in -e pip flag for environment dependencies ([#3708](#3708))
* Add error for when an etag is specified in dashboard configuration. Setting etags was never supported / valid in bundles but now users will see this error during validation rather than deployment. ([#3723](#3723))
* Fix PIP flag processing in pipeline environment dependencies ([#3734](#3734))
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment paths with pip options are not supported

4 participants

@andrewnester@eng-dev-ecosystem-bot@pietern@lennartkats-db