Skip to content

Aemo filename format 2024 08#72

Open
timcu wants to merge 20 commits into
UNSW-CEEM:masterfrom
timcu:aemo-filename-format-2024-08
Open

Aemo filename format 2024 08#72
timcu wants to merge 20 commits into
UNSW-CEEM:masterfrom
timcu:aemo-filename-format-2024-08

Conversation

@timcu

@timcu timcu commented May 24, 2026

Copy link
Copy Markdown

The main purpose of this pull request was to address issue #71 . On the way I made several other changes that were necessary

  • The original installation as per the poetry.lock file had 11 security vulnerabilities. A poetry update fixed those security issues, except that the required requests library wasn't compatible back to python 3.8 so I increased the lowest supported python to 3.10. That shouldn't be controversial because python.org only support as far back as 3.10.
  • I wanted to use nemseer on python 3.14 so I increased the maximum python version. Then poetry complained about some dependencies not allowing this. I noticed that pandas-stubs was old and mismatched to pandas so I upgraded all the stubs and types libraries to match the installed libraries.
  • The latest version of numpy required minimum python 3.11. I upgraded that in pyproject.toml. This was a more controversial decision, but will only be controversial until Oct 2026 when python.org stop supporting python 3.10.
  • While I was setting up my dev environment I noticed some changes to how poetry now works. I was also getting warnings when running tests when I had the docs environment also installed, so I updated CONTRIBUTING.md that docs (requires anyio) and test (requires grequests) were incompatible and couldn't be run together on modern python versions.
  • I fixed some broken links in README.md
  • I fixed a bug in the use of DataFrames which is not compatible with pandas 3
  • Finally getting to the purpose of this pull request, I added some tests which used both filename formats from before and after August 2024.
  • Then I noticed in another test test_allmonths_available it was hanging at about 2018 with the test continually making the same request of nemweb and continuously getting a 403 response. I rewrote the handling of _rerequest_to_obtain_soup to change the useragent as was so diligently done elsewhere but not here, plus some other handling improvements. This solved the hanging issue.
  • Then I was able to rewrite the filename constructors so they work both before and after the change in format. I also converted to using https from http which is one of the suggestions in Implement requests and performance improvements #63 .

I hope you find this pull request useful and can pull it into the main code.

timcu and others added 9 commits May 24, 2026 17:38
Bring types libraries up to date with their supporting libraries
Update poetry.lock to remove 11 security vulnerabilities
Fix broken URLs
Update poetry instructions for current version of poetry
Document incompatibility of docs and test
…ython now 3.11

Also upgraded some libraries which were quite old
Exclude 2012 to 2014 as data only in zip files, not in folders, on nemweb
Monitor for different response status codes
Respect retry-after header if provided by server
…iles present

Change test fixtures so not incredibly slow and also testing newer data.
Eventually we want tests that cover many dates not just one so fixtures may not be the best solution for get_test_year_and_month or valid_download_datetimes
@timcu

timcu commented May 27, 2026

Copy link
Copy Markdown
Author

Some tests are still failing so I am still updating this pull request

timcu added 2 commits May 29, 2026 19:47
…aying compatible with old format

netcdf can't save CategoricalDtype columns
if using pandas>=3.0.0 or xarray>=2025.4.0 CategoricalDtype columns were throwing an exception
Remove Googlebot user agent because nemweb blocks with 403
Provide enhanced ENUMERATED_TABLES_BY_MONTH to handle differences in table output by month when change happened
Use a separate field for table counter to cope with different AEMO filename formats
Handle AEMO double escaping of # in new filename format ("%2523" = "#")
Construct sqlloader filename in sections so can be used more universally in library
Deprecate function _enumerate_tables which was changing mutable argument in place
@timcu

timcu commented May 29, 2026

Copy link
Copy Markdown
Author

All tests are now passing including some new ones I have added.

Most of the changes are to do with the filename format change and also file existence changes on nemweb.

There was a major problem with saving xarray to netcdf. netcdf format can't save pandas Categorical dtype data and now with recent versions of pandas OR xarray it has started throwing exceptions. I have added some lines to replace categorical data with str before converting to netcdf.

nemweb has started blocking googlebot which is one of the useragents being used so I have removed it.

@prakaa

prakaa commented May 30, 2026

Copy link
Copy Markdown
Contributor

Thanks @timcu appreciate you work on this as I no longer have time to actively maintain nemseer. I will merge this in and increment version number/release

@prakaa

prakaa commented May 30, 2026

Copy link
Copy Markdown
Contributor

@nick-gorman I am no longer in the CEEM org so I can't approve the pending workflow. Are you able to add me as maintainer for NEMSEER or approve the workflow yourself? A new version/release is also required.

Also, would someone in CEEM be able to take over managing PRs etc on NEMSEER?

Use later versions of poetry and python in action workflow also
@dylanjmcconnell

Copy link
Copy Markdown

Hi @prakaa ! -

Also, would someone in CEEM be able to take over managing PRs etc on NEMSEER?

Have sort of been discussing this and/or related issue last few weeks - (Repository organisation and descriptions) - and nemseer is certainly one of repo's flagged as one we need to do something with.

Will sort something out (...eventually / soon) - but will looking to perhaps allocate different people (...i.e. not just @nick-gorman ) to different repo's

timcu added 6 commits June 1, 2026 14:51
Remove some code which is no longer used
As requested by GitHub actions warning
…ld version of numpy which throws warnings in tests about binary incompatibility
Include tests and docs for new functions
Fix some docstring typos
Enable test for mtpasa duid availability
Replace grequests with requests-futures to remove incompatibility between docs and test
Address warnings regarding data fragmentation and unexpected data types
Reverted documentation so now OK to use docs and test together
Ignore incorrect warnings created by numpy caused by cython
@timcu

timcu commented Jun 4, 2026

Copy link
Copy Markdown
Author

Please run CI/CD workflow on my latest commits. I have altered the tests to ensure it doesn't randomly use 2014 or earlier data which is incompatible with NEMSEER. I am not a big fan of randomness in testing. That was why the test was passing on my computer and then failed here. I have left the randomness in there but ensured it can't go outside the valid range.

I have also addressed some of the warnings which were being generated during the tests.

I have also replaced grequests with requests-futures. grequests installed gevent which monkey patched threads and was incompatible with anyio (used in docs) potentially causing python to hang during testing. Even the author of grequests has recommended requests-futures because of these incompatibility issues.

@timcu

timcu commented Jun 23, 2026

Copy link
Copy Markdown
Author

Please approve pending workflow @nick-gorman or @dylanjmcconnell

@timcu

timcu commented Jun 25, 2026

Copy link
Copy Markdown
Author

Thanks for running the tests. It appears that nemweb have changed the URL format between me writing the code and you running the tests because these tests all passed on my computer. They were double escaping # in the URLs and now they are just single escaping #, which is what they should have done all along. The tests are now failing on my computer also. I will adjust the code for the change.

@timcu

timcu commented Jun 29, 2026

Copy link
Copy Markdown
Author

I have updated code to cope with single escaping of # in URLs. I have also updated the CI/CD workflow to use the latest actions to get rid of warnings about Node 20 not available. I have tested the CI/CD workflow in my github area and it passes all tests. I believe the last failure on your github account was due to codecov rate limit for your account. @nick-gorman Please rerun the workflow on the latest commit.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.27273% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.89%. Comparing base (9a326be) to head (b66d596).

Files with missing lines Patch % Lines
src/nemseer/downloader.py 64.28% 12 Missing and 3 partials ⚠️
...emseer/forecast_type/forecasted_time_generators.py 92.45% 2 Missing and 2 partials ⚠️
src/nemseer/data_compilers.py 95.00% 0 Missing and 1 partial ⚠️
src/nemseer/query.py 97.29% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   96.34%   94.89%   -1.45%     
==========================================
  Files           9       10       +1     
  Lines         739      823      +84     
  Branches      153      127      -26     
==========================================
+ Hits          712      781      +69     
- Misses         15       26      +11     
- Partials       12       16       +4     
Flag Coverage Δ
unittests 94.89% <87.27%> (-1.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants