Accept datetime / date for start_time and end_time (#44, #53)#89
Merged
Conversation
Adapted from Matt's 34fecd4 via cherry-pick. Resolved conflicts: - src/nemosis/data_fetch_methods.py: kept HEAD's underscore-aliased module imports (project convention), but adopted Matt's direct filter_on_column_value import since both call sites changed. Kept HEAD's static_downloader_map with download_xlsx (PR #84 rename) and no "_downloader.download_xml" dead key (PR #84 cleanup). - src/nemosis/custom_tables.py: kept Matt's parse_datetime_py call but retained HEAD's pandas freq="5min" (PR #81 deprecation fix). - tests/test_data_fetch_methods.py: dropped Matt's net-hitting tests; the file was deleted by PR #72 in favour of offline-fixture tests. Equivalent coverage will be added in the follow-up commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adapted from Matt's 539670b via cherry-pick. Resolved conflict in src/nemosis/custom_tables.py: kept Matt's midnight='start' / midnight='end' arguments for parse_datetime_py but retained HEAD's pandas freq='5min' (PR #81 deprecation fix). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
inputs, and add end-to-end coverage Matt's PR #67 commits taught dynamic_data_compiler / cache_compiler to accept datetime and date inputs, but missed two setup-function wrappers in query_wrappers.py that still called datetime.strptime() directly. That broke any datetime input flowing through BIDDAYOFFER_D / BIDPEROFFER_D / MNSP_DAYOFFER / MNSP_PEROFFER / MNSP_INTERCONNECTOR (uses dispatch_date_setup) or MNSP_PEROFFER (uses dispatch_half_hour_setup). Both wrappers now route their inputs through parse_datetime_py so they accept any of the three input shapes (str / datetime / date), matching the public-API contract. Also adds tests/end_to_end_table_tests/test_datetime_inputs.py with 5 end-to-end tests covering the offline-fixture-driven equivalents of Matt's now-deleted tests/test_data_fetch_methods.py additions: datetime and date inputs through dynamic_data_compiler and cache_compiler, plus a BIDDAYOFFER_D regression test that exercises the dispatch_date_setup path that this commit fixes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-picks Matt's two PR-#67 commits that taught the public NEMOSIS API to accept
datetime.datetimeanddatetime.dateforstart_time/end_time, not just"YYYY/MM/DD HH:MM:SS"strings. Closes #44 and #53.Public API after this PR:
"YYYY/MM/DD HH:MM:SS"format, unchangedValueError(the conversion isn't implemented since the contract is "treated as market time")end_timeresolves to midnight at the start of the next day so a request bounded by a date covers the whole of that dateCommits
bad82bcAllow start_date to be dt.datetime — Matt's34fecd4, cherry-picked with Matt's authorship preserved691bbb1Allow passing date as start_time and end_time — Matt's539670b, cherry-picked with Matt's authorship preserved8f11360Fix dispatch_date_setup / dispatch_half_hour_setup to accept datetime inputs, and add end-to-end coverage — my follow-upConflict resolutions during cherry-pick
src/nemosis/data_fetch_methods.py: kept HEAD's underscore-aliased module imports (project convention), but adopted Matt's direct_filter_on_column_valueimport since both call sites changed. Kept HEAD'sstatic_downloader_mapwithdownload_xlsx(PR Rename download_xl → download_xlsx, drop dead dict keys #84 rename) and no_downloader.download_xmldead key (PR Rename download_xl → download_xlsx, drop dead dict keys #84 cleanup).src/nemosis/custom_tables.py(twice): kept Matt'sparse_datetime_pycall withmidnight='start'/midnight='end'but retained HEAD's pandasfreq='5min'(PR Small fixes: 1-sec FCAS columns, Excel close, Pandas deprecations #81 deprecation fix).tests/test_data_fetch_methods.py: dropped — the file was deleted by PR Port test suite to offline fixture-based architecture #72 in favour of the offline-fixture suite. Matt's twotest_dt_not_stringtests were re-implemented in offline-fixture style intests/end_to_end_table_tests/test_datetime_inputs.py(see below).Bug Matt's PR didn't catch (fixed here)
dispatch_date_setupanddispatch_half_hour_setupinquery_wrappers.pyare setup-function wrappers used by_set_up_dynamic_compilers. They run BEFORE_parse_datetime_pyis called in the compilers, and both still calleddatetime.strptime(start_time, ...)directly — so passing adatetimeordateto any table that routes through them (BIDDAYOFFER_D,BIDPEROFFER_D,MNSP_DAYOFFER,MNSP_PEROFFER,MNSP_INTERCONNECTOR) raisedTypeError: strptime() argument 1 must be str, not datetime.datetime. Both wrappers now route throughparse_datetime_pyat the start, so they accept any of the three input shapes.Departures from Matt's design
_downloader.Xmodule reference instatic_downloader_maprather than switching to direct function imports. The rest of the file uses underscore-aliased module imports throughout."_downloader.download_xml": download_xmlkey — PR Rename download_xl → download_xlsx, drop dead dict keys #84 already removed it as dead.test_dt_not_stringtests intests/test_data_fetch_methods.py. That whole file was deleted by PR Port test suite to offline fixture-based architecture #72. Offline-fixture replacements intests/end_to_end_table_tests/test_datetime_inputs.pycover the same behaviour without hitting real AEMO.Tests
tests/test_date_generators.py::TestParseDatetimePy— Matt's unit tests, 5 cases (datetime, tz-aware datetime, valid string, invalid string, date withmidnight='start'andmidnight='end').tests/end_to_end_table_tests/test_datetime_inputs.py— 5 new offline-fixture tests:test_dynamic_data_compiler_accepts_datetimetest_dynamic_data_compiler_accepts_date— verifies date end_time resolves to start-of-next-daytest_cache_compiler_accepts_datetimetest_cache_compiler_accepts_datetest_dispatch_date_setup_path_accepts_datetime— regression test for the bug abovePart of the PR #67 breakdown (#9 of ~10).
Test plan
uv run pytest tests/test_date_generators.py tests/end_to_end_table_tests/test_datetime_inputs.py— 33 passuv run pytest— full suite 399 passed / 1 skipped (no regressions)🤖 Generated with Claude Code