Compare commits

...

4 Commits

Author SHA1 Message Date
Kshitij Aranke
9ed2d23759 Merge branch 'main' into deprecate_make_symlink 2023-11-06 19:04:47 +00:00
Kshitij Aranke
f8158560da Merge branch 'main' into deprecate_make_symlink 2023-09-06 16:52:46 +01:00
Kshitij Aranke
b4ed5a0713 Use os.symlink in patch for tests 2023-09-05 13:08:46 +01:00
Kshitij Aranke
eee0777148 Deprecate system.make_symlink 2023-09-05 13:02:05 +01:00
5 changed files with 9 additions and 31 deletions

View File

@@ -0,0 +1,6 @@
kind: Under the Hood
body: Deprecate make_symlink
time: 2023-09-05T13:01:55.327854+01:00
custom:
Author: aranke
Issue: ' '

View File

@@ -147,21 +147,6 @@ def make_file(path: str, contents: str = "", overwrite: bool = False) -> bool:
return False
def make_symlink(source: str, link_path: str) -> None:
"""
Create a symlink at `link_path` referring to `source`.
"""
if not supports_symlinks():
# TODO: why not import these at top?
raise dbt.exceptions.SymbolicLinkError()
os.symlink(source, link_path)
def supports_symlinks() -> bool:
return getattr(os, "symlink", None) is not None
def write_file(path: str, contents: str = "") -> bool:
path = convert_path(path)
try:

View File

@@ -1,3 +1,4 @@
import os
import shutil
from dbt.clients import system
@@ -58,7 +59,7 @@ class LocalPinnedPackage(LocalPackageMixin, PinnedPackage):
system.remove_file(dest_path)
try:
fire_event(DepsCreatingLocalSymlink())
system.make_symlink(src_path, dest_path)
os.symlink(src_path, dest_path)
except OSError:
fire_event(DepsSymlinkNotAvailable())
shutil.copytree(src_path, dest_path)

View File

@@ -729,20 +729,6 @@ class OperationError(CompilationError):
return msg
class SymbolicLinkError(CompilationError):
def __init__(self) -> None:
super().__init__(msg=self.get_message())
def get_message(self) -> str:
msg = (
"dbt encountered an error when attempting to create a symbolic link. "
"If this error persists, please create an issue at: \n\n"
"https://github.com/dbt-labs/dbt-core"
)
return msg
# context level exceptions
class ZipStrictWrongTypeError(CompilationError):
def __init__(self, exc) -> None:

View File

@@ -93,7 +93,7 @@ class TestGitPackage(unittest.TestCase):
self.assertIs(a_pinned.warn_unpinned, True)
@mock.patch("shutil.copytree")
@mock.patch("dbt.deps.local.system.make_symlink")
@mock.patch("os.symlink")
@mock.patch("dbt.deps.local.LocalPinnedPackage.get_installation_path")
@mock.patch("dbt.deps.local.LocalPinnedPackage.resolve_path")
def test_deps_install(