Skip to content
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

deps call sites #4199

Merged
merged 5 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/dbt/deps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from dbt.clients import system
from dbt.contracts.project import ProjectPackageMetadata
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.functions import fire_event
from dbt.events.types import DepsSetDownloadDirectory

DOWNLOADS_PATH = None

Expand All @@ -31,7 +32,7 @@ def downloads_directory():
remove_downloads = True

system.make_directory(DOWNLOADS_PATH)
logger.debug("Set downloads directory='{}'".format(DOWNLOADS_PATH))
fire_event(DepsSetDownloadDirectory(path=DOWNLOADS_PATH))

yield DOWNLOADS_PATH

Expand Down
9 changes: 3 additions & 6 deletions core/dbt/deps/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from dbt.exceptions import (
ExecutableError, warn_or_error, raise_dependency_error
)
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.functions import fire_event
from dbt.events.types import EnsureGitInstalled
from dbt import ui

PIN_PACKAGE_URL = 'https://docs.getdbt.com/docs/package-management#section-specifying-package-versions' # noqa
Expand Down Expand Up @@ -81,11 +82,7 @@ def _checkout(self):
)
except ExecutableError as exc:
if exc.cmd and exc.cmd[0] == 'git':
logger.error(
'Make sure git is installed on your machine. More '
'information: '
'https://docs.getdbt.com/docs/package-management'
)
fire_event(EnsureGitInstalled())
raise
return os.path.join(get_downloads_path(), dir_)

Expand Down
8 changes: 4 additions & 4 deletions core/dbt/deps/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
ProjectPackageMetadata,
LocalPackage,
)
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.functions import fire_event
from dbt.events.types import DepsCreatingLocalSymlink, DepsSymlinkNotAvailable


class LocalPackageMixin:
Expand Down Expand Up @@ -57,12 +58,11 @@ def install(self, project, renderer):
system.remove_file(dest_path)

if can_create_symlink:
logger.debug(' Creating symlink to local dependency.')
fire_event(DepsCreatingLocalSymlink())
system.make_symlink(src_path, dest_path)

else:
logger.debug(' Symlinks are not available on this '
'OS, copying dependency.')
fire_event(DepsSymlinkNotAvailable())
shutil.copytree(src_path, dest_path)


Expand Down
29 changes: 29 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,31 @@ def cli_msg(self) -> str:
return self.msg


@dataclass
class DepsSetDownloadDirectory(DebugLevel, CliEventABC):
path: str

def cli_msg(self) -> str:
return f"Set downloads directory='{self.path}'"


class EnsureGitInstalled(ErrorLevel, CliEventABC):
def cli_msg(self) -> str:
return ('Make sure git is installed on your machine. More '
'information: '
'https://docs.getdbt.com/docs/package-management')


class DepsCreatingLocalSymlink(DebugLevel, CliEventABC):
def cli_msg(self) -> str:
return ' Creating symlink to local dependency.'


class DepsSymlinkNotAvailable(DebugLevel, CliEventABC):
def cli_msg(self) -> str:
return ' Symlinks are not available on this OS, copying dependency.'


# since mypy doesn't run on every file we need to suggest to mypy that every
# class gets instantiated. But we don't actually want to run this code.
# making the conditional `if False` causes mypy to skip it as dead code so
Expand Down Expand Up @@ -1778,3 +1803,7 @@ def cli_msg(self) -> str:
InvalidProfileTemplateYAML()
ProjectNameAlreadyExists(name='')
GetAddendum(msg='')
DepsSetDownloadDirectory(path='')
EnsureGitInstalled()
DepsCreatingLocalSymlink()
DepsSymlinkNotAvailable()