Skip to content

Commit 3cfcc23

Browse files
authored
Fixes lint failures on main (#374)
* lint fixes Signed-off-by: kalyanr <[email protected]> * isort fix Signed-off-by: kalyanr <[email protected]> * update changelog Signed-off-by: kalyanr <[email protected]> --------- Signed-off-by: kalyanr <[email protected]>
1 parent 261eab5 commit 3cfcc23

File tree

10 files changed

+30
-24
lines changed

10 files changed

+30
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4848
- Fix pandas dependency issue in nox session by installing pandas package to python directly by @thanawan-atc in ([#266](https://github.com/opensearch-project/opensearch-py-ml/pull/266))
4949
- Fix conditional job execution issue in model upload workflow by @thanawan-atc in ([#294](https://github.com/opensearch-project/opensearch-py-ml/pull/294))
5050
- fix bug in `MLCommonClient_client.upload_model` by @rawwar in ([#336](https://github.com/opensearch-project/opensearch-py-ml/pull/336))
51+
- fix lint issues on main by @rawwar in ([#374](https://github.com/opensearch-project/opensearch-py-ml/pull/374))
5152

5253
## [1.1.0]
5354

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import os
2323
import sys
2424

25-
2625
sys.path.insert(0, os.path.abspath("../../"))
2726

2827
# -- Project information -----------------------------------------------------

opensearch_py_ml/dataframe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,10 @@ def _sizeof_fmt(num: float, size_qualifier: str) -> str:
978978
elif verbose is False: # specifically set to False, not nesc None
979979
_non_verbose_repr()
980980
else:
981-
_non_verbose_repr() if exceeds_info_cols else _verbose_repr(
982-
number_of_columns
981+
(
982+
_non_verbose_repr()
983+
if exceeds_info_cols
984+
else _verbose_repr(number_of_columns)
983985
)
984986

985987
# pandas 0.25.1 uses get_dtype_counts() here. This

opensearch_py_ml/field_mappings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ def find_aggregatable(row, df):
445445
try:
446446
series = df.loc[df.os_field_name == os_field_name_keyword]
447447
if not series.empty and series.is_aggregatable.squeeze():
448-
row_as_dict[
449-
"aggregatable_os_field_name"
450-
] = os_field_name_keyword
448+
row_as_dict["aggregatable_os_field_name"] = (
449+
os_field_name_keyword
450+
)
451451
else:
452452
row_as_dict["aggregatable_os_field_name"] = None
453453
except KeyError:

opensearch_py_ml/ml_commons/model_uploader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def _register_model(
9595
model_meta_json[TOTAL_CHUNKS_FIELD] = total_num_chunks
9696

9797
if MODEL_CONTENT_SIZE_IN_BYTES_FIELD not in model_meta_json:
98-
model_meta_json[
99-
MODEL_CONTENT_SIZE_IN_BYTES_FIELD
100-
] = model_content_size_in_bytes
98+
model_meta_json[MODEL_CONTENT_SIZE_IN_BYTES_FIELD] = (
99+
model_content_size_in_bytes
100+
)
101101
if MODEL_CONTENT_HASH_VALUE not in model_meta_json:
102102
# Generate the sha1 hash for the model zip file
103103
hash_val_model_file = _generate_model_content_hash_value(model_path)

opensearch_py_ml/ml_models/metrics_correlation/event_detection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def merge_events(
9494
send = ends[ix]
9595
sevents = candidates[ix, :]
9696

97-
merged: List[
98-
Dict[str, torch.Tensor]
99-
] = [] # merge in linear pass over time dimension
97+
merged: List[Dict[str, torch.Tensor]] = (
98+
[]
99+
) # merge in linear pass over time dimension
100100
currstart = torch.tensor([-1])
101101
currend = torch.tensor([-1])
102102
currevent = torch.ones(T) * -1.0

opensearch_py_ml/ml_models/sentencetransformermodel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,9 @@ def make_model_config_json(
13041304
model_config_content["model_content_size_in_bytes"] = os.stat(
13051305
model_zip_file_path
13061306
).st_size
1307-
model_config_content[
1308-
"model_content_hash_value"
1309-
] = _generate_model_content_hash_value(model_zip_file_path)
1307+
model_config_content["model_content_hash_value"] = (
1308+
_generate_model_content_hash_value(model_zip_file_path)
1309+
)
13101310

13111311
if verbose:
13121312
print("generating ml-commons_model_config.json file...\n")

opensearch_py_ml/operations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,9 +1159,11 @@ def _map_pd_aggs_to_os_aggs(
11591159
# piggy-back on that single aggregation.
11601160
if extended_stats_calls >= 2:
11611161
os_aggs = [
1162-
("extended_stats", os_agg)
1163-
if os_agg in extended_stats_os_aggs
1164-
else os_agg
1162+
(
1163+
("extended_stats", os_agg)
1164+
if os_agg in extended_stats_os_aggs
1165+
else os_agg
1166+
)
11651167
for os_agg in os_aggs
11661168
]
11671169

tests/dataframe/test_iterrows_itertuples_pytest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def assert_tuples_almost_equal(left, right):
6161
# Shim which uses pytest.approx() for floating point values inside tuples.
6262
assert len(left) == len(right)
6363
assert all(
64-
(lt == rt) # Not floats? Use ==
65-
if not isinstance(lt, float) and not isinstance(rt, float)
66-
else (lt == pytest.approx(rt)) # If both are floats use pytest.approx()
64+
(
65+
(lt == rt) # Not floats? Use ==
66+
if not isinstance(lt, float) and not isinstance(rt, float)
67+
else (lt == pytest.approx(rt))
68+
) # If both are floats use pytest.approx()
6769
for lt, rt in zip(left, right)
6870
)
6971

utils/model_uploader/update_models_upload_history_md.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ def create_model_json_obj(
7676
"Model ID": model_id,
7777
"Model Version": model_version,
7878
"Model Format": model_format,
79-
"Embedding Dimension": str(embedding_dimension)
80-
if embedding_dimension is not None
81-
else "N/A",
79+
"Embedding Dimension": (
80+
str(embedding_dimension) if embedding_dimension is not None else "N/A"
81+
),
8282
"Pooling Mode": pooling_mode if pooling_mode is not None else "N/A",
8383
"Workflow Run ID": workflow_id if workflow_id is not None else "-",
8484
}

0 commit comments

Comments
 (0)