Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/flyte/_code_bundle/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from flyte._logging import log, logger
from flyte._utils import AsyncLRUCache
from flyte.errors import CodeBundleError
from flyte.models import CodeBundle

from ._ignore import GitIgnore, Ignore, StandardIgnore
Expand Down Expand Up @@ -144,6 +145,16 @@ async def build_code_bundle(

logger.debug(f"Finding files to bundle, ignoring as configured by: {ignore}")
files, digest = list_files_to_bundle(from_dir, True, *ignore, copy_style=copy_style)
if len(files) == 0:
raise CodeBundleError(
f"No files found to bundle in '{from_dir}'.\n"
"Possible causes:\n"
" - The task file is inside a virtual environment directory (e.g., .venv/, venv/)\n"
" - The task file is excluded by .gitignore\n"
" - The directory does not contain any Python files\n"
"To debug, check that your task file exists in the specified directory and is not ignored."
)

if logger.getEffectiveLevel() <= logging.INFO:
print_ls_tree(from_dir, files)

Expand Down
2 changes: 1 addition & 1 deletion src/flyte/cli/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async def _execute_and_render(self, ctx: click.Context, config: common.CLIConfig
result = await execution_context.run.aio(self.obj, **ctx.params)
except Exception as e:
console.print(common.get_panel("Exception", f"[red]✕ Execution failed:[/red] {e}", config.output_format))
raise
exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intended?


# 3. UI Branching
if self.run_args.local:
Expand Down
9 changes: 9 additions & 0 deletions src/flyte/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,12 @@ class RestrictedTypeError(RuntimeUserError):

def __init__(self, message: str):
super().__init__("RestrictedTypeUsage", message, "user")


class CodeBundleError(RuntimeUserError):
"""
This error is raised when the code bundle cannot be created, for example when no files are found to bundle.
"""

def __init__(self, message: str):
super().__init__("CodeBundleError", message, "user")
Loading