Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Marigold committed Jan 3, 2025
1 parent b831d3c commit 1776c48
Show file tree
Hide file tree
Showing 3 changed files with 351 additions and 14 deletions.
12 changes: 9 additions & 3 deletions etl/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ def get_dependency_step_name(
short_name=short_name,
is_private=is_private,
)
matches = [dependency for dependency in self.dependencies if bool(re.match(pattern, dependency))]
deps = self.dependencies
matches = _match_dependencies(pattern, deps)

# If no step was found and is_private was not specified, try again assuming step is private.
if (len(matches) == 0) and (is_private is None):
Expand All @@ -700,7 +701,7 @@ def get_dependency_step_name(
short_name=short_name,
is_private=True,
)
matches = [dependency for dependency in self.dependencies if bool(re.match(pattern, dependency))]
matches = _match_dependencies(pattern, self.dependencies)

# If not step was found and channel is "grapher", try again assuming this is a grapher://grapher step.
if (len(matches) == 0) and (channel == "grapher"):
Expand All @@ -712,7 +713,7 @@ def get_dependency_step_name(
short_name=short_name,
is_private=is_private,
)
matches = [dependency for dependency in self.dependencies if bool(re.match(pattern, dependency))]
matches = _match_dependencies(pattern, self.dependencies)

if len(matches) == 0:
raise NoMatchingStepsAmongDependencies(step_name=self.step_name)
Expand Down Expand Up @@ -798,6 +799,11 @@ def load_mdim_config(self, filename: Optional[str] = None, path: Optional[str |
return config


def _match_dependencies(pattern: str, dependencies: List[str]) -> List[str]:
regex = re.compile(pattern)
return [dependency for dependency in dependencies if regex.match(dependency)]


def print_tables_metadata_template(tables: List[Table], fields: Optional[List[str]] = None) -> None:
# This function is meant to be used when creating code in an interactive window (or a notebook).
# It prints a template for the metadata of the tables in the list.
Expand Down
Loading

0 comments on commit 1776c48

Please sign in to comment.