Skip to content

Commit 3b163e5

Browse files
authored
Merge pull request #58 from getindata/release-0.15.0
Release 0.15.0
2 parents d1e91dd + 9540663 commit 3b163e5

File tree

11 files changed

+1457
-1268
lines changed

11 files changed

+1457
-1268
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
## [0.15.0] - 2022-02-11
6+
7+
- Migration to dbt 1.0.1
8+
59
## [0.14.0] - 2022-02-02
610

711
## [0.13.0] - 2022-02-01
@@ -152,7 +156,9 @@
152156
- Draft of `dp init`, `dp create`, `dp template new`, `dp template list` and `dp dbt`
153157
- Draft of `dp compile` and `dp deploy`
154158

155-
[Unreleased]: https://github.com/getindata/data-pipelines-cli/compare/0.14.0...HEAD
159+
[Unreleased]: https://github.com/getindata/data-pipelines-cli/compare/0.15.0...HEAD
160+
161+
[0.15.0]: https://github.com/getindata/data-pipelines-cli/compare/0.14.0...0.15.0
156162

157163
[0.14.0]: https://github.com/getindata/data-pipelines-cli/compare/0.13.0...0.14.0
158164

data_pipelines_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
pipelines.
66
"""
77

8-
version = "0.14.0"
8+
version = "0.15.0"

data_pipelines_cli/cli_commands/compile.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import yaml
66

77
from ..cli_constants import BUILD_DIR, IMAGE_TAG_TO_REPLACE
8-
from ..cli_utils import echo_error, echo_info, echo_warning
8+
from ..cli_utils import echo_info, echo_warning
99
from ..config_generation import (
1010
copy_config_dir_to_build_dir,
1111
copy_dag_dir_to_build_dir,
@@ -14,11 +14,7 @@
1414
from ..data_structures import DockerArgs
1515
from ..dbt_utils import read_dbt_vars_from_configs, run_dbt_command
1616
from ..docker_response_reader import DockerResponseReader
17-
from ..errors import (
18-
DataPipelinesError,
19-
DockerErrorResponseError,
20-
DockerNotInstalledError,
21-
)
17+
from ..errors import DockerErrorResponseError, DockerNotInstalledError
2218
from ..io_utils import replace
2319
from ..jinja import replace_vars_with_values
2420

@@ -31,22 +27,19 @@ def _docker_build(docker_args: DockerArgs) -> None:
3127
"""
3228
try:
3329
import docker
30+
import docker.errors
3431
except ModuleNotFoundError:
3532
raise DockerNotInstalledError()
3633

3734
echo_info("Building Docker image")
3835
docker_client = docker.from_env()
3936
docker_tag = docker_args.docker_build_tag()
40-
_, logs_generator = docker_client.images.build(path=".", tag=docker_tag)
4137
try:
38+
_, logs_generator = docker_client.images.build(path=".", tag=docker_tag)
4239
DockerResponseReader(logs_generator).click_echo_ok_responses()
43-
except DockerErrorResponseError as err:
44-
echo_error(err.message)
45-
raise DataPipelinesError(
46-
"Error raised when pushing Docker image. Ensure that "
47-
"Docker image you try to push exists. Maybe try running "
48-
"'dp compile' first?"
49-
)
40+
except docker.errors.BuildError as err:
41+
build_log = "\n".join([str(log) for log in err.build_log])
42+
raise DockerErrorResponseError(f"{err.msg}\n{build_log}")
5043

5144

5245
def _dbt_compile(env: str) -> None:

data_pipelines_cli/cli_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ def echo_error(text: str, **kwargs: Any) -> None:
2525
click.secho(text, file=sys.stderr, fg="red", **kwargs)
2626

2727

28+
def echo_suberror(text: str, **kwargs: Any) -> None:
29+
"""
30+
Print a suberror message to stderr using click-specific print function.
31+
32+
:param text: Message to print
33+
:type text: str
34+
:param kwargs:
35+
"""
36+
click.secho(text, file=sys.stderr, fg="bright_red", **kwargs)
37+
38+
2839
def echo_warning(text: str, **kwargs: Any) -> None:
2940
"""
3041
Print a warning message to stderr using click-specific print function.

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import os
1010
import sys
1111

12+
sys.path.insert(0, os.path.abspath("."))
13+
sys.path.insert(0, os.path.abspath("../"))
1214
sys.path.insert(0, os.path.abspath("../data_pipelines_cli"))
1315

1416

@@ -27,7 +29,7 @@
2729
extensions = [
2830
"sphinx.ext.autodoc",
2931
"sphinx.ext.viewcode",
30-
"sphinx_click.ext",
32+
"sphinx_click",
3133
"myst_parser",
3234
]
3335

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx-rtd-theme==1.0.0
2-
sphinx-click>=3.0,<3.1
2+
sphinx-click>=3.1,<3.2
33
myst-parser>=0.16, <0.17
44
docutils>=0.17,<0.18
5+
GitPython==3.1.26

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.14.0
2+
current_version = 0.15.0
33

44
[bumpversion:file:setup.py]
55

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
README = f.read()
77

88
INSTALL_REQUIREMENTS = [
9-
"click<8.0",
9+
"click>=8.0.3,<9.0",
1010
"questionary==1.10.0",
1111
"pyyaml>=5.1, <6.0",
1212
"types-PyYAML>=6.0",
1313
"copier==5.1.0",
14-
"dbt>=0.21, <0.22",
14+
"dbt-core==1.0.1",
1515
"Jinja2>=2.11,<2.12",
1616
"fsspec",
17+
"packaging>=20.4,<21.0",
1718
]
1819

1920
EXTRA_FILESYSTEMS_REQUIRE = {
@@ -44,15 +45,16 @@
4445
"docs": [
4546
"sphinx==4.3.1",
4647
"sphinx-rtd-theme==1.0.0",
47-
"sphinx-click>=3.0,<3.1",
48+
"sphinx-click>=3.1,<3.2",
4849
"myst-parser>=0.16, <0.17",
50+
"GitPython==3.1.26",
4951
],
5052
**EXTRA_FILESYSTEMS_REQUIRE,
5153
}
5254

5355
setup(
5456
name="data_pipelines_cli",
55-
version="0.14.0",
57+
version="0.15.0",
5658
description="CLI for data platform",
5759
long_description=README,
5860
long_description_content_type="text/markdown",

tests/cli_commands/test_compile.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _mock_docker(**kwargs):
130130

131131
runner = CliRunner()
132132
with patch.dict(
133-
"sys.modules", docker=docker_mock
133+
"sys.modules", **{"docker": docker_mock, "docker.errors": MagicMock()}
134134
), tempfile.TemporaryDirectory() as tmp_dir, patch(
135135
"data_pipelines_cli.cli_commands.compile.BUILD_DIR", pathlib.Path(tmp_dir)
136136
), patch(
@@ -146,6 +146,40 @@ def _mock_docker(**kwargs):
146146
self.assertEqual(0, result.exit_code, msg=result.exception)
147147
self.assertEqual("my_docker_repository_uri:aaa9876aaa", docker_tag)
148148

149+
@patch("pathlib.Path.cwd", lambda: goldens_dir_path)
150+
@patch("data_pipelines_cli.data_structures.git_revision_hash")
151+
def test_docker_throw_build_error(self, mock_git_revision_hash):
152+
commit_sha = "aaa9876aaa"
153+
mock_git_revision_hash.return_value = commit_sha
154+
155+
class MockException(Exception):
156+
msg = "some error message"
157+
build_log = ["more", "errors"]
158+
159+
docker_errors_mock = MagicMock(BuildError=MockException)
160+
docker_images_mock = MagicMock(build=MagicMock(side_effect=MockException))
161+
docker_client_mock = MagicMock(images=docker_images_mock)
162+
docker_mock = MagicMock(from_env=lambda: docker_client_mock, errors=docker_errors_mock)
163+
164+
with patch.dict(
165+
"sys.modules", **{"docker": docker_mock, "docker.errors": docker_errors_mock}
166+
), tempfile.TemporaryDirectory() as tmp_dir, patch(
167+
"data_pipelines_cli.cli_commands.compile.BUILD_DIR", pathlib.Path(tmp_dir)
168+
), patch(
169+
"data_pipelines_cli.cli_constants.BUILD_DIR", pathlib.Path(tmp_dir)
170+
), patch(
171+
"data_pipelines_cli.config_generation.BUILD_DIR", pathlib.Path(tmp_dir)
172+
), patch(
173+
"data_pipelines_cli.dbt_utils.BUILD_DIR", pathlib.Path(tmp_dir)
174+
), patch(
175+
"data_pipelines_cli.dbt_utils.subprocess_run", self._mock_run
176+
):
177+
with self.assertRaises(DataPipelinesError):
178+
try:
179+
compile_project("base", True)
180+
except MockException:
181+
self.fail()
182+
149183
@patch("pathlib.Path.cwd", lambda: goldens_dir_path)
150184
@patch("data_pipelines_cli.data_structures.git_revision_hash")
151185
def test_docker_throw_on_error(self, mock_git_revision_hash):
@@ -159,15 +193,23 @@ def _mock_docker(**_kwargs):
159193
'"error":"An image cannot be built."}',
160194
]
161195

196+
class MockException(Exception):
197+
pass
198+
199+
docker_errors_mock = MagicMock()
200+
docker_errors_mock.BuildError = MockException
201+
162202
docker_images_mock = MagicMock()
163203
docker_images_mock.configure_mock(**{"build": _mock_docker})
164204
docker_client_mock = MagicMock()
165205
docker_client_mock.configure_mock(**{"images": docker_images_mock})
166206
docker_mock = MagicMock()
167-
docker_mock.configure_mock(**{"from_env": lambda: docker_client_mock})
207+
docker_mock.configure_mock(
208+
**{"from_env": lambda: docker_client_mock, "errors": docker_errors_mock}
209+
)
168210

169211
with patch.dict(
170-
"sys.modules", docker=docker_mock
212+
"sys.modules", **{"docker": docker_mock, "docker.errors": docker_errors_mock}
171213
), tempfile.TemporaryDirectory() as tmp_dir, patch(
172214
"data_pipelines_cli.cli_commands.compile.BUILD_DIR", pathlib.Path(tmp_dir)
173215
), patch(

0 commit comments

Comments
 (0)