Fix: Unsafe path handling and directory pollution in Time Series examples#2236
Fix: Unsafe path handling and directory pollution in Time Series examples#2236jaytiwarihub wants to merge 7 commits intokeras-team:masterfrom
Conversation
Summary of ChangesHello @jaytiwarihub, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and reliability of several Keras examples by addressing critical path handling issues and updating outdated resource links. The primary focus is on preventing unintended directory pollution and ensuring cross-platform compatibility for dataset extraction in time series examples, alongside refreshing image sources in generative and vision examples. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the unsafe path handling and directory pollution issues in the timeseries_weather_forecasting.py and timeseries_traffic_forecasting.py examples by using os.path.dirname for robust path resolution. The fixes are correct and improve the reliability of these examples.
The PR also includes changes in other examples (fine_tune_via_textual_inversion.py, neural_style_transfer.py, grad_cam.py) to update image URLs, presumably to fix broken links. While these changes are beneficial, they are outside the scope described in the PR title and description. It would be good practice to either mention them in the description or submit them as a separate PR.
I've found a few issues in fine_tune_via_textual_inversion.py related to duplicated and misplaced image URLs, and a minor cleanup suggestion for neural_style_transfer.py. Please see my detailed comments below.
|
Thanks, the changes looks good, but let's not delete the files. |
|
Resolve the conflicts and apply the suggestion for your others PRs as well. |
|
Closing this one out! .... The git history got a bit tangled here with some accidental deletions, so I'm moving to a fresh branch to keep things clean |
Description
This PR fixes two path handling issues in the
examples/timeseries/folder that cause fragility on Windows and cache directory pollution.Changes
timeseries_weather_forecasting.pyZipFile.extractall()without a path, dumping dataset files into the user's current working directory instead of the Keras cache. It also used a relative path ("jena_climate...") which fails if the script is run from a different directory.~/.keras/datasets/cache directory usingos.path.dirname(zip_path)and accesses them using an absolute path.timeseries_traffic_forecasting.pydata_dir = data_dir.rstrip("PeMSD7_Full.zip"). This is unsafe becauserstripremoves any character from the set, potentially mangling the directory path if it ends with characters likep,z,i, etc.os.path.dirname(zip_path)for robust, cross-platform parent directory resolution.Test Plan