Skip to content

Implement insert mode (fixes DEV-146)#52

Merged
aptiko merged 2 commits intoopenmeteo:masterfrom
aptiko:dev-146--insert-all
Dec 8, 2025
Merged

Implement insert mode (fixes DEV-146)#52
aptiko merged 2 commits intoopenmeteo:masterfrom
aptiko:dev-146--insert-all

Conversation

@aptiko
Copy link
Copy Markdown
Member

@aptiko aptiko commented Dec 8, 2025

No description provided.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread loggertodb/enhydris.py
@aptiko aptiko force-pushed the dev-146--insert-all branch from 6d07e38 to d3f34af Compare December 8, 2025 12:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements an insert mode feature that allows retroactively inserting older data that was discovered later. The implementation adds a new --insert-all command-line option and makes extensive type annotation improvements throughout the codebase.

Key Changes

  • Added --insert-all <station> <filepath> CLI option to enable inserting historical data retroactively
  • Modified Enhydris class to support insert mode, which uses "insert" instead of "append" when posting time series data
  • Refactored MeteologgerStorage to accept configparser.SectionProxy instead of plain dictionaries
  • Added comprehensive type annotations using Python 3.10+ style (e.g., dict[str, Any] instead of Dict[str, Any])

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
loggertodb/cli.py Added --insert-all option, refactored configuration reading to support single-station processing with custom file path, added type annotations
loggertodb/enhydris.py Added use_insert_mode parameter, modified _get_ts_end_dates to skip fetching end dates in insert mode, added mode parameter to post_tsdata call, converted to NamedTuple
loggertodb/meteologgerstorage.py Changed parameter type from dict to configparser.SectionProxy, added extensive type annotations, refactored error handling structure, added type safety improvements
tests/test_cli.py Added tests for insert-all functionality, refactored existing tests to use better mock parameter naming, added type annotations
tests/test_enhydris.py Added test_insert_all to verify insert mode behavior, updated constructor calls to include use_insert_mode parameter, added type annotations
tests/loggerstorage/test_loggerstorage.py Updated tests to use configparser.SectionProxy instead of dicts, added type annotations
tests/loggerstorage/test_multitextfileloggerstorage.py Updated tests to use configparser.SectionProxy, added timezone directory handling for pyfakefs, added type annotations
docs/usage.rst Added command-line reference section documenting the --insert-all option with usage examples and limitations
pyproject.toml Updated pthelma dependency to >=2.8.1 and pinned pyfakefs to 5.3.x range
Comments suppressed due to low confidence (1)

loggertodb/meteologgerstorage.py:909

  • The variable v is initialized to an empty string, but if self.variables is empty or no matching ts_id is found in the loop, v will remain an empty string and be used as a dictionary key on line 909, which would likely cause a KeyError. Consider adding an assertion after the loop similar to the pattern used in TextFileMeteologgerStorage._extract_value_and_flags (line 280):
assert v != ""

or

assert isinstance(v, str) and v
        v = ""
        for v, tid in self.variables.items():
            if tid == ts_id:
                break
        return (record[v], "")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/loggerstorage/test_multitextfileloggerstorage.py Outdated
Comment thread tests/loggerstorage/test_multitextfileloggerstorage.py Outdated
Comment thread tests/test_cli.py
Comment thread loggertodb/cli.py Outdated
Comment thread docs/usage.rst Outdated
Comment thread tests/test_enhydris.py
Comment thread tests/loggerstorage/test_multitextfileloggerstorage.py Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 95.78313% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.34%. Comparing base (f6df345) to head (3baeea6).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
loggertodb/meteologgerstorage.py 93.63% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #52      +/-   ##
==========================================
+ Coverage   89.10%   89.34%   +0.24%     
==========================================
  Files           6        6              
  Lines         789      826      +37     
==========================================
+ Hits          703      738      +35     
- Misses         86       88       +2     

☔ View full report in Codecov by Sentry.
📢 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.

@aptiko aptiko force-pushed the dev-146--insert-all branch from d3f34af to ef675d5 Compare December 8, 2025 12:36
@aptiko aptiko force-pushed the dev-146--insert-all branch from ef675d5 to 3baeea6 Compare December 8, 2025 12:58
@aptiko aptiko merged commit 3baeea6 into openmeteo:master Dec 8, 2025
3 checks passed
@aptiko aptiko deleted the dev-146--insert-all branch December 8, 2025 12:59
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.

2 participants