Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plugin regressions #688

Merged
merged 19 commits into from
Oct 7, 2021
19 changes: 17 additions & 2 deletions .github/workflows/pythonbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,21 @@ jobs:
strategy:
matrix:
python-version: [3.8]
plugin-names: ["flytekit-aws-athena", "flytekit-aws-sagemaker", "flytekit-data-fsspec", "flytekit-dolt", "flytekit-greatexpectations", "flytekit-hive", "flytekit-k8s-pod", "flytekit-kf-pytorch", "flytekit-kf-tensorflow", "flytekit-papermill", "flytekit-spark", "flytekit-sqlalchemy", "flytekit-pandera", "flytekit-snowflake"]
plugin-names:
- flytekit-aws-athena
- flytekit-aws-sagemaker
- flytekit-data-fsspec
- flytekit-dolt
- flytekit-greatexpectations
- flytekit-hive
- flytekit-k8s-pod
- flytekit-kf-pytorch
- flytekit-kf-tensorflow
- flytekit-papermill
- flytekit-spark
- flytekit-sqlalchemy
- flytekit-pandera
- flytekit-snowflake
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -72,7 +86,8 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
make setup
cd plugins/${{ matrix.plugin-names }}
pip install -r requirements.txt
# install in develop mode so setuptools doesn't override flytekit on current branch
pip install -e .
pip freeze
- name: Test with coverage
run: |
Expand Down
2 changes: 1 addition & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: test
test:
pytest tests
find . -maxdepth 1 -type d | grep 'flytekit-' | xargs -L1 pytest

.PHONY: build_all_plugins
build_all_plugins:
Expand Down
3 changes: 2 additions & 1 deletion plugins/flytekit-aws-sagemaker/tests/test_hpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
)
from flytekit.models.sagemaker.parameter_ranges import IntegerParameterRange, ParameterRangeOneOf
from flytekit.models.sagemaker.training_job import AlgorithmName, AlgorithmSpecification, TrainingJobResourceConfig
from plugins.tests.awssagemaker.test_training import _get_reg_settings

from .test_training import _get_reg_settings


def test_hpo_for_builtin():
Expand Down
2 changes: 1 addition & 1 deletion plugins/flytekit-greatexpectations/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

microlib_name = f"flytekitplugins-{PLUGIN_NAME}"

plugin_requires = ["flytekit>=0.21.0,<1.0.0", "great-expectations>=0.13.30"]
plugin_requires = ["flytekit>=0.21.0,<1.0.0", "great-expectations>=0.13.30", "sqlalchemy>=1.4.23"]

__version__ = "0.0.0+develop"

Expand Down
6 changes: 6 additions & 0 deletions plugins/flytekit-pandera/flytekitplugins/pandera/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from flytekit.types.schema import FlyteSchema, PandasSchemaWriter, SchemaFormat, SchemaOpenMode
from flytekit.types.schema.types import FlyteSchemaTransformer

T = typing.TypeVar("T")


class PanderaTransformer(TypeTransformer[pandera.typing.DataFrame]):
_SUPPORTED_TYPES: typing.Dict[
Expand Down Expand Up @@ -53,6 +55,10 @@ def _get_schema_type(self, t: Type[pandera.typing.DataFrame]) -> SchemaType:
def get_literal_type(self, t: Type[pandera.typing.DataFrame]) -> LiteralType:
return LiteralType(schema=self._get_schema_type(t))

def assert_type(self, t: Type[T], v: T):
if not hasattr(t, "__origin__") and not isinstance(v, (t, pandas.DataFrame)):
raise TypeError(f"Type of Val '{v}' is not an instance of {t}")

def to_literal(
self,
ctx: FlyteContext,
Expand Down
4 changes: 2 additions & 2 deletions plugins/flytekit-pandera/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def my_wf() -> pandera.typing.DataFrame[OutSchema]:
# raise error when defining workflow using invalid data
invalid_df = pandas.DataFrame({"col1": [1, 2, 3], "col2": list("abc")})

with pytest.raises(pandera.errors.SchemaError):
with pytest.raises(AssertionError):

@workflow
def invalid_wf() -> pandera.typing.DataFrame[OutSchema]:
Expand All @@ -65,7 +65,7 @@ def transform2_noop(df: pandera.typing.DataFrame[IntermediateSchema]) -> pandera
def wf_invalid_output(df: pandera.typing.DataFrame[InSchema]) -> pandera.typing.DataFrame[OutSchema]:
return transform2_noop(df=transform1(df=df))

with pytest.raises(pandera.errors.SchemaError, match="column 'col4' not in dataframe"):
with pytest.raises(TypeError, match="^Failed to convert return value"):
wf_invalid_output(df=valid_df)


Expand Down
8 changes: 7 additions & 1 deletion plugins/flytekit-papermill/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

microlib_name = f"flytekitplugins-{PLUGIN_NAME}"

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0", "papermill>=1.2.0", "nbconvert>=6.0.7", "ipykernel>=5.0.0"]
plugin_requires = [
"flytekit>=0.16.0b0,<1.0.0",
"flytekitplugins-spark>=0.16.0b0,<1.0.0",
"papermill>=1.2.0",
"nbconvert>=6.0.7",
"ipykernel>=5.0.0",
]

__version__ = "0.0.0+develop"

Expand Down
3 changes: 2 additions & 1 deletion plugins/flytekit-papermill/tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from flytekit import kwtypes
from flytekit.types.file import PythonNotebook
from plugins.tests.papermilltests.testdata.datatype import X

from .testdata.datatype import X


def _get_nb_path(name: str, suffix: str = "", abs: bool = True, ext: str = ".ipynb") -> str:
Expand Down
97 changes: 69 additions & 28 deletions plugins/flytekit-papermill/tests/testdata/nb-complex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,104 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"h = \"hello\"\n",
"w = \"./nb-simple.ipynb\"\n",
"n = 5"
]
],
"outputs": [],
"metadata": {
"tags": [
"parameters"
]
}
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# We're importing from the root folder because tests aren't released as part of the package, so there's nothing to\n",
"# import from in the actual package.\n",
"from plugins.tests.papermilltests.testdata.datatype import X\n",
"# import from in the actual package. Assume that we're in the root of the papermill plugin project.\n",
"from tests.testdata.datatype import X\n",
"\n",
"h = h + \" world!\"\n",
"x = X(x=n)"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"tags": [
"outputs"
]
},
"source": [
"from flytekitplugins.papermill import record_outputs\n",
"from flytekit.types.file import PythonNotebook\n",
"\n",
"record_outputs(h=h, w=PythonNotebook(w), x=x)"
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "literals {\n key: \"h\"\n value {\n scalar {\n primitive {\n string_value: \"hello world!\"\n }\n }\n }\n}\nliterals {\n key: \"w\"\n value {\n scalar {\n blob {\n metadata {\n type {\n format: \"ipynb\"\n }\n }\n uri: \"/tmp/flyte/20210112_113703/mock_remote/b96d99e5767adf99ea71fa4d6f3374b8/nb-simple.ipynb\"\n }\n }\n }\n}\nliterals {\n key: \"x\"\n value {\n scalar {\n generic {\n fields {\n key: \"x\"\n value {\n number_value: 5.0\n }\n }\n }\n }\n }\n}"
"text/plain": [
"literals {\n",
" key: \"h\"\n",
" value {\n",
" scalar {\n",
" primitive {\n",
" string_value: \"hello world!\"\n",
" }\n",
" }\n",
" }\n",
"}\n",
"literals {\n",
" key: \"w\"\n",
" value {\n",
" scalar {\n",
" blob {\n",
" metadata {\n",
" type {\n",
" format: \"ipynb\"\n",
" }\n",
" }\n",
" uri: \"/tmp/flyte/20210112_113703/mock_remote/b96d99e5767adf99ea71fa4d6f3374b8/nb-simple.ipynb\"\n",
" }\n",
" }\n",
" }\n",
"}\n",
"literals {\n",
" key: \"x\"\n",
" value {\n",
" scalar {\n",
" generic {\n",
" fields {\n",
" key: \"x\"\n",
" value {\n",
" number_value: 5.0\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
"}"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
"execution_count": 14
}
],
"source": [
"from flytekitplugins.papermill import record_outputs\n",
"from flytekit.types.file import PythonNotebook\n",
"\n",
"record_outputs(h=h, w=PythonNotebook(w), x=x)"
]
"metadata": {
"tags": [
"outputs"
]
}
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"source": [],
"outputs": [],
"source": []
"metadata": {}
}
],
"metadata": {
Expand Down
3 changes: 2 additions & 1 deletion plugins/flytekit-sqlalchemy/tests/test_sql_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from flytekit.common.translator import get_serializable
from flytekit.core import context_manager
from flytekit.core.context_manager import Image, ImageConfig
from plugins.tests.sqlalchemy.test_task import tk as not_tk

from .test_task import tk as not_tk


def test_sql_lhs():
Expand Down
17 changes: 9 additions & 8 deletions plugins/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@

PACKAGE_NAME = "flytekitplugins-parent"
SOURCES = {
"flytekitplugins-athena": "flytekit-aws-athena",
"flytekitplugins-awssagemaker": "flytekit-aws-sagemaker",
"flytekitplugins-fsspec": "flytekit-data-fsspec",
"flytekitplugins-dolt": "flytekit-dolt",
"flytekitplugins-great_expectations": "flytekit-greatexpectations",
"flytekitplugins-hive": "flytekit-hive",
"flytekitplugins-papermill": "flytekit-papermill",
"flytekitplugins-spark": "flytekit-spark",
"flytekitplugins-pod": "flytekit-k8s-pod",
"flytekitplugins-kfpytorch": "flytekit-kf-pytorch",
"flytekitplugins-awssagemaker": "flytekit-aws-sagemaker",
"flytekitplugins-kftensorflow": "flytekit-kf-tensorflow",
"flytekitplugins-pandera": "flytekit-pandera",
"flytekitplugins-dolt": "flytekit-dolt",
"flytekitplugins-sqlalchemy": "flytekit-sqlalchemy",
"flytekitplugins-athena": "flytekit-aws-athena",
"flytekitplugins-great_expectations": "flytekit-greatexpectations",
"flytekitplugins-papermill": "flytekit-papermill",
"flytekitplugins-snowflake": "flytekit-snowflake",
"flytekitplugins-spark": "flytekit-spark",
"flytekitplugins-sqlalchemy": "flytekit-sqlalchemy",
}


Expand Down Expand Up @@ -64,7 +65,7 @@ def run(self):
version="0.1.0",
author="flyteorg",
author_email="[email protected]",
description="This is a fake package to help install all the plugins",
description="This is a microlib package to help install all the plugins",
license="apache2",
classifiers=["Private :: Do Not Upload to pypi server"],
install_requires=[],
Expand Down