Refactor to library-first architecture with thin CLI wrapper#32
Conversation
…SD, convert clean_file to clean_dataframe
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## emmleroy-v1.0.0 #32 +/- ##
===================================================
- Coverage 96.57% 90.97% -5.60%
===================================================
Files 17 21 +4
Lines 846 931 +85
===================================================
+ Hits 817 847 +30
- Misses 29 84 +55
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| df = fix_timestamps(df, sort_values=True) | ||
|
|
||
| if df.empty: | ||
| raise Exception("No data") |
There was a problem hiding this comment.
Should add an error message here before the exception
| df = flag_dataframe(df) | ||
|
|
||
| logger.info("New flag summary:") | ||
| echo_flag_table(df) |
There was a problem hiding this comment.
I don't think we want to include a table, at least not by default as loghandlers can't pick it up easily. Should use logs instead where possible and/or include the table as a separate utility that can optionally be triggered?
There was a problem hiding this comment.
Got it -- I removed this from the flag_command in 44a89e5. The logging in _add_flag() logs which flags are added and for how many rows (although we will modify _add_flag() later so that it is device-specific).
| tmp = fix_timestamps(tmp, set_index=True, sort_values=True, localize_tz=True) | ||
|
|
||
| # merge with the other files | ||
| df = pd.merge(df, tmp, left_index=True, right_index=True, how='outer') |
There was a problem hiding this comment.
Is the goal here to merge two files together or n files? We probably want someway to pass the desired suffix for each file in the event of duplicate column names and/or provide the option to only keep 1?
| from quantaq_py.exceptions import InvalidFileExtension | ||
| from quantaq_py.schema import build_dtype_schema, COLUMN_DEFINITIONS | ||
|
|
||
| def infer_data_source(df): |
There was a problem hiding this comment.
See previous comments on how we may want to improve this auto-detection
| df = df.sort_values(by=tscol) | ||
|
|
||
| # localize the timezone if needed | ||
| if localize_tz: |
There was a problem hiding this comment.
We should make sure we only do this if tscol is timestamp or timestamp_iso and NOT timestamp_local
| @@ -1,7 +1,7 @@ | |||
| [tool.poetry] | |||
| name = "quantaq-cli" | |||
| name = "quantaq-py" | |||
There was a problem hiding this comment.
So, we can change the name from quantaq-cli, but we probably don't want to use quantaq_py as we already have and maintain py_quantaq which may get a bit confusing...
…NOT timestamp_local
…rror msg before exception
…ep only the overlapping columns from both, left, or right
…col names still need to be specified
Summary
This PR restructures quantaq_py as an importable library with cli.py reduced to a thin wrapper around it.
Changes
quantaq_cli/toquantaq_py/quantaq_py/toolkit/, still organized by individual module (e.g.concat.py), but re-exported inquantaq_py/__init__.py--> so they're importable directly asfrom quantaq_py import concat_filescli.py(which first callssafe_loadfor functions that operate on dataframes)log.py