Skip to content

Commit

Permalink
remove resource_type.value
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurpulkit committed May 31, 2024
1 parent 4145be8 commit 9245187
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 68 deletions.
134 changes: 73 additions & 61 deletions src/datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_node(self, node: ManifestNode) -> AltimateManifestNode:
language,
contract,
) = ([], [], None, None, None, None, None, "", "", None)
if node.resource_type.value != SEED:
if node.resource_type != SEED:
sources = node.sources
metrics = node.metrics
depends_on_nodes = node.depends_on.nodes if node.depends_on else None
Expand All @@ -75,7 +75,7 @@ def _get_node(self, node: ManifestNode) -> AltimateManifestNode:
database=node.database,
schema_name=node.schema_,
name=node.name,
resource_type=AltimateResourceType(node.resource_type.value),
resource_type=AltimateResourceType(node.resource_type),
package_name=node.package_name,
path=node.path,
description=node.description,
Expand Down Expand Up @@ -119,7 +119,7 @@ def _get_node(self, node: ManifestNode) -> AltimateManifestNode:
def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode:
return AltimateManifestSourceNode(
database=source.database,
resource_type=AltimateResourceType(source.resource_type.value),
resource_type=AltimateResourceType(source.resource_type),
schema_name=source.schema_,
name=source.name,
package_name=source.package_name,
Expand Down Expand Up @@ -160,7 +160,7 @@ def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode:
def _get_macro(self, macro: MacroNode) -> AltimateManifestMacroNode:
return AltimateManifestMacroNode(
name=macro.name,
resource_type=AltimateResourceType(macro.resource_type.value),
resource_type=AltimateResourceType(macro.resource_type),
package_name=macro.package_name,
path=macro.path,
original_file_path=macro.original_file_path,
Expand All @@ -185,7 +185,7 @@ def _get_macro(self, macro: MacroNode) -> AltimateManifestMacroNode:
def _get_exposure(self, exposure: ExposureNode) -> AltimateManifestExposureNode:
return AltimateManifestExposureNode(
name=exposure.name,
resource_type=AltimateResourceType(exposure.resource_type.value),
resource_type=AltimateResourceType(exposure.resource_type),
package_name=exposure.package_name,
path=exposure.path,
original_file_path=exposure.original_file_path,
Expand All @@ -201,12 +201,14 @@ def _get_exposure(self, exposure: ExposureNode) -> AltimateManifestExposureNode:
config=AltimateSourceConfig(**exposure.config.dict()) if exposure.config else None,
unrendered_config=exposure.unrendered_config,
url=exposure.url,
depends_on=AltimateDependsOn(
nodes=exposure.depends_on.nodes,
macros=exposure.depends_on.macros,
)
if exposure.depends_on
else None,
depends_on=(
AltimateDependsOn(
nodes=exposure.depends_on.nodes,
macros=exposure.depends_on.macros,
)
if exposure.depends_on
else None
),
refs=[AltimateRefArgs(**ref.dict()) for ref in exposure.refs] if exposure.refs else None,
sources=exposure.sources,
metrics=exposure.metrics,
Expand All @@ -226,35 +228,39 @@ def _get_tests(self, test: TestNode) -> AltimateManifestTestNode:
test_metadata=test_metadata,
test_type=test_type,
name=test.name,
resource_type=AltimateResourceType(test.resource_type.value),
resource_type=AltimateResourceType(test.resource_type),
package_name=test.package_name,
path=test.path,
original_file_path=test.original_file_path,
unique_id=test.unique_id,
fqn=test.fqn,
alias=test.alias,
checksum=AltimateFileHash(
name=test.checksum.name,
checksum=test.checksum.checksum,
)
if test.checksum
else None,
checksum=(
AltimateFileHash(
name=test.checksum.name,
checksum=test.checksum.checksum,
)
if test.checksum
else None
),
config=AltimateTestConfig(**test.config.dict()) if test.config else None,
description=test.description,
tags=test.tags,
columns={
name: AltimateManifestColumnInfo(
name=column.name,
description=column.description,
meta=column.meta,
data_type=column.data_type,
quote=column.quote,
tags=column.tags,
)
for name, column in test.columns.items()
}
if test.columns
else None,
columns=(
{
name: AltimateManifestColumnInfo(
name=column.name,
description=column.description,
meta=column.meta,
data_type=column.data_type,
quote=column.quote,
tags=column.tags,
)
for name, column in test.columns.items()
}
if test.columns
else None
),
meta=test.meta,
relation_name=test.relation_name,
group=test.group,
Expand All @@ -263,12 +269,14 @@ def _get_tests(self, test: TestNode) -> AltimateManifestTestNode:
refs=[AltimateRefArgs(**ref.dict()) for ref in test.refs] if test.refs else None,
sources=test.sources,
metrics=test.metrics,
depends_on=AltimateDependsOn(
nodes=test.depends_on.nodes,
macros=test.depends_on.macros,
)
if test.depends_on
else None,
depends_on=(
AltimateDependsOn(
nodes=test.depends_on.nodes,
macros=test.depends_on.macros,
)
if test.depends_on
else None
),
compiled_path=test.compiled_path,
compiled=test.compiled,
compiled_code=test.compiled_code,
Expand All @@ -279,35 +287,39 @@ def _get_seed(self, seed: SeedNodeMap) -> AltimateSeedNode:
database=seed.database,
schema_name=seed.schema_,
name=seed.name,
resource_type=AltimateResourceType(seed.resource_type.value),
resource_type=AltimateResourceType(seed.resource_type),
package_name=seed.package_name,
path=seed.path,
original_file_path=seed.original_file_path,
unique_id=seed.unique_id,
fqn=seed.fqn,
alias=seed.alias,
checksum=AltimateFileHash(
name=seed.checksum.name,
checksum=seed.checksum.checksum,
)
if seed.checksum
else None,
checksum=(
AltimateFileHash(
name=seed.checksum.name,
checksum=seed.checksum.checksum,
)
if seed.checksum
else None
),
config=AltimateSeedConfig(**seed.config.dict()) if seed.config else None,
description=seed.description,
tags=seed.tags,
columns={
name: AltimateManifestColumnInfo(
name=column.name,
description=column.description,
meta=column.meta,
data_type=column.data_type,
quote=column.quote,
tags=column.tags,
)
for name, column in seed.columns.items()
}
if seed.columns
else None,
columns=(
{
name: AltimateManifestColumnInfo(
name=column.name,
description=column.description,
meta=column.meta,
data_type=column.data_type,
quote=column.quote,
tags=column.tags,
)
for name, column in seed.columns.items()
}
if seed.columns
else None
),
meta=seed.meta,
group=seed.group,
docs=seed.docs.dict() if seed.docs else None,
Expand All @@ -325,7 +337,7 @@ def get_nodes(
nodes = {}
for node in self.manifest.nodes.values():
if (
node.resource_type.value
node.resource_type
in [
AltimateResourceType.seed.value,
AltimateResourceType.test.value,
Expand All @@ -348,7 +360,7 @@ def get_sources(self) -> Dict[str, AltimateManifestSourceNode]:
def get_macros(self) -> Dict[str, AltimateManifestMacroNode]:
macros = {}
for macro in self.manifest.macros.values():
if macro.resource_type.value == AltimateResourceType.macro.value and macro.package_name == self.get_package():
if macro.resource_type == AltimateResourceType.macro.value and macro.package_name == self.get_package():
macros[macro.unique_id] = self._get_macro(macro)
return macros

Expand All @@ -369,15 +381,15 @@ def get_tests(self, type=None) -> Dict[str, AltimateManifestTestNode]:

for node in self.manifest.nodes.values():
# Check if the node is a test and of the correct type
if node.resource_type.value == AltimateResourceType.test.value:
if node.resource_type == AltimateResourceType.test.value:
if any(isinstance(node, t) for t in types):
tests[node.unique_id] = self._get_tests(node)
return tests

def get_seeds(self) -> Dict[str, AltimateSeedNode]:
seeds = {}
for seed in self.manifest.nodes.values():
if seed.resource_type.value == AltimateResourceType.seed.value:
if seed.resource_type == AltimateResourceType.seed.value:
seeds[seed.unique_id] = self._get_seed(seed)
return seeds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _get_node(self, node: ManifestNode) -> AltimateManifestNode:
def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode:
return AltimateManifestSourceNode(
database=source.database,
resource_type=AltimateResourceType(source.resource_type.value),
resource_type=AltimateResourceType(source.resource_type),
schema_name=source.schema_,
name=source.name,
package_name=source.package_name,
Expand Down Expand Up @@ -160,7 +160,7 @@ def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode:
def _get_macro(self, macro: MacroNode) -> AltimateManifestMacroNode:
return AltimateManifestMacroNode(
name=macro.name,
resource_type=AltimateResourceType(macro.resource_type.value),
resource_type=AltimateResourceType(macro.resource_type),
package_name=macro.package_name,
path=macro.path,
original_file_path=macro.original_file_path,
Expand All @@ -185,7 +185,7 @@ def _get_macro(self, macro: MacroNode) -> AltimateManifestMacroNode:
def _get_exposure(self, exposure: ExposureNode) -> AltimateManifestExposureNode:
return AltimateManifestExposureNode(
name=exposure.name,
resource_type=AltimateResourceType(exposure.resource_type.value),
resource_type=AltimateResourceType(exposure.resource_type),
package_name=exposure.package_name,
path=exposure.path,
original_file_path=exposure.original_file_path,
Expand Down Expand Up @@ -228,7 +228,7 @@ def _get_tests(self, test: TestNode) -> AltimateManifestTestNode:
test_metadata=test_metadata,
test_type=test_type,
name=test.name,
resource_type=AltimateResourceType(test.resource_type.value),
resource_type=AltimateResourceType(test.resource_type),
package_name=test.package_name,
path=test.path,
original_file_path=test.original_file_path,
Expand Down Expand Up @@ -287,7 +287,7 @@ def _get_seed(self, seed: SeedNodeMap) -> AltimateSeedNode:
database=seed.database,
schema_name=seed.schema_,
name=seed.name,
resource_type=AltimateResourceType(seed.resource_type.value),
resource_type=AltimateResourceType(seed.resource_type),
package_name=seed.package_name,
path=seed.path,
original_file_path=seed.original_file_path,
Expand Down Expand Up @@ -360,7 +360,7 @@ def get_sources(self) -> Dict[str, AltimateManifestSourceNode]:
def get_macros(self) -> Dict[str, AltimateManifestMacroNode]:
macros = {}
for macro in self.manifest.macros.values():
if macro.resource_type.value == AltimateResourceType.macro.value and macro.package_name == self.get_package():
if macro.resource_type == AltimateResourceType.macro.value and macro.package_name == self.get_package():
macros[macro.unique_id] = self._get_macro(macro)
return macros

Expand Down Expand Up @@ -389,7 +389,7 @@ def get_tests(self, type=None) -> Dict[str, AltimateManifestTestNode]:
def get_seeds(self) -> Dict[str, AltimateSeedNode]:
seeds = {}
for seed in self.manifest.nodes.values():
if seed.resource_type.value == AltimateResourceType.seed.value:
if seed.resource_type == AltimateResourceType.seed.value:
seeds[seed.unique_id] = self._get_seed(seed)
return seeds

Expand Down

0 comments on commit 9245187

Please sign in to comment.