NatLabRockies / NatLabRockies/chronify
sqlalchemy engine seems to caching metadata causing inconsistency
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Running the following in test_timeseries_mapper.py will raise an error due to inconsistency between the ingested table and the Metadata() object.
def test__one_week_per_month_by_hour(iter_engines: Engine):
run_test(iter_engines, one_week=True, tzinfo=None) # this has no time_zone
run_test(iter_engines, one_week=True, tzinfo=ZoneInfo("US/Eastern")) # this expects time_zone
The metadata object seems to be retaining remnant of the first run_test, which does not have a time_zone column, whereas the second test does.
Confirmed by running the pytest as a regular function that it is not a pytest issue.
The current workaround is to parametrize the pytest on tzinfo or keep each run_test as separate function so that the engine is created new each time.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducer in test_timeseries_mapper.py as a regular function and under pytest, focusing on how the engine and Metadata() are reused across the two run_test calls. Done means consecutive calls with and without tzinfo no longer retain inconsistent table metadata, while the relevant test passes without requiring separate functions or a new engine.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100