forked from DAGWorks-Inc/hamilton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds resources that I forgot to port over for tests
- Loading branch information
Showing
19 changed files
with
222 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# pre-commit hooks require a user to have installed `pre-commit`: | ||
# $ brew install pre-commit | ||
# Then install the hooks within the repo: | ||
# $ cd /PATH/TO/Khan | ||
# $ pre-commit install | ||
|
||
repos: | ||
- repo: git://github.com/pre-commit/mirrors-yapf | ||
rev: v0.30.0 | ||
hooks: | ||
- id: yapf | ||
files: .py | ||
args: | ||
- -r | ||
|
||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
# " -> ' | ||
- id: double-quote-string-fixer | ||
# ensures files are either empty or end with a blank line | ||
- id: end-of-file-fixer | ||
# sorts requirements | ||
- id: requirements-txt-fixer | ||
# valid python file | ||
- id: check-ast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[style] | ||
based_on_style = google | ||
|
||
# max characters per line | ||
COLUMN_LIMIT = 100 | ||
|
||
# Put closing brackets on a separate line, dedented, if the bracketed expression can't fit in a single line | ||
DEDENT_CLOSING_BRACKETS = true | ||
|
||
# Place each dictionary entry onto its own line. | ||
EACH_DICT_ENTRY_ON_SEPARATE_LINE = true | ||
|
||
# Join short lines into one line. E.g., single line if statements. | ||
JOIN_MULTIPLE_LINES = true | ||
|
||
# Insert a blank line before a def or class immediately nested within another def or class | ||
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true | ||
|
||
# Split before arguments if the argument list is terminated by a comma. | ||
SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED = true | ||
|
||
# If an argument / parameter list is going to be split, then split before the first argument | ||
SPLIT_BEFORE_FIRST_ARGUMENT = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
pytest-assume | ||
pytest-cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
graphviz | ||
networkx | ||
numpy | ||
pandas |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Module for more dummy functions to test graph things with. | ||
""" | ||
# we import this to check we don't pull in this function when parsing this module. | ||
from tests.resources import only_import_me | ||
|
||
|
||
def A(b, c) -> int: | ||
"""Should error out because we're missing an annotation""" | ||
return b + c | ||
|
||
|
||
def B(b: int, c: int): | ||
"""Should error out because we're missing an annotation""" | ||
return b + c | ||
|
||
|
||
def C(b: int) -> dict: | ||
"""Setting up type mismatch.""" | ||
return {'hi': 'world'} | ||
|
||
|
||
def D(C: int) -> int: | ||
"""C is the incorrect type.""" | ||
return int(C['hi']) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_VALUE = 'value' | ||
|
||
|
||
def key() -> str: | ||
return _VALUE | ||
|
||
|
||
def double_key(key: str) -> str: | ||
return key + key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def some_key() -> str: | ||
return 'some_value' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def key_overwrite_ignoring_input() -> str: | ||
return 'user_specified_value' | ||
|
||
def key_to_overwrite() -> str: | ||
return 'user_specified_value' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from hamilton.function_modifiers import config | ||
|
||
|
||
def new_param() -> str: | ||
return 'dummy' | ||
|
||
|
||
@config.when(fn_1_version=0) | ||
def fn() -> str: | ||
pass | ||
|
||
|
||
@config.when(fn_1_version=1) | ||
def fn__v1() -> str: | ||
return 'version_1' | ||
|
||
|
||
@config.when(fn_1_version=2) | ||
def fn__v2(new_param: str) -> str: | ||
return 'version_2' | ||
|
||
|
||
@config.when(fn_1_version=3, name='fn') | ||
def fn_to_rename() -> str: | ||
return 'version_3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Module for dummy functions to test graph things with. | ||
""" | ||
# we import this to check we don't pull in this function when parsing this module. | ||
from tests.resources import only_import_me | ||
|
||
|
||
def A(b: int, c: int) -> int: | ||
"""Function that should become part of the graph - A""" | ||
return b + c | ||
|
||
|
||
def _do_not_import_me(some_input: int, some_input2: int) -> int: | ||
"""Function that should not become part of the graph - _do_not_import_me.""" | ||
only_import_me.this_is_not_something_we_should_import() | ||
return some_input + some_input2 | ||
|
||
|
||
def B(A: int) -> int: | ||
"""Function that should become part of the graph - B""" | ||
return A * A | ||
|
||
|
||
def C(A: int) -> int: # empty string doc on purpose. | ||
return A * 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pandas as pd | ||
|
||
from hamilton.function_modifiers import extract_columns | ||
|
||
|
||
@extract_columns('col_1', 'col_2') | ||
def generate_df() -> pd.DataFrame: | ||
"""Function that should be parametrized to form multiple functions""" | ||
return pd.DataFrame({ | ||
'col_1': [1, 2, 3], | ||
'col_2': [4, 5, 6]}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Module for functions that we import in other test scenarios but never directly in the test case itself.""" | ||
|
||
|
||
def this_is_not_something_we_should_import(): | ||
print('Why am I being printed?') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from hamilton.function_modifiers import parametrized | ||
|
||
|
||
@parametrized('param', {('parametrized_1', 'doc'): 1, ('parametrized_2', 'doc'): 2, ('parametrized_3', 'doc'): 3}) | ||
def to_parametrize(param: int) -> int: | ||
"""Function that should be parametrized to form multiple functions""" | ||
return param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Module for dummy functions to test graph things with. | ||
""" | ||
|
||
|
||
def A(required: int, defaults_to_zero: int = 0) -> int: | ||
"""Function that should become part of the graph - A""" | ||
return required + defaults_to_zero | ||
|
||
|
||
def B(A: int) -> int: | ||
"""Function that should become part of the graph - B""" | ||
return A * A | ||
|
||
|
||
def C(A: int) -> int: # empty string doc on purpose. | ||
return A * 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Module for dummy functions to test graph things with. | ||
""" | ||
# we import this to check we don't pull in this function when parsing this module. | ||
from tests.resources import only_import_me | ||
from typing import Dict | ||
|
||
|
||
def A(b: int, c: int) -> Dict: | ||
"""Function that outputs a typing type.""" | ||
return {'a': b + c} | ||
|
||
|
||
def _do_not_import_me(some_input: int, some_input2: int) -> int: | ||
"""Function that should not become part of the graph - _do_not_import_me.""" | ||
only_import_me.this_is_not_something_we_should_import() | ||
return some_input + some_input2 | ||
|
||
|
||
def B(A: dict) -> int: | ||
"""Function that depends on A, but says it's a primitive type dict.""" | ||
return A['a'] + 1 | ||
|
||
|
||
def A2(x: int, y: int) -> dict: | ||
"""Graph function using primitive output type.""" | ||
return {'a': x + y} | ||
|
||
|
||
def B2(A2: Dict) -> int: | ||
"""Graph function depending on A2 but saying it's a typing type.""" | ||
return A['a'] + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters