Skip to content

Commit

Permalink
Adds more comments for recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
skrawcz committed Dec 4, 2023
1 parent 7a8439e commit 17777a4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions hamilton/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ def _get_legend(node_types: Set[str]):
concentrate="true",
),
)
# we need to update the graph_attr dict instead of overwriting it
# so that means we need to handle nested dicts, e.g. graph_attr.
for g_key, g_value in graphviz_kwargs.items():
if isinstance(g_value, dict):
digraph_attr[g_key].update(**g_value)
Expand Down
16 changes: 16 additions & 0 deletions hamilton/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

def get_file_metadata(path: str) -> Dict[str, Any]:
"""Gives metadata from loading a file.
Note: we reserve the right to change this schema. So if you're using this come
chat so that we can make sure we don't break your code.
This includes:
- the file size
- the file path
Expand All @@ -27,6 +31,10 @@ def get_file_metadata(path: str) -> Dict[str, Any]:

def get_dataframe_metadata(df: pd.DataFrame) -> Dict[str, Any]:
"""Gives metadata from loading a dataframe.
Note: we reserve the right to change this schema. So if you're using this come
chat so that we can make sure we don't break your code.
This includes:
- the number of rows
- the number of columns
Expand All @@ -43,6 +51,10 @@ def get_dataframe_metadata(df: pd.DataFrame) -> Dict[str, Any]:

def get_file_and_dataframe_metadata(path: str, df: pd.DataFrame) -> Dict[str, Any]:
"""Gives metadata from loading a file and a dataframe.
Note: we reserve the right to change this schema. So if you're using this come
chat so that we can make sure we don't break your code.
This includes:
file_meta:
- the file size
Expand All @@ -60,6 +72,10 @@ def get_file_and_dataframe_metadata(path: str, df: pd.DataFrame) -> Dict[str, An

def get_sql_metadata(query_or_table: str, results: Union[int, pd.DataFrame]) -> Dict[str, Any]:
"""Gives metadata from reading a SQL table or writing to SQL db.
Note: we reserve the right to change this schema. So if you're using this come
chat so that we can make sure we don't break your code.
This includes:
- the number of rows read, added, or to add.
- the sql query (e.g., "SELECT foo FROM bar")
Expand Down
11 changes: 7 additions & 4 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import pandas as pd
import pytest

import hamilton.graph_utils
import hamilton.htypes
import tests.resources.bad_functions
import tests.resources.compatible_input_types
import tests.resources.config_modifier
Expand All @@ -24,6 +21,9 @@
import tests.resources.parametrized_nodes
import tests.resources.test_default_args
import tests.resources.typing_vs_not_typing

import hamilton.graph_utils
import hamilton.htypes
from hamilton import ad_hoc_utils, base, graph, node
from hamilton.execution import graph_functions
from hamilton.node import NodeType
Expand Down Expand Up @@ -237,7 +237,10 @@ def test_add_dependency_input_nodes_compatible_types():


def test_add_dependency_input_nodes_compatible_types_order_check():
"""Tests that if functions request an input that we correctly accept compatible types independent of order."""
"""Tests that if functions request an input that we correctly accept compatible types independent of order.
This just reorders test_add_dependency_input_nodes_compatible_types to ensure the outcome does not change.
"""
b_sig = inspect.signature(tests.resources.compatible_input_types.b)
c_sig = inspect.signature(tests.resources.compatible_input_types.c)
d_sig = inspect.signature(tests.resources.compatible_input_types.d)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hamilton_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import pandas as pd
import pytest

import tests.resources.cyclic_functions
import tests.resources.dummy_functions
import tests.resources.dynamic_parallelism.parallel_linear_basic
import tests.resources.tagging
import tests.resources.test_default_args
import tests.resources.very_simple_dag

from hamilton import base, node
from hamilton.driver import (
Builder,
Expand Down

0 comments on commit 17777a4

Please sign in to comment.