Add interactive download functionality for MaStR date selection #696#697
Conversation
|
Usage Examples 1. Basic Interactive Usage Console Output: 2. Programmatic Usage 3. Backward Compatibility All existing functionality is preserved. The following code continues to work exactly as before: |
|
Nice feature, thank you @fharookshaik ! |
|
Commits Overview This PR introduces interactive download functionality and includes important optimizations to improve robustness and maintainability. Commit 1: "Add tests for interactive download functionality" Added comprehensive test coverage for the new interactive download functionality. Files Changed
Test Cases Created
Key Features Tested
Commit 2: "Refactor date parsing in download_xml_Mastr to improve robustness and readability" Optimized the Files Changed
Test Results Related Issues
*Please note that the test cases were generated with the help of LLM's. The working functionality is manually verified. Feel free to let me know incase of any improvements. Regards, |
| return None, None | ||
|
|
||
| else: | ||
| print("Invalid choice. Please enter 1, 2, or 3.") |
There was a problem hiding this comment.
This looks like some left-over of a previous version. 3 is not an available choice, right?
There was a problem hiding this comment.
Correct @Simon-Will, Thanks for noticing! Let me remove that and recommit with the removed code!
There was a problem hiding this comment.
@Simon-Will I have pushed the correction. Please review it and let me know if something's odd. I am happy to help! :)
|
There's one more thing I'm thinking about here: The returned list of available downloads includes these little dicts of date and filename. The date is formatted as a string. I would prefer if it were a |
I would prefer to have this as a seperate issue and PR - allowing datetime objects is a change that affects multiple places in the codebase I suppose. |
|
@fharookshaik How is your status here? Did you find the time to look at the proposed changes yet? |
Tbh, I don't think there's any proposed change anymore. 😅 @fharookshaik has added tests, a changelog entry and the tiny fixes I requested. If we don't want to switch from date in string format to date as date object, this is ready to be merged. In fact, my branch for #516 / #718 is rebased onto this one here already. @fharookshaik, I think it's a great feature by the way! So thanks a lot for contributing it. Sorry that we haven't been super fast here; we all have a lot at our hands. |
|
@Simon-Will @FlorianK13 Happy to contribute! On a little side note, I have been working on a tiny project called MaStr_Visualizer, a simple containerized web application to better understand the energy unit distribution nation-wide. Initially, I have concentrated more on the architecture and backend wise, there are not much statistics to be explored on the frontend. I am planning to introduce more stats in the later time. Feel free to checkout the project. If it is noteworthy to be displayed under Examples of Usage in this repository, feel free to do so! GitHub Link: https://github.com/fharookshaik/MaStr_Visualizer |
|
Yeah, sorry for the late replies on this PR @fharookshaik - I'd say we merge then, also to not delay the work of you @Simon-Will any further. |
|
Tests are failing as usual, since API key secrets are not revealed to PRs from forked repositories. Someone really needs to fix this 😅 |
| url_time = dt.strptime(bulk_date_string, "%Y%m%d").date().timetuple() | ||
| url = gen_url(url_time) | ||
| # Helper function to convert date string to time.struct_time | ||
| def _parse_date_string(date_str): |
There was a problem hiding this comment.
Could you reuse parse_date_string() from helpers.py?
| >>> # User can then choose a date and download with: | ||
| >>> # db.download(select_date_interactively=True) | ||
| """ | ||
| from open_mastr.xml_download.utils_download_bulk import list_available_downloads |
There was a problem hiding this comment.
| from open_mastr.xml_download.utils_download_bulk import list_available_downloads |
This is better imported at the top of the file I guess.
| # import xml dependencies | ||
| from open_mastr.xml_download.utils_download_bulk import ( | ||
| download_xml_Mastr, | ||
| select_download_date, |
There was a problem hiding this comment.
| select_download_date, | |
| select_download_date, | |
| list_available_downloads, |
|
@fharookshaik yeah, thanks for your first contribution 🎉 |
Summary of the discussion
This documentation describes the implementation of interactive download functionality for the open-MaStR project. The enhancement addresses a key limitation where users could only download the latest MaStR export data (today's date) and had no visibility into available historical downloads.
Problem Solved
Before: Users were limited to downloading only today's MaStR export data through bulk method.
After: Users can now browse all available downloads and select any historical date
Key Features Implemented
Interactive Date Selection: Users can browse available downloads and select which date to download
Programmatic Access: Developers can fetch available dates and select downloads programmatically
Backward Compatibility: All existing functionality preserved - no breaking changes
Enhanced User Experience: User-friendly interfaces for both interactive and programmatic workflows
Type of change (CHANGELOG.md)
Added
get_available_download_links()function to fetch available downloads from MaStR website (#696)list_available_downloads()function to display downloads in user-friendly format (#696)select_download_date()function for interactive date selection (#696)browse_available_downloads()method to Mastr class (#696)Updated
download_xml_Mastr()function with optional URL parameter for custom downloads (#696)Mastr.download()method with select_date_interactively parameter (#696)Mastr.download()method docstring with comprehensive documentation for new parameter (#696)Removed
Workflow checklist
Automation
Closes #696
PR-Assignee
Reviewer