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

Dedicated folder for looker explores views #944

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion metaphor/looker/lookml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
# lkml parser's debug log can be very noisy
logging.getLogger("lkml.parser").setLevel(logging.WARNING)

VIEW_EXPLORE_FOLDER = "LookML models"
elic-eon marked this conversation as resolved.
Show resolved Hide resolved


@dataclass
class Explore:
Expand Down Expand Up @@ -200,7 +202,7 @@ def fullname(model: str, name: str) -> str:

def _get_model_asset_structure(model: str, name: str) -> AssetStructure:
return AssetStructure(
directories=[model],
directories=[VIEW_EXPLORE_FOLDER, model],
name=name,
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.14.72"
version = "0.14.73"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down
83 changes: 44 additions & 39 deletions tests/looker/test_lookml_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from metaphor.common.entity_id import EntityId
from metaphor.looker.config import LookerConnectionConfig
from metaphor.looker.lookml_parser import Explore, Model, parse_project
from metaphor.looker.lookml_parser import (
VIEW_EXPLORE_FOLDER,
Explore,
Model,
parse_project,
)
from metaphor.models.metadata_change_event import (
AssetStructure,
DataPlatform,
Expand Down Expand Up @@ -91,7 +96,7 @@ def test_basic(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id)]),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="view1",
),
),
Expand All @@ -107,7 +112,7 @@ def test_basic(test_root_dir):
url="http://foo/files/model1.model.lkml",
),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="explore1",
),
entity_upstream=EntityUpstream(
Expand Down Expand Up @@ -191,7 +196,7 @@ def test_join(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id1)]),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="view1",
),
),
Expand All @@ -210,7 +215,7 @@ def test_join(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id2)]),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="view2",
),
),
Expand Down Expand Up @@ -239,7 +244,7 @@ def test_join(test_root_dir):
label="label",
),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="explore1",
),
entity_upstream=EntityUpstream(
Expand Down Expand Up @@ -299,7 +304,7 @@ def test_explore_in_view(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id)]),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="view1",
),
),
Expand All @@ -314,7 +319,7 @@ def test_explore_in_view(test_root_dir):
label="label",
),
structure=AssetStructure(
directories=["model1"],
directories=[VIEW_EXPLORE_FOLDER, "model1"],
name="explore1",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id)]),
Expand Down Expand Up @@ -361,7 +366,7 @@ def test_derived_table(test_root_dir):
name="model.view1", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
looker_view=LookerView(
Expand All @@ -379,7 +384,7 @@ def test_derived_table(test_root_dir):
name="model.view2", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view2",
),
looker_view=LookerView(
Expand All @@ -397,7 +402,7 @@ def test_derived_table(test_root_dir):
name="model.view3", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view3",
),
looker_view=LookerView(),
Expand All @@ -412,7 +417,7 @@ def test_derived_table(test_root_dir):
base_view=str(virtual_view_id1),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore1",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id1)]),
Expand All @@ -427,7 +432,7 @@ def test_derived_table(test_root_dir):
base_view=str(virtual_view_id2),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore2",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id2)]),
Expand All @@ -442,7 +447,7 @@ def test_derived_table(test_root_dir):
base_view=str(virtual_view_id3),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore3",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id3)]),
Expand Down Expand Up @@ -489,7 +494,7 @@ def test_sql_table_name(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id1)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
),
Expand All @@ -502,7 +507,7 @@ def test_sql_table_name(test_root_dir):
base_view=str(virtual_view_id1),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore1",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id1)]),
Expand Down Expand Up @@ -542,7 +547,7 @@ def test_include_relative_to_model(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id1)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
),
Expand All @@ -555,7 +560,7 @@ def test_include_relative_to_model(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id2)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view2",
),
),
Expand Down Expand Up @@ -624,7 +629,7 @@ def test_complex_includes(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id1)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
),
Expand All @@ -637,7 +642,7 @@ def test_complex_includes(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id2)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view2",
),
),
Expand All @@ -650,7 +655,7 @@ def test_complex_includes(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id3)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view3",
),
),
Expand All @@ -663,7 +668,7 @@ def test_complex_includes(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_id4)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view4",
),
),
Expand All @@ -676,7 +681,7 @@ def test_complex_includes(test_root_dir):
base_view=str(virtual_view_id1),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore1",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view_id1)]),
Expand Down Expand Up @@ -733,7 +738,7 @@ def test_view_extension(test_root_dir):
name="model.view1", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
looker_view=LookerView(
Expand All @@ -746,7 +751,7 @@ def test_view_extension(test_root_dir):
name="model.view2", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view2",
),
looker_view=LookerView(
Expand All @@ -763,7 +768,7 @@ def test_view_extension(test_root_dir):
name="model.view3", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view3",
),
looker_view=LookerView(
Expand All @@ -784,7 +789,7 @@ def test_view_extension(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_table3)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view4",
),
),
Expand All @@ -793,7 +798,7 @@ def test_view_extension(test_root_dir):
name="model.base_view2", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="base_view2",
),
looker_view=LookerView(
Expand All @@ -810,7 +815,7 @@ def test_view_extension(test_root_dir):
name="model.base_view3", type=VirtualViewType.LOOKER_VIEW
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="base_view3",
),
looker_view=LookerView(
Expand All @@ -823,7 +828,7 @@ def test_view_extension(test_root_dir):
name="model.explore1", type=VirtualViewType.LOOKER_EXPLORE
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore1",
),
looker_explore=LookerExplore(
Expand Down Expand Up @@ -904,7 +909,7 @@ def test_explore_extension(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_view1)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view1",
),
),
Expand All @@ -917,7 +922,7 @@ def test_explore_extension(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_view2)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view2",
),
),
Expand All @@ -930,7 +935,7 @@ def test_explore_extension(test_root_dir):
),
entity_upstream=EntityUpstream(source_entities=[str(dataset_view3)]),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view3",
),
),
Expand All @@ -943,7 +948,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view1),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore1",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view1)]),
Expand All @@ -958,7 +963,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view2),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore2",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view2)]),
Expand All @@ -973,7 +978,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view1),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore3",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view1)]),
Expand All @@ -988,7 +993,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view3),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="explore4",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view3)]),
Expand All @@ -1003,7 +1008,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view2),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="base_explore2",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view2)]),
Expand All @@ -1018,7 +1023,7 @@ def test_explore_extension(test_root_dir):
base_view=str(virtual_view3),
),
structure=AssetStructure(
directories=["model"],
directories=[VIEW_EXPLORE_FOLDER, "model"],
name="view3",
),
entity_upstream=EntityUpstream(source_entities=[str(virtual_view3)]),
Expand Down
Loading