Skip to content

Fix file not found error#2079

Merged
pingsutw merged 1 commit into
flyteorg:masterfrom
austin362667:bug/fs
Jan 8, 2024
Merged

Fix file not found error#2079
pingsutw merged 1 commit into
flyteorg:masterfrom
austin362667:bug/fs

Conversation

@austin362667

Copy link
Copy Markdown
Contributor

Tracking issue

flyteorg/flyte#4470

Why are the changes needed?

flyteorg/flyte#4470

Flytekit should raise a file not found error instead of Access denied

What changes were proposed in this pull request?

Raise an exception if the path doesn't exist on the filesystem when dst = file_system.get(from_path, to_path, recursive=recursive, **kwargs) catches OSError.

How was this patch tested?

Setup process

As per mentioned by flyteorg/flyte#4470

  1. pyflyte run --remote workflow.py wf
  2. remove script_mode.tar.gz from s3 bucket (e.g., via minio)
  3. pyflyte run --remote workflow.py wf # run the workflow again

Screenshots

Screenshot 2024-01-02 at 3 59 22 PM

Check all the applicable boxes

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

Related PRs

Docs link

@welcome

welcome Bot commented Jan 2, 2024

Copy link
Copy Markdown

Thank you for opening this pull request! 🙌

These tips will help get your PR across the finish line:

  • Most of the repos have a PR template; if not, fill it out to the best of your knowledge.
  • Sign off your commits (Reference: DCO Guide).

pingsutw
pingsutw previously approved these changes Jan 2, 2024
Comment thread flytekit/core/data_persistence.py Outdated
except OSError as oe:
logger.debug(f"Error in getting {from_path} to {to_path} rec {recursive} {oe}")
if not file_system.exists(from_path):
raise Exception(f"File not found in {from_path}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
raise Exception(f"File not found in {from_path}")
raise FlyteValueException(f"File not found in {from_path}")

Comment thread flytekit/core/context_manager.py Outdated
v = os.environ.get(env_var)
if v is not None:
return v
return v.strip()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why removes strip()?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

dropped 😅

@codecov

codecov Bot commented Jan 2, 2024

Copy link
Copy Markdown

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (e107994) 85.71% compared to head (e05a9e8) 85.75%.
Report is 5 commits behind head on master.

Files Patch % Lines
flytekit/core/data_persistence.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2079      +/-   ##
==========================================
+ Coverage   85.71%   85.75%   +0.03%     
==========================================
  Files         313      313              
  Lines       23396    23428      +32     
  Branches     3501     3511      +10     
==========================================
+ Hits        20055    20090      +35     
+ Misses       2733     2731       -2     
+ Partials      608      607       -1     

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

Future-Outlier
Future-Outlier previously approved these changes Jan 3, 2024

@Future-Outlier Future-Outlier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Austin Liu <austin362667@gmail.com>

reorder import

Signed-off-by: Austin Liu <austin362667@gmail.com>

fix received_value

Signed-off-by: Austin Liu <austin362667@gmail.com>
@austin362667

Copy link
Copy Markdown
Contributor Author
Screenshot 2024-01-03 at 7 03 14 PM

@austin362667 austin362667 marked this pull request as ready for review January 3, 2024 11:05
pingsutw
pingsutw previously approved these changes Jan 3, 2024
return to_path
except OSError as oe:
logger.debug(f"Error in getting {from_path} to {to_path} rec {recursive} {oe}")
if not file_system.exists(from_path):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it possible to raise an error without an additional network call? e.g. are we able to check the error code (404) from oe?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if not, that's fine

@austin362667 austin362667 Jan 3, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Neat, but I've tried oe.errno == FileNotFoundError.errno: and it failed to catch the 404 error.

I think it's ignorable wrt the performance issue, since it's already trapped in the exception handling process.

Future-Outlier
Future-Outlier previously approved these changes Jan 3, 2024

@Future-Outlier Future-Outlier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, wait for your error code reply!

@austin362667 austin362667 marked this pull request as draft January 3, 2024 13:15
@austin362667 austin362667 dismissed stale reviews from Future-Outlier and pingsutw via 67f80b6 January 3, 2024 13:27
@austin362667 austin362667 marked this pull request as ready for review January 3, 2024 14:31
@pingsutw pingsutw merged commit f22cec2 into flyteorg:master Jan 8, 2024
@welcome

welcome Bot commented Jan 8, 2024

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉

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