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

Remove usage of pathlib.Path.unlink(missing_ok=...) #9227

Merged

Conversation

ymerkli
Copy link
Contributor

@ymerkli ymerkli commented Aug 30, 2022

Argument missing_ok in pathlib.Path.unlink() has only been introduced since Python 3.8, leading to errors when using Python 3.7.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improved file existence checks before deletion in various utility functions.

πŸ“Š Key Changes

  • Modified autosplit function to explicitly check for file existence before attempting to delete auto-generated .txt files.
  • Updated safe_download function to verify file presence before deletion to prevent possible file-not-found errors.
  • Changed gdrive_download function to incorporate file presence verification ahead of file and cookie deletions.

🎯 Purpose & Impact

  • The updates prevent potential errors that could arise when attempting to delete files that do not exist.
  • Users will experience smoother operation without encountering exceptions related to file deletion, especially in environments that may not support the missing_ok parameter.
  • Overall reliability of the download and autosplit processes within the repository is enhanced, leading to more robust data preparation and file handling operations.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

πŸ‘‹ Hello @ymerkli, thank you for submitting a YOLOv5 πŸš€ PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • βœ… Verify your PR is up-to-date with ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • βœ… Verify all YOLOv5 Continuous Integration (CI) checks are passing.
  • βœ… Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." β€” Bruce Lee

@glenn-jocher glenn-jocher self-assigned this Aug 30, 2022
@glenn-jocher glenn-jocher changed the title remove usage of pathlib.Path.unlink(missing_ok=...) Remove usage of pathlib.Path.unlink(missing_ok=...) Aug 30, 2022
@glenn-jocher glenn-jocher merged commit 5f1000a into ultralytics:master Aug 30, 2022
@glenn-jocher
Copy link
Member

@ymerkli good catch! PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
remove usage of pathlib.Path.unlink(missing_ok=...)

Co-authored-by: Yannick Merkli <ymerkli@latticeflow.ai>
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.

None yet

2 participants