fix: support absolute paths in feast init CLI argument#6146
Open
joaquinhuigomez wants to merge 1 commit intofeast-dev:masterfrom
Open
fix: support absolute paths in feast init CLI argument#6146joaquinhuigomez wants to merge 1 commit intofeast-dev:masterfrom
joaquinhuigomez wants to merge 1 commit intofeast-dev:masterfrom
Conversation
Comment on lines
+469
to
+472
| if os.sep in project_directory: | ||
| if not repo_path: | ||
| repo_path = project_directory | ||
| project_directory = os.path.basename(project_directory) |
Contributor
There was a problem hiding this comment.
🔴 Trailing slash in path argument produces empty project name
When a user runs feast init /tmp/test/ (with a trailing slash), os.path.basename("/tmp/test/") returns an empty string ''. This empty string passes the is_valid_name check at sdk/python/feast/repo_operations.py:577-581 (since an empty string doesn't start with _ or - and has no invalid characters), so init_repo proceeds to template feature_store.yaml with project: (empty project name), producing a corrupt configuration. The same issue occurs with any trailing-separator path like test/.
Suggested change
| if os.sep in project_directory: | |
| if not repo_path: | |
| repo_path = project_directory | |
| project_directory = os.path.basename(project_directory) | |
| if os.sep in project_directory: | |
| if not repo_path: | |
| repo_path = project_directory | |
| project_directory = os.path.basename(project_directory.rstrip(os.sep)) |
Was this helpful? React with 👍 or 👎 to provide feedback.
When a user runs `feast init /tmp/test`, the path argument is now correctly parsed: the directory path is used as repo_path and the basename is used as the project name. Previously, the entire path was validated as a project name, which failed because slashes are not valid in project names. Fixes feast-dev#6134 Signed-off-by: Joaquin Hui Gomez <132194176+joaquinhuigomez@users.noreply.github.com>
d58bb9e to
2644985
Compare
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.
Summary
Fixes #6134
feast init /tmp/testcurrently fails with:The root cause is that when a path (containing
/) is passed as thePROJECT_DIRECTORYargument, the entire string (e.g./tmp/test) is validated as a project name. Since slashes aren't valid in project names, validation fails.Fix
When
PROJECT_DIRECTORYcontains a path separator, the CLI now:repo_path(the target directory)testfrom/tmp/test)This makes
feast init /tmp/testbehave equivalently tofeast init test --repo-path /tmp/test, which already works correctly.If
--repo-pathis explicitly provided alongside a path argument, the explicit--repo-pathtakes precedence.Test plan
feast init /tmp/testcreates the repo at/tmp/testwith project nametestfeast init myprojectstill works as before (no path separator, no behavior change)feast init /tmp/test --repo-path /other/pathuses/other/pathas the directory andtestas the name