datajunction 0.0.1a68.dev0__tar.gz → 0.0.1a68.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/PKG-INFO +1 -1
- datajunction-0.0.1a68.dev1/datajunction/__about__.py +4 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/builder.py +9 -9
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/compile.py +18 -45
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/exceptions.py +0 -4
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/nodes.py +3 -2
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_builder.py +6 -14
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_compile.py +4 -29
- datajunction-0.0.1a68.dev0/datajunction/__about__.py +0 -4
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/.coveragerc +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/.gitignore +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/.isort.cfg +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/.pre-commit-config.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/LICENSE.txt +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/Makefile +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/README.md +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/__init__.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/_internal.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/admin.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/client.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/models.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/datajunction/tags.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/pdm.lock +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/pyproject.toml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/setup.cfg +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/__init__.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/conftest.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/avg_length_of_employment.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/avg_repair_price.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/avg_time_to_dispatch.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/contractor.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/contractors.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/date.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/date_dim.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/dispatcher.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/dispatchers.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/hard_hat.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/hard_hat_state.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/hard_hats.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/local_hard_hats.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/municipality.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/municipality_dim.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/municipality_municipality_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/municipality_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/national_level_agg.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/num_repair_orders.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/regional_level_agg.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/regional_repair_efficiency.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_order.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_order_details.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_order_transform.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_orders.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_orders_cube.cube.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/repair_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/total_repair_cost.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/total_repair_order_discounts.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/us_region.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/us_state.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project1/roads/us_states.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project10/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/avg_length_of_employment.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/avg_repair_price.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/avg_time_to_dispatch.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/contractor.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/contractors.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/date.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/date_dim.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/dispatcher.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/dispatchers.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/hard_hat.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/hard_hat_state.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/hard_hats.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/local_hard_hats.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/municipality.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/municipality_dim.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/municipality_municipality_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/municipality_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/national_level_agg.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/num_repair_orders.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/regional_level_agg.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/regional_repair_efficiency.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_order.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_order_details.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_order_transform.transform.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_orders.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_orders_cube.cube.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/repair_type.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/total_repair_cost.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/total_repair_order_discounts.metric.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/us_region.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/us_state.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/us_states.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project2/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project2/some_node.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project3/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project3/some_node.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project4/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project4/very/very/deeply/nested/namespace/some_node.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project5/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project5/some_node.a.b.c.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project6/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project6/roads/contractor.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project6/roads/contractors.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project7/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project7/roads/contractor.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project7/roads/contractors.source.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project8/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project9/dj.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project9/roads/contractor.dimension.yaml +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test__internal.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_admin.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_client.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_generated_client.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_integration.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/test_models.py +0 -0
- {datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: datajunction
|
|
3
|
-
Version: 0.0.1a68.
|
|
3
|
+
Version: 0.0.1a68.dev1
|
|
4
4
|
Summary: DataJunction client library for connecting to a DataJunction server
|
|
5
5
|
Project-URL: repository, https://github.com/DataJunction/dj
|
|
6
6
|
Author-email: DataJunction Authors <yian.shang@gmail.com>
|
|
@@ -46,7 +46,7 @@ class DJBuilder(DJClient): # pylint: disable=too-many-public-methods
|
|
|
46
46
|
def create_namespace(
|
|
47
47
|
self,
|
|
48
48
|
namespace: str,
|
|
49
|
-
|
|
49
|
+
update_if_exists: bool = False,
|
|
50
50
|
) -> "Namespace":
|
|
51
51
|
"""
|
|
52
52
|
Create a namespace with a given name.
|
|
@@ -56,7 +56,7 @@ class DJBuilder(DJClient): # pylint: disable=too-many-public-methods
|
|
|
56
56
|
timeout=self._timeout,
|
|
57
57
|
)
|
|
58
58
|
json_response = response.json()
|
|
59
|
-
if response.status_code == 409 and not
|
|
59
|
+
if response.status_code == 409 and not update_if_exists:
|
|
60
60
|
raise DJNamespaceAlreadyExists(json_response["message"])
|
|
61
61
|
return Namespace(namespace=namespace, dj_client=self)
|
|
62
62
|
|
|
@@ -152,24 +152,24 @@ class DJBuilder(DJClient): # pylint: disable=too-many-public-methods
|
|
|
152
152
|
# This check is for the unit tests, which don't raise an exception
|
|
153
153
|
# for >= 400 status codes
|
|
154
154
|
if "name" in cube_dict:
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
data["metrics"] = cube_dict["cube_node_metrics"]
|
|
156
|
+
data["dimensions"] = cube_dict["cube_node_dimensions"]
|
|
157
157
|
except DJClientException as e: # pragma: no cover # pytest fixture doesn't raise
|
|
158
158
|
if re.search(r"node .* does not exist", str(e)):
|
|
159
159
|
existing_node_dict = None
|
|
160
160
|
else:
|
|
161
161
|
raise
|
|
162
162
|
|
|
163
|
-
#
|
|
163
|
+
# pylint: disable=fixme
|
|
164
|
+
# TODO: checking for "name" in existing_node_dict is a workaround
|
|
164
165
|
# to accommodate pytest mock client, which return a error message dict (no "name")
|
|
165
166
|
# instead of raising like the real client.
|
|
166
167
|
if existing_node_dict and "name" in existing_node_dict:
|
|
167
168
|
# update
|
|
168
169
|
if update_if_exists:
|
|
169
|
-
existing_node_dict.update(data)
|
|
170
170
|
new_node = self.make_node_of_type(
|
|
171
171
|
type_=type_,
|
|
172
|
-
data=
|
|
172
|
+
data=data,
|
|
173
173
|
)
|
|
174
174
|
new_node._update_tags()
|
|
175
175
|
new_node._update()
|
|
@@ -487,7 +487,7 @@ class DJBuilder(DJClient): # pylint: disable=too-many-public-methods
|
|
|
487
487
|
description: Optional[str],
|
|
488
488
|
tag_metadata: Dict,
|
|
489
489
|
tag_type: str,
|
|
490
|
-
|
|
490
|
+
update_if_exists: bool = False,
|
|
491
491
|
) -> Tag:
|
|
492
492
|
"""
|
|
493
493
|
Create a tag with a given name.
|
|
@@ -502,7 +502,7 @@ class DJBuilder(DJClient): # pylint: disable=too-many-public-methods
|
|
|
502
502
|
try:
|
|
503
503
|
self._create_tag(tag=new_tag)
|
|
504
504
|
except DJTagAlreadyExists as exc:
|
|
505
|
-
if not
|
|
505
|
+
if not update_if_exists:
|
|
506
506
|
raise exc
|
|
507
507
|
new_tag.refresh()
|
|
508
508
|
return new_tag
|
|
@@ -28,11 +28,7 @@ from rich.live import Live
|
|
|
28
28
|
from rich.table import Table
|
|
29
29
|
|
|
30
30
|
from datajunction import DJBuilder
|
|
31
|
-
from datajunction.exceptions import
|
|
32
|
-
DJClientException,
|
|
33
|
-
DJDeploymentFailure,
|
|
34
|
-
DJNamespaceAlreadyExists,
|
|
35
|
-
)
|
|
31
|
+
from datajunction.exceptions import DJClientException, DJDeploymentFailure
|
|
36
32
|
from datajunction.models import Column, NodeMode, NodeType
|
|
37
33
|
from datajunction.tags import Tag
|
|
38
34
|
|
|
@@ -606,7 +602,7 @@ class CompiledProject(Project):
|
|
|
606
602
|
*[
|
|
607
603
|
prefixed_name,
|
|
608
604
|
"[b][#3A4F6C]tag",
|
|
609
|
-
f"[green]Tag {prefixed_name} successfully created
|
|
605
|
+
f"[green]Tag {prefixed_name} successfully created",
|
|
610
606
|
]
|
|
611
607
|
)
|
|
612
608
|
except DJClientException as exc: # pragma: no cover
|
|
@@ -620,53 +616,30 @@ class CompiledProject(Project):
|
|
|
620
616
|
"""
|
|
621
617
|
Deploy namespaces
|
|
622
618
|
"""
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
namespaces_to_create = [prefix] + [
|
|
626
|
-
f"{prefix}.{ns}" for ns in list(self.namespaces)
|
|
627
|
-
]
|
|
628
|
-
for namespace in namespaces_to_create:
|
|
619
|
+
for namespace in list(self.namespaces) + [prefix]:
|
|
620
|
+
prefixed_name = f"{prefix}.{namespace}" if namespace != prefix else prefix
|
|
629
621
|
try:
|
|
630
|
-
print(f"Creating namespace {namespace}")
|
|
631
622
|
client.create_namespace(
|
|
632
|
-
namespace=
|
|
623
|
+
namespace=prefixed_name,
|
|
624
|
+
update_if_exists=True,
|
|
633
625
|
)
|
|
634
|
-
print(f"Created namespace {namespace}")
|
|
635
626
|
table.add_row(
|
|
636
627
|
*[
|
|
637
|
-
|
|
628
|
+
prefixed_name,
|
|
638
629
|
"[b][#3A4F6C]namespace",
|
|
639
|
-
f"[green]Namespace {
|
|
640
|
-
]
|
|
641
|
-
)
|
|
642
|
-
except DJNamespaceAlreadyExists:
|
|
643
|
-
table.add_row(
|
|
644
|
-
*[
|
|
645
|
-
namespace,
|
|
646
|
-
"namespace",
|
|
647
|
-
f"[i][yellow]Namespace {namespace} already exists",
|
|
630
|
+
f"[green]Namespace {prefixed_name} successfully created",
|
|
648
631
|
]
|
|
649
632
|
)
|
|
650
633
|
except DJClientException as exc:
|
|
651
|
-
#
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
else:
|
|
661
|
-
# pragma: no cover
|
|
662
|
-
table.add_row(*[namespace, "namespace", f"[i][red]{str(exc)}"])
|
|
663
|
-
self.errors.append(
|
|
664
|
-
{
|
|
665
|
-
"name": namespace,
|
|
666
|
-
"type": "namespace",
|
|
667
|
-
"error": str(exc),
|
|
668
|
-
},
|
|
669
|
-
)
|
|
634
|
+
# pragma: no cover
|
|
635
|
+
table.add_row(*[namespace, "namespace", f"[i][red]{str(exc)}"])
|
|
636
|
+
self.errors.append(
|
|
637
|
+
{
|
|
638
|
+
"name": prefixed_name,
|
|
639
|
+
"type": "namespace",
|
|
640
|
+
"error": str(exc),
|
|
641
|
+
},
|
|
642
|
+
)
|
|
670
643
|
return table
|
|
671
644
|
|
|
672
645
|
def _deploy_nodes(
|
|
@@ -722,7 +695,7 @@ class CompiledProject(Project):
|
|
|
722
695
|
*[
|
|
723
696
|
prefixed_name,
|
|
724
697
|
f"{style}{created_node.type}",
|
|
725
|
-
f"[green]Node {created_node.name} successfully created
|
|
698
|
+
f"[green]Node {created_node.name} successfully created",
|
|
726
699
|
]
|
|
727
700
|
)
|
|
728
701
|
except DJClientException as exc:
|
|
@@ -13,10 +13,6 @@ class DJNamespaceAlreadyExists(DJClientException):
|
|
|
13
13
|
Raised when a namespace to be created already exists.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
def __init__(self, ns_name: str, *args) -> None:
|
|
17
|
-
self.message = f"Namespace `{ns_name}` already exists."
|
|
18
|
-
super().__init__(self.message, *args)
|
|
19
|
-
|
|
20
16
|
|
|
21
17
|
class DJTagAlreadyExists(DJClientException):
|
|
22
18
|
"""
|
|
@@ -383,8 +383,9 @@ class Source(Node):
|
|
|
383
383
|
When `catalog` is a dictionary, parse out the catalog's
|
|
384
384
|
name, otherwise just return the string.
|
|
385
385
|
"""
|
|
386
|
-
if self.catalog
|
|
387
|
-
self.catalog
|
|
386
|
+
if self.catalog:
|
|
387
|
+
if isinstance(self.catalog, dict):
|
|
388
|
+
self.catalog = self.catalog["name"]
|
|
388
389
|
|
|
389
390
|
def _update(self) -> requests.Response:
|
|
390
391
|
"""
|
|
@@ -359,11 +359,11 @@ class TestDJBuilder: # pylint: disable=too-many-public-methods, protected-acces
|
|
|
359
359
|
with pytest.raises(DJClientException):
|
|
360
360
|
account_type_table = client.create_source(
|
|
361
361
|
name="default.account_type_table",
|
|
362
|
-
description="
|
|
362
|
+
description="New description",
|
|
363
363
|
update_if_exists=False,
|
|
364
364
|
)
|
|
365
365
|
|
|
366
|
-
# ... should work since update_if_exists is set to True
|
|
366
|
+
# ... should work since update_if_exists is set to True by default
|
|
367
367
|
account_type_table = client.create_source(
|
|
368
368
|
name="default.account_type_table",
|
|
369
369
|
description="new description",
|
|
@@ -657,17 +657,13 @@ class TestDJBuilder: # pylint: disable=too-many-public-methods, protected-acces
|
|
|
657
657
|
)
|
|
658
658
|
assert cube_one.name == "default.cube_one"
|
|
659
659
|
assert cube_one.status == "valid"
|
|
660
|
-
assert cube_one.metrics == ["default.number_of_account_types"]
|
|
661
660
|
assert [tag["name"] for tag in cube_one.tags] == ["foo"]
|
|
662
661
|
|
|
663
662
|
# Test updating cube node
|
|
664
663
|
cube_one = client.create_cube(
|
|
665
664
|
name="default.cube_one",
|
|
666
665
|
description="Ice cubes!",
|
|
667
|
-
metrics=[
|
|
668
|
-
"default.number_of_account_types",
|
|
669
|
-
"default.number_of_account_types2",
|
|
670
|
-
],
|
|
666
|
+
metrics=["default.number_of_account_types"],
|
|
671
667
|
dimensions=["default.account_type.account_type_name"],
|
|
672
668
|
mode=NodeMode.PUBLISHED,
|
|
673
669
|
tags=[],
|
|
@@ -675,10 +671,6 @@ class TestDJBuilder: # pylint: disable=too-many-public-methods, protected-acces
|
|
|
675
671
|
)
|
|
676
672
|
assert cube_one.name == "default.cube_one"
|
|
677
673
|
assert cube_one.description == "Ice cubes!"
|
|
678
|
-
assert cube_one.metrics == [
|
|
679
|
-
"default.number_of_account_types",
|
|
680
|
-
"default.number_of_account_types2",
|
|
681
|
-
]
|
|
682
674
|
assert [tag["name"] for tag in cube_one.tags] == []
|
|
683
675
|
|
|
684
676
|
def test_link_unlink_dimension(self, client): # pylint: disable=unused-argument
|
|
@@ -1043,15 +1035,15 @@ class TestDJBuilder: # pylint: disable=too-many-public-methods, protected-acces
|
|
|
1043
1035
|
tag_type="test",
|
|
1044
1036
|
tag_metadata={"foo": "bar"},
|
|
1045
1037
|
)
|
|
1046
|
-
#
|
|
1038
|
+
# update the same tag
|
|
1047
1039
|
client.create_tag(
|
|
1048
1040
|
name="foo.two",
|
|
1049
1041
|
description="Foo Bar",
|
|
1050
1042
|
tag_type="test",
|
|
1051
1043
|
tag_metadata={"foo": "bar"},
|
|
1052
|
-
|
|
1044
|
+
update_if_exists=True,
|
|
1053
1045
|
)
|
|
1054
|
-
#
|
|
1046
|
+
# create a new tag with the same name
|
|
1055
1047
|
with pytest.raises(DJTagAlreadyExists) as exc_info:
|
|
1056
1048
|
client.create_tag(
|
|
1057
1049
|
name="foo.two",
|
|
@@ -4,7 +4,7 @@ Test YAML project related things
|
|
|
4
4
|
# pylint: disable=unused-argument
|
|
5
5
|
import os
|
|
6
6
|
from typing import Callable
|
|
7
|
-
from unittest.mock import MagicMock
|
|
7
|
+
from unittest.mock import MagicMock
|
|
8
8
|
|
|
9
9
|
import pytest
|
|
10
10
|
|
|
@@ -14,50 +14,25 @@ from datajunction.exceptions import DJClientException, DJDeploymentFailure
|
|
|
14
14
|
from datajunction.models import NodeMode
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def
|
|
17
|
+
def test_compiled_project__deploy_namespaces():
|
|
18
18
|
"""
|
|
19
19
|
Test deploying a namespace.
|
|
20
20
|
"""
|
|
21
|
-
mock_table = MagicMock()
|
|
22
21
|
cp = CompiledProject(
|
|
23
22
|
name="foo",
|
|
24
23
|
prefix="foo.fix",
|
|
24
|
+
mode=NodeMode.DRAFT,
|
|
25
25
|
root_path="/foo",
|
|
26
|
-
namespaces=["foo", "bar"],
|
|
27
26
|
)
|
|
28
|
-
# namespace creation random error
|
|
29
27
|
builder_client = MagicMock(
|
|
30
28
|
create_namespace=MagicMock(side_effect=DJClientException("foo error")),
|
|
31
29
|
)
|
|
32
30
|
cp._deploy_namespaces( # pylint: disable=protected-access
|
|
33
31
|
prefix="foo",
|
|
34
|
-
table=
|
|
32
|
+
table=MagicMock(),
|
|
35
33
|
client=builder_client,
|
|
36
34
|
)
|
|
37
35
|
assert cp.errors[0]["error"] == "foo error"
|
|
38
|
-
# namespace already exists, not an error
|
|
39
|
-
cp = CompiledProject(
|
|
40
|
-
name="foo",
|
|
41
|
-
prefix="foo.fix",
|
|
42
|
-
root_path="/foo",
|
|
43
|
-
namespaces=["foo", "bar"],
|
|
44
|
-
)
|
|
45
|
-
builder_client = MagicMock(
|
|
46
|
-
create_namespace=MagicMock(
|
|
47
|
-
side_effect=DJClientException("foo bar already exists"),
|
|
48
|
-
),
|
|
49
|
-
)
|
|
50
|
-
cp._deploy_namespaces( # pylint: disable=protected-access
|
|
51
|
-
prefix="foo",
|
|
52
|
-
table=mock_table,
|
|
53
|
-
client=builder_client,
|
|
54
|
-
)
|
|
55
|
-
assert cp.errors == []
|
|
56
|
-
assert mock_table.add_row.call_args == call(
|
|
57
|
-
"foo.bar",
|
|
58
|
-
"namespace",
|
|
59
|
-
"[i][yellow]Namespace foo.bar already exists",
|
|
60
|
-
)
|
|
61
36
|
|
|
62
37
|
|
|
63
38
|
def test_compiled_project__cleanup_namespace():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project11/date.source.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datajunction-0.0.1a68.dev0 → datajunction-0.0.1a68.dev1}/tests/examples/project3/some_node.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|