Skip to content

Commit

Permalink
Fixes inconsistency between pre-commit and git hook
Browse files Browse the repository at this point in the history
So the git commit hook for isort was running with
different configuration from the pre-commit CI run.

This (a) fixes files to be consistent with (b) the configuration
now provided -- e.g. what is first party, and what is local.

This should hopefully now prevent any conflicts from reoccurring.
  • Loading branch information
skrawcz committed Dec 4, 2023
1 parent 17777a4 commit 67278b9
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
rev: '5.12.0'
hooks:
- id: isort
args: ["--profile", "black", --line-length=100]
args: ["--profile", "black", "--line-length=100", "--known-local-folder", "tests", "-p", "hamilton"]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions contrib/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ignore =

[isort]
known_first_party=hamilton
known_local_folder=tests
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ignore =

[isort]
known_first_party=hamilton
known_local_folder=tests
17 changes: 9 additions & 8 deletions tests/execution/test_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@

import numpy as np
import pytest
from tests.resources.dynamic_parallelism import (
inputs_in_collect,
no_parallel,
parallel_collect_multiple_arguments,
parallel_complex,
parallel_delayed,
parallel_linear_basic,
)

import hamilton.ad_hoc_utils
from hamilton import base, driver
Expand All @@ -30,6 +22,15 @@
)
from hamilton.htypes import Collect, Parallelizable

from tests.resources.dynamic_parallelism import (
inputs_in_collect,
no_parallel,
parallel_collect_multiple_arguments,
parallel_complex,
parallel_delayed,
parallel_linear_basic,
)

ADAPTER = base.DefaultAdapter()


Expand Down
4 changes: 2 additions & 2 deletions tests/execution/test_node_grouping.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from tests.resources.dynamic_parallelism import no_parallel, parallel_complex, parallel_linear_basic

from hamilton import ad_hoc_utils, base, graph, node
from hamilton.execution import grouping
from hamilton.execution.grouping import (
Expand All @@ -12,6 +10,8 @@
from hamilton.graph import FunctionGraph
from hamilton.node import NodeType

from tests.resources.dynamic_parallelism import no_parallel, parallel_complex, parallel_linear_basic


def test_group_individually():
fn_graph = FunctionGraph.from_modules(no_parallel, config={})
Expand Down
3 changes: 2 additions & 1 deletion tests/function_modifiers/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pandas as pd
import pytest
import tests.resources.pipe

import hamilton.function_modifiers
from hamilton import base, driver, function_modifiers, models, node
Expand All @@ -12,6 +11,8 @@
from hamilton.function_modifiers.macros import Applicable, ensure_function_empty, pipe, step
from hamilton.node import DependencyType

import tests.resources.pipe


def test_no_code_validator():
def no_code():
Expand Down
3 changes: 2 additions & 1 deletion tests/function_modifiers/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Tuple

import pytest
import tests.resources.reuse_subdag

from hamilton import ad_hoc_utils, graph
from hamilton.function_modifiers import (
Expand All @@ -18,6 +17,8 @@
from hamilton.function_modifiers.dependencies import source
from hamilton.function_modifiers.recursive import _validate_config_inputs

import tests.resources.reuse_subdag


def test_collect_function_fns():
val = random.randint(0, 100000)
Expand Down
11 changes: 6 additions & 5 deletions tests/function_modifiers/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import numpy as np
import pandas as pd
import pytest
from tests.resources.dq_dummy_examples import (
DUMMY_VALIDATORS_FOR_TESTING,
SampleDataValidator2,
SampleDataValidator3,
)

from hamilton import node
from hamilton.data_quality.base import DataValidationError, ValidationResult
Expand All @@ -17,6 +12,12 @@
)
from hamilton.node import DependencyType

from tests.resources.dq_dummy_examples import (
DUMMY_VALIDATORS_FOR_TESTING,
SampleDataValidator2,
SampleDataValidator3,
)


def test_check_output_node_transform():
decorator = check_output(
Expand Down
5 changes: 3 additions & 2 deletions tests/io/test_materialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from typing import Any, Collection, Dict, List, Optional, Tuple, Type

import pytest
import tests.resources.cyclic_functions
import tests.resources.test_default_args

from hamilton import base, graph, node, registry
from hamilton.function_modifiers import load_from, save_to, value
Expand All @@ -20,6 +18,9 @@
to,
)

import tests.resources.cyclic_functions
import tests.resources.test_default_args

global_mock_data_saver_cache = {}


Expand Down
3 changes: 2 additions & 1 deletion tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

import pandas as pd
import pytest
from tests import nodes

from hamilton import base
from hamilton.driver import Driver
from hamilton.experimental import h_cache

from tests import nodes


@pytest.fixture
def df():
Expand Down
5 changes: 3 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest
import tests.resources.cyclic_functions
import tests.resources.test_default_args

from hamilton import common, driver

import tests.resources.cyclic_functions
import tests.resources.test_default_args


class Object:
"""Dummy class to test with."""
Expand Down
13 changes: 7 additions & 6 deletions tests/test_default_data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
import numpy as np
import pandas as pd
import pytest
from tests.resources.dq_dummy_examples import (
DUMMY_VALIDATORS_FOR_TESTING,
SampleDataValidator1,
SampleDataValidator2,
SampleDataValidator3,
)

import hamilton.data_quality.base
from hamilton.data_quality import default_validators
Expand All @@ -21,6 +15,13 @@
resolve_default_validators,
)

from tests.resources.dq_dummy_examples import (
DUMMY_VALIDATORS_FOR_TESTING,
SampleDataValidator1,
SampleDataValidator2,
SampleDataValidator3,
)


@pytest.mark.parametrize(
"output_type, kwargs, importance, expected",
Expand Down
7 changes: 4 additions & 3 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from typing import Any, Callable, Dict, List, Type

import pytest
import tests.resources.data_quality
import tests.resources.dynamic_config
import tests.resources.overrides

from hamilton import ad_hoc_utils, base, driver, settings
from hamilton.base import DefaultAdapter
Expand All @@ -15,6 +12,10 @@
from hamilton.function_modifiers import source, value
from hamilton.io.materialization import from_, to

import tests.resources.data_quality
import tests.resources.dynamic_config
import tests.resources.overrides


@pytest.mark.parametrize(
"driver_factory",
Expand Down
13 changes: 7 additions & 6 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

import pandas as pd
import pytest

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

import tests.resources.bad_functions
import tests.resources.compatible_input_types
import tests.resources.config_modifier
Expand All @@ -22,12 +29,6 @@
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


def test_find_functions():
"""Tests that we filter out _ functions when passed a module and don't pull in anything from the imports."""
Expand Down
13 changes: 7 additions & 6 deletions tests/test_hamilton_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

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 (
Expand All @@ -20,6 +14,13 @@
from hamilton.execution import executors
from hamilton.io.materialization import to

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

"""This file tests driver capabilities.
Anything involving execution is tested for multiple executors/driver configuration.
Anything not involving execution is tested for just the single driver configuration.
Expand Down

0 comments on commit 67278b9

Please sign in to comment.