-
Notifications
You must be signed in to change notification settings - Fork 131
HelpersTask547_Find_more_GFI,_GSI,_Outsourceable_and_Bounty_in_the_code_base #549
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ def get_universe_top_n(universe: List[Any], n: Optional[int]) -> List[Any]: | |
| # ############################################################################# | ||
|
|
||
|
|
||
| # TODO(gp): -> get_time_interval | ||
| # TODO(gp): GFI -> get_time_interval | ||
| def get_period(period: str) -> Tuple[pd.Timestamp, pd.Timestamp]: | ||
| """ | ||
| Get start and end timestamps from the specified period. | ||
|
|
@@ -193,11 +193,11 @@ def build_config_list_varying_asset_id( | |
| # ############################################################################# | ||
|
|
||
|
|
||
| # TODO(gp): -> ...varying_asset_tiles | ||
| # TODO(gp): GFI -> ...varying_asset_tiles | ||
| def build_config_list_varying_universe_tiles( | ||
|
Comment on lines
+196
to
197
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also used in |
||
| config_list: cconfig.ConfigList, | ||
| universe_tile_id: cconfig.CompoundKey, | ||
| # TODO(gp): -> asset_tiles | ||
| # TODO(gp): GFI -> asset_tiles | ||
| universe_tiles: List[List[int]], | ||
| ) -> cconfig.ConfigList: | ||
| """ | ||
|
|
@@ -226,7 +226,7 @@ def build_config_list_varying_universe_tiles( | |
| return config_list_out | ||
|
|
||
|
|
||
| # TODO(gp): -> ...varying_period_tiles | ||
| # TODO(gp): GFI -> ...varying_period_tiles | ||
| def build_config_list_varying_tiled_periods( | ||
|
Comment on lines
+229
to
230
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in |
||
| config_list: cconfig.ConfigList, | ||
| start_timestamp: pd.Timestamp, | ||
|
|
@@ -255,7 +255,7 @@ def build_config_list_varying_tiled_periods( | |
| hdateti.dassert_has_tz(start_timestamp) | ||
| hdateti.dassert_has_tz(end_timestamp) | ||
| hdbg.dassert_lte(start_timestamp, end_timestamp) | ||
| # TODO(gp): Check that the lookback is > 0. | ||
| # TODO(gp): GFI Check that the lookback is > 0. | ||
| lookback = pd.Timedelta(lookback_as_pd_str) | ||
| # | ||
| configs = [] | ||
|
|
@@ -311,7 +311,7 @@ def build_config_list_varying_tiled_periods( | |
| # ############################################################################# | ||
|
|
||
|
|
||
| # TODO(gp): -> build_config_list_using_equal_asset_tiles | ||
| # TODO(gp): GFI -> build_config_list_using_equal_asset_tiles | ||
| def build_config_list_with_tiled_universe( | ||
|
Comment on lines
+314
to
315
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in |
||
| config_list: cconfig.ConfigList, asset_ids: List[int] | ||
| ) -> cconfig.ConfigList: | ||
|
|
@@ -367,7 +367,7 @@ def apply_build_config_list( | |
| return config_list_out | ||
|
|
||
|
|
||
| # TODO(gp): -> build_config_list_using_equal_asset_and_period_tiles | ||
| # TODO(gp): GFI -> build_config_list_using_equal_asset_and_period_tiles | ||
| def build_config_list_with_tiled_universe_and_periods( | ||
|
Comment on lines
+370
to
371
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in |
||
| config_list: cconfig.ConfigList, | ||
| ) -> cconfig.ConfigList: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -472,8 +472,8 @@ def to_config_str(self) -> str: | |
| # ############################################################################# | ||
|
|
||
|
|
||
| # TODO(gp): CleanUp. This is for testing and should be in hobject_test.py. | ||
| # TODO(gp): -> check_object_signature | ||
| # TODO(gp): GSI. This is for testing and should be in hobject_test.py. | ||
| # TODO(gp): GSI -> check_object_signature | ||
| def test_object_signature( | ||
|
Comment on lines
+475
to
477
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in |
||
| self_: Any, obj: Any, *, remove_lines_regex: Optional[str] = None | ||
| ) -> None: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -141,7 +141,7 @@ def dassert_unique_index( | |||
| hdbg.dassert(index.is_unique, msg=msg, *args) | ||||
|
|
||||
|
|
||||
| # TODO(gp): @all Add unit tests. | ||||
| # TODO(gp): GSI. Add unit tests. | ||||
| def dassert_increasing_index( | ||||
|
Comment on lines
+144
to
145
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests already exist: helpers/helpers/test/test_hpandas.py Line 3660 in aaacce3
Either an outdated TODO, or need more specs on what tests still have to be added. |
||||
| obj: Union[pd.Index, pd.DataFrame, pd.Series], | ||||
| msg: Optional[str] = None, | ||||
|
|
@@ -181,7 +181,7 @@ def dassert_increasing_index( | |||
| hdbg.dassert(index.is_monotonic_increasing, msg=msg, *args) | ||||
|
|
||||
|
|
||||
| # TODO(gp): @all Add more info in case of failures and unit tests. | ||||
| # TODO(gp): GSI. Add more info in case of failures and unit tests. | ||||
| def dassert_strictly_increasing_index( | ||||
|
Comment on lines
+184
to
185
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, tests already exist: helpers/helpers/test/test_hpandas.py Line 3731 in aaacce3
Can probably change the TODO to only "Add more info in case of failures", if that's still relevant. |
||||
| obj: Union[pd.Index, pd.DataFrame, pd.Series], | ||||
| msg: Optional[str] = None, | ||||
|
|
@@ -210,7 +210,7 @@ def dassert_monotonic_index( | |||
| hdbg.dassert(cond, msg=msg, *args) | ||||
|
|
||||
|
|
||||
| # TODO(Paul): @gp -> dassert_datetime_indexed_df | ||||
| # TODO(Paul): GSI -> dassert_datetime_indexed_df | ||||
| def dassert_time_indexed_df( | ||||
|
Comment on lines
+213
to
214
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in |
||||
| df: pd.DataFrame, allow_empty: bool, strictly_increasing: bool | ||||
| ) -> None: | ||||
|
|
@@ -1776,11 +1776,11 @@ def get_random_df( | |||
|
|
||||
| # ############################################################################# | ||||
|
|
||||
| # TODO(gp): -> AxisNameSet | ||||
| # TODO(gp): GSI -> AxisNameSet | ||||
| ColumnSet = Optional[Union[str, List[str]]] | ||||
|
|
||||
|
|
||||
| # TODO(gp): -> _resolve_axis_names | ||||
| # TODO(gp): GSI -> _resolve_axis_names | ||||
| def _resolve_column_names( | ||||
| column_set: ColumnSet, | ||||
| columns: Union[List[str], pd.Index], | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -396,114 +396,3 @@ def test1(self) -> None: | |
| # Comment before initializing. | ||
| class TestAnother(): | ||
| pass | ||
|
|
||
| if __name__ == "main": | ||
|
Comment on lines
-399
to
-400
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is all of that deleted? By mistake?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looked weird (and without comment explaining it) so I thought it was a leftover. pytest collects the tests and we don't use the entrypoint. Should it be a manual test? (I.e., a disabled pytest?)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The deleted content is
It all should be restored, otherwise all the tests will break. |
||
| txt = "hello" | ||
| m = re.search("\s", txt) | ||
| n = nltk.word_tokenize(txt) | ||
| hdbg.dassert_path_exists("filename.txt") | ||
| ''' | ||
| return txt | ||
|
|
||
| @staticmethod | ||
| def _get_ipynb_contents1() -> str: | ||
| contents_ipynb = r""" | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Imports" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import pandas as pd\n", | ||
| "import re\n", | ||
| "\n", | ||
| "# TODO: Fix.\n", | ||
| "res = re.findall(r\"[a-z]+\", \"some text\")\n", | ||
| "\n", | ||
| "\n" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3 (ipykernel)", | ||
| "language": "python", | ||
| "name": "python3" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
| """ | ||
| return contents_ipynb | ||
|
|
||
| def _run_linter( | ||
| self, | ||
| file_name: str, | ||
| linter_log: str, | ||
| as_system_call: bool, | ||
| ) -> str: | ||
| if as_system_call: | ||
| cmd = [] | ||
| cmd.append(f"linters/base.py --files {file_name}") | ||
| cmd_as_str = " ".join(cmd) | ||
| ## We need to ignore the errors reported by the script, since it | ||
| ## represents how many lints were found. | ||
| suppress_output = _LOG.getEffectiveLevel() > logging.DEBUG | ||
| hsystem.system( | ||
| cmd_as_str, | ||
| abort_on_error=False, | ||
| suppress_output=suppress_output, | ||
| output_file=linter_log, | ||
| ) | ||
| cmd_rm = f"git restore --staged {file_name}" | ||
| hsystem.system(cmd_rm, abort_on_error=False) | ||
| else: | ||
| logger_verbosity = hdbg.get_logger_verbosity() | ||
| parser = libase._parse() | ||
| args = parser.parse_args( | ||
| [ | ||
| "-f", | ||
| file_name, | ||
| "--linter_log", | ||
| linter_log, | ||
| # TODO(gp): Avoid to call the logger. | ||
| "-v", | ||
| "ERROR", | ||
| ] | ||
| ) | ||
| libase._main(args) | ||
| hdbg.init_logger(logger_verbosity) | ||
|
|
||
| # Read log. | ||
| _LOG.debug("linter_log=%s", linter_log) | ||
| txt = hio.from_file(linter_log) | ||
| # Process log. | ||
| output = [] | ||
| output.append("# linter log") | ||
| for line in txt.split("\n"): | ||
| # Remove the line: | ||
| # Cmd line='.../linter.py -f input.py --linter_log ./linter.log' | ||
| if "cmd line=" in line: | ||
| continue | ||
| # Filter out code rate because of #2241. | ||
| if "Your code has been rated at" in line: | ||
| continue | ||
| output.append(line) | ||
| # Read output. | ||
| _LOG.debug("file_name=%s", file_name) | ||
| output.append("# linter file") | ||
| txt = hio.from_file(file_name) | ||
| output.extend(txt.split("\n")) | ||
| # ////////////// | ||
| output_as_str = "\n".join(output) | ||
| return output_as_str | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is used in other repos too (
cmamp,orange)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll revert and come up with a system to check across the repos.