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

Improve error message for pyflyte run #2142

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Conversation

pingsutw
Copy link
Member

Why are the changes needed?

Improve error message

What changes were proposed in this pull request?

raise an error if file not found

How was this patch tested?

Before:

(flytekit-3.10) ➜  plugins git:(improve-error-message-1) ✗ pyflyte run --remote flyte-example/airflow_example/time_sensor.py wf
Failed with Unknown Exception <class 'ModuleNotFoundError'> Reason: No module named 'time_sensor'
Traceback:
  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/utils.py", line 139, in invoke
    return super().invoke(ctx)

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1682, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command
    cmd = self.get_command(ctx, cmd_name)

  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/run.py", line 818, in get_command
    entity = load_naive_entity(module, exe_entity, project_root)

  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/run.py", line 294, in load_naive_entity
    importlib.import_module(module_name)

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

No module named 'time_sensor'

After:

(flytekit-3.10) ➜  plugins git:(improve-error-message-1) ✗ pyflyte run --remote flyte-example/airflow_example/time_sensor.py wf 
Failed with Unknown Exception <class 'ValueError'> Reason: File /Users/kevin/git/flytekit/plugins/flyte-example/airflow_example/time_sensor.py does not exist
Traceback:
  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/utils.py", line 139, in invoke
    return super().invoke(ctx)

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1682, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)

  File "/Users/kevin/anaconda3/envs/flytekit-3.10/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command
    cmd = self.get_command(ctx, cmd_name)

  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/run.py", line 796, in get_command
    raise ValueError(f"File {self._filename} does not exist")

File /Users/kevin/git/flytekit/plugins/flyte-example/airflow_example/time_sensor.py does not exist

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f058663) 83.01% compared to head (f56a21e) 85.80%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2142      +/-   ##
==========================================
+ Coverage   83.01%   85.80%   +2.79%     
==========================================
  Files         176      313     +137     
  Lines       17116    23579    +6463     
  Branches     3530     3530              
==========================================
+ Hits        14208    20231    +6023     
- Misses       2298     2738     +440     
  Partials      610      610              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

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

Can we do a similar exercise with inexistent tasks too? In a separate PR.

Copy link
Member

@Future-Outlier Future-Outlier left a comment

Choose a reason for hiding this comment

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

LGTM

@pingsutw pingsutw merged commit 84fbdfe into master Jan 31, 2024
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants