Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add representative time mapping #19

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Add representative time mapping #19

wants to merge 15 commits into from

Conversation

lixiliu
Copy link
Collaborator

@lixiliu lixiliu commented Nov 14, 2024

Add support for representative time config and mapping from representative time to datetime

src/chronify/time_configs.py Outdated Show resolved Hide resolved
src/chronify/time_configs.py Outdated Show resolved Hide resolved
src/chronify/time_configs.py Outdated Show resolved Hide resolved
src/chronify/time_configs.py Outdated Show resolved Hide resolved
src/chronify/time_configs.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
tests/test_time_series_mapper.py Outdated Show resolved Hide resolved
tests/test_time_series_mapper.py Outdated Show resolved Hide resolved
tests/test_time_series_mapper.py Outdated Show resolved Hide resolved
tests/test_time_series_mapper.py Outdated Show resolved Hide resolved
tests/test_time_series_mapper.py Outdated Show resolved Hide resolved
Base automatically changed from fix/ingest-csv to main November 15, 2024 18:48
@codecov-commenter
Copy link

codecov-commenter commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 94.06100% with 37 lines in your changes missing coverage. Please review.

Project coverage is 93.81%. Comparing base (f9d18c9) to head (66943d5).

Files with missing lines Patch % Lines
src/chronify/time_series_mapper_representative.py 91.07% 10 Missing ⚠️
src/chronify/annual_time_range_generator.py 60.00% 6 Missing ⚠️
src/chronify/index_time_range_generator.py 64.28% 5 Missing ⚠️
src/chronify/time_range_generator_factory.py 73.68% 5 Missing ⚠️
src/chronify/time.py 75.00% 3 Missing ⚠️
src/chronify/time_series_checker.py 92.00% 2 Missing ⚠️
src/chronify/time_series_mapper.py 77.77% 2 Missing ⚠️
src/chronify/store.py 93.75% 1 Missing ⚠️
src/chronify/time_configs.py 90.90% 1 Missing ⚠️
src/chronify/utils/sqlalchemy_table.py 97.36% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   93.50%   93.81%   +0.31%     
==========================================
  Files          18       30      +12     
  Lines         831     1374     +543     
==========================================
+ Hits          777     1289     +512     
- Misses         54       85      +31     

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

daniel-thom and others added 2 commits November 22, 2024 18:40
* Refactor time range generation code
* Support mapping time in the Store
* Add missing type annotations
* Remove duplication of representative time columns
src/chronify/time_series_checker.py Outdated Show resolved Hide resolved
src/chronify/time_series_checker.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
tests/data/project_time.json5 Outdated Show resolved Hide resolved
tests/test_checker_representative_time.py Show resolved Hide resolved
tests/test_mapper_representative_time_to_datetime.py Outdated Show resolved Hide resolved

res = df.groupby(["time_zone"])["timestamp"].count().unique().tolist()
tru = [len(ts)]
assert res == tru, "wrong number of timestamps"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do spot check.

lixiliu and others added 3 commits November 26, 2024 22:47
Has `*** TypeError: must be real number, not str` on read_database(selectable, *args) when backend is sqlite3. read_database does not have this error if str sql is passed in instead.
on_stmt &= left_table.c[x] == right_table.c[x]
query = select(*select_stmt).select_from(left_table).join(right_table, on_stmt)
create_table(self._to_schema.name, query, self._engine, self._metadata)
self._metadata.reflect(self._engine, views=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is already happening in create_table, right? (and can be deleted)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's more complete for it to exists here. We should always update the metadata within the same function after creating something.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not a cheap function, but it's time is nothing compared to the time to do this mapping. Still, though, I would prefer that we minimize the number of times it's called. If we end up calling create_table in 15 places, I really hope that every call site doesn't repeat this behavior. I think it would be fine to document in create_table that it takes care of the update. Also, I'm getting warning errors from duckdb_engine every time it's called.

src/chronify/time_series_mapper_representative.py Outdated Show resolved Hide resolved
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