Skip to content

Commit

Permalink
Use FlyteValidationException instead of AssertionError
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Grätz <[email protected]>
  • Loading branch information
Fabio Grätz committed Jan 30, 2024
1 parent c42f215 commit 50ac42f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions flytekit/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def compile(self, **kwargs):
)
bindings.append(b)
except Exception as e:
raise AssertionError(f"Failed to bind output {output_names[0]} for function {self.name}: {e}") from e
raise FlyteValidationException(f"Failed to bind output {output_names[0]} for function {self.name}: {e}") from e
elif len(output_names) > 1:
if not isinstance(workflow_outputs, tuple):
raise AssertionError("The Workflow specification indicates multiple return values, received only one")
Expand All @@ -776,7 +776,7 @@ def compile(self, **kwargs):
)
bindings.append(b)
except Exception as e:
raise AssertionError(f"Failed to bind output {out} for function {self.name}: {e}") from e
raise FlyteValidationException(f"Failed to bind output {out} for function {self.name}: {e}") from e

# Save all the things necessary to create an WorkflowTemplate, except for the missing project and domain
self._nodes = all_nodes
Expand Down
3 changes: 2 additions & 1 deletion tests/flytekit/unit/core/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from flytekit.core.testing import patch, task_mock
from flytekit.core.type_engine import RestrictedTypeError, SimpleTransformer, TypeEngine
from flytekit.core.workflow import workflow
from flytekit.exceptions.user import FlyteValidationException
from flytekit.models import literals as _literal_models
from flytekit.models.core import types as _core_types
from flytekit.models.interface import Parameter
Expand Down Expand Up @@ -138,7 +139,7 @@ def test_missing_output():
def wf() -> str:
return None # type: ignore

with pytest.raises(AssertionError, match="Failed to bind output"):
with pytest.raises(FlyteValidationException, match="Failed to bind output"):
wf.compile()


Expand Down
3 changes: 2 additions & 1 deletion tests/flytekit/unit/experimental/test_eager_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from hypothesis import given, settings

from flytekit import dynamic, task, workflow
from flytekit.exceptions.user import FlyteValidationException
from flytekit.experimental import EagerException, eager
from flytekit.types.directory import FlyteDirectory
from flytekit.types.file import FlyteFile
Expand Down Expand Up @@ -212,7 +213,7 @@ async def eager_wf(x: int) -> int:
out = await local_wf(x=x)
return await double(x=out)

with pytest.raises(AssertionError):
with pytest.raises(FlyteValidationException):
asyncio.run(eager_wf(x=x_input))


Expand Down

0 comments on commit 50ac42f

Please sign in to comment.