Skip to content

Conversation

@andrewnester
Copy link
Contributor

Changes

Fix processing short pip flags in environment dependencies

Why

Fixes #3674

Tests

Added unit test case


func containsPipFlag(input string) bool {
re := regexp.MustCompile(`--[a-zA-Z0-9-]+`)
re := regexp.MustCompile(`--?[a-zA-Z0-9-]+`)
Copy link
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
Contributor Author

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
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
Contributor Author

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

@eng-dev-ecosystem-bot
Copy link
Collaborator

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

Run: 18222671618

Env ✅​pass 🙈​skip
✅​ aws linux 320 537
✅​ aws windows 321 536
✅​ aws-ucws linux 436 433
✅​ aws-ucws windows 437 432
✅​ azure linux 320 536
✅​ azure windows 321 535
✅​ azure-ucws linux 436 432
✅​ azure-ucws windows 437 431
✅​ gcp linux 319 538
✅​ gcp windows 320 537

TranslateModeEnvironmentPipFlag,
func(s string) bool {
_, ok := libraries.IsLocalRequirementsFile(s)
_, _, ok := libraries.IsLocalPathInPipFlag(s)
Copy link
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
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
Contributor Author

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

### Dependency updates

### Bundles
* Fix processing short pip flags in environment dependencies ([#3708](https://github.com/databricks/cli/pull/3708))
Copy link
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
Contributor Author

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
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
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
Contributor Author

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 queue Oct 3, 2025
Merged via the queue into main with commit 4246149 Oct 3, 2025
13 checks passed
@andrewnester andrewnester deleted the fix/env-pip-option branch October 3, 2025 13:29
github-merge-queue bot 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-tagging bot 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))
Sign up for free to 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

5 participants