-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy dir if symlink fails #7447
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28875a6
Copy dir if symlink fails
anjutiwari ffa6d01
Copy dir if symlink fails
anjutiwari 56087c4
Merge branch 'main' into CT-2457/dbt-deps
anjutiwari a4d28cf
Update .changes/unreleased/Fixes-20230424-210734.yaml
gshank 1bbd247
Merge branch 'CT-2457/dbt-deps' of github.com:anjutiwari/dbt-core int…
gshank abb6c24
fix formatting of changelog
gshank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Copy dir during `dbt deps` if symlink fails | ||
time: 2023-04-24T21:07:34.336797+05:30 | ||
custom: | ||
Author: anjutiwari | ||
Issue: "7428 8223" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,19 +51,15 @@ def install(self, project, renderer): | |
src_path = self.resolve_path(project) | ||
dest_path = self.get_installation_path(project, renderer) | ||
|
||
can_create_symlink = system.supports_symlinks() | ||
|
||
if system.path_exists(dest_path): | ||
if not system.path_is_symlink(dest_path): | ||
system.rmdir(dest_path) | ||
else: | ||
system.remove_file(dest_path) | ||
|
||
if can_create_symlink: | ||
try: | ||
fire_event(DepsCreatingLocalSymlink()) | ||
system.make_symlink(src_path, dest_path) | ||
|
||
else: | ||
except OSError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.getdbt.com/faqs/core/install-pip-os-prereqs.md |
||
fire_event(DepsSymlinkNotAvailable()) | ||
shutil.copytree(src_path, dest_path) | ||
|
||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if can_create_symlink
check shouldn't be removed. It helps for the cases wheresymlink
function doesn't exist onos
, in which caseAttributeError
would be thrown.except OSError
should be added as an edge case like ours, whereos.symlink
function exists but it still fails.Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need it,
make_symlink
calling it. The functionality remains the same. Check make_symlink method.https://github.com/anjutiwari/dbt-core/blob/main/core/dbt/clients/system.py#L156
https://docs.getdbt.com/faqs/core/install-pip-os-prereqs.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make_symlink
method will throwdbt.exceptions.SymbolicLinkError
, in which caseexcept OSError
block here won't handle it.The behaviour is changed for the case where
symlink
function attribute isn't present onos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think we should use
dbt.exceptions.SymbolicLinkError,
and we should also catch the SymbolicLinkError.Also, I am curious about which OS does not have symlinks function in python
lib(os)
package, as mentioned in my Issue description.As per the dbt, we have a list of supported operating systems and condition on python3.7+. https://docs.getdbt.com/faqs/core/install-pip-os-prereqs.md
If my understanding is true, we may not have any scenarios where
lib(os)
package will not have asymlink
function and we may not need to handle the SymbolicLinkError exception.Waiting for the core reviewers to help us here.