Skip to content

Commit 8eacaae

Browse files
authored
Refactor: Simplify interfaces, expose more functions (#33)
1 parent d4ca6f9 commit 8eacaae

11 files changed

+342
-285
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ releases are available on [conda-forge](https://anaconda.org/conda-forge/dags).
66

77
## 0.3.0
88

9+
- :gh:`33` Simplify interfaces, expose more functions (:ghuser:`hmgaudecker`)
910
- :gh:`29` Improve namespace handling, allow for relative paths (:ghuser:`hmgaudecker`)
1011
- :gh:`31` Refactor `dag_tree` (:ghuser:`hmgaudecker`)
1112
- :gh:`28` Expose relevant functions for working with function trees (:ghuser:`hmgaudecker`)

pixi.lock

+94-95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ requires-python = ">=3.10"
55
dynamic = ["version"]
66
dependencies = [
77
"networkx",
8-
"types-networkx",
98
"flatten-dict",
109
]
1110
classifiers = [
@@ -89,10 +88,11 @@ pre-commit = "*"
8988
pytest = "*"
9089
pytest-cov = "*"
9190
pytest-xdist = "*"
92-
mypy = "==1.15.0"
91+
mypy = "~=1.15"
9392

9493
[tool.pixi.pypi-dependencies]
9594
dags = {path = ".", editable = true}
95+
types-networkx = "*"
9696
pdbp = "*"
9797

9898
# Features and Tasks
@@ -106,16 +106,16 @@ tests-with-cov = "pytest tests --cov-report=xml --cov=./"
106106
# --------------------------------------------------------------------------------------
107107

108108
[tool.pixi.feature.py310.dependencies]
109-
python = "~=3.10.0"
109+
python = "~=3.10"
110110

111111
[tool.pixi.feature.py311.dependencies]
112-
python = "~=3.11.0"
112+
python = "~=3.11"
113113

114114
[tool.pixi.feature.py312.dependencies]
115-
python = "~=3.12.0"
115+
python = "~=3.12"
116116

117117
[tool.pixi.feature.py313.dependencies]
118-
python = "~=3.13.0"
118+
python = "~=3.13"
119119

120120
# Environments
121121
# --------------------------------------------------------------------------------------

src/dags/dag.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _create_combined_function_from_dag(
169169
targets,
170170
)
171171

172-
_arglist = _create_arguments_of_concatenated_function(_functions, dag)
172+
_arglist = create_arguments_of_concatenated_function(_functions, dag)
173173
_exec_info = _create_execution_info(_functions, dag)
174174
_concatenated = _create_concatenated_function(
175175
_exec_info,
@@ -333,12 +333,12 @@ def _create_complete_dag(
333333
334334
"""
335335
functions_arguments_dict = {
336-
name: _get_free_arguments(function) for name, function in functions.items()
336+
name: get_free_arguments(function) for name, function in functions.items()
337337
}
338338
return nx.DiGraph(functions_arguments_dict).reverse() # type: ignore[arg-type]
339339

340340

341-
def _get_free_arguments(
341+
def get_free_arguments(
342342
func: GenericCallable,
343343
) -> list[str]:
344344
arguments = list(inspect.signature(func).parameters)
@@ -379,7 +379,7 @@ def _limit_dag_to_targets_and_their_ancestors(
379379
return dag
380380

381381

382-
def _create_arguments_of_concatenated_function(
382+
def create_arguments_of_concatenated_function(
383383
functions: dict[str, GenericCallable],
384384
dag: nx.DiGraph[str],
385385
) -> list[str]:
@@ -418,7 +418,7 @@ def _create_execution_info(
418418
out = {}
419419
for node in nx.topological_sort(dag):
420420
if node in functions:
421-
arguments = _get_free_arguments(functions[node])
421+
arguments = get_free_arguments(functions[node])
422422
out[node] = FunctionExecutionInfo(func=functions[node], arguments=arguments)
423423
return out
424424

src/dags/tree/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
concatenate_functions_tree,
55
create_dag_tree,
66
create_input_structure_tree,
7+
functions_without_tree_logic,
8+
one_function_without_tree_logic,
79
)
810
from dags.tree.tree_utils import (
911
QUAL_NAME_DELIMITER,
@@ -18,6 +20,7 @@
1820
)
1921
from dags.tree.validation import (
2022
fail_if_path_elements_have_trailing_undersores,
23+
fail_if_paths_are_invalid,
2124
fail_if_top_level_elements_repeated_in_paths,
2225
fail_if_top_level_elements_repeated_in_single_path,
2326
)
@@ -27,7 +30,10 @@
2730
"create_input_structure_tree",
2831
"create_dag_tree",
2932
"concatenate_functions_tree",
33+
"functions_without_tree_logic",
34+
"one_function_without_tree_logic",
3035
# Validation functions
36+
"fail_if_paths_are_invalid",
3137
"fail_if_path_elements_have_trailing_undersores",
3238
"fail_if_top_level_elements_repeated_in_paths",
3339
"fail_if_top_level_elements_repeated_in_single_path",

0 commit comments

Comments
 (0)