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 file not found error #2079

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Fix file not found error #2079

merged 1 commit into from
Jan 8, 2024

Conversation

austin362667
Copy link
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

Copy link

welcome bot commented Jan 2, 2024

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
@@ -254,6 +254,8 @@ def get(self, from_path: str, to_path: str, recursive: bool = False, **kwargs):
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):
raise Exception(f"File not found in {from_path}")
Copy link
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}")

@@ -365,7 +365,7 @@ def get(
fpath = self.get_secrets_file(group, key, group_version)
v = os.environ.get(env_var)
if v is not None:
return v
return v.strip()
Copy link
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
Member

Choose a reason for hiding this comment

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

I think it's because of this PR.
https://github.com/flyteorg/flytekit/pull/2077/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped 😅

Copy link

codecov bot commented Jan 2, 2024

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
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

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
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
@@ -254,6 +254,8 @@ def get(self, from_path: str, to_path: str, recursive: bool = False, **kwargs):
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
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
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

Copy link
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
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, wait for your error code reply!

@austin362667 austin362667 marked this pull request as draft January 3, 2024 13:15
@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
162 of 163 checks passed
Copy link

welcome bot commented Jan 8, 2024

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
3 participants