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

Fix bugs with field mapping and lint issue #346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -197,13 +197,13 @@ currently using a minimum version of PyCharm 2019.2.4.
* To run the automatic formatter and check for lint issues run

``` bash
> nox -s format`
> nox -s format
```

* To test specific versions of Python run

``` bash
> nox -s test-3.8`
> nox -s test-3.8
```

### Documentation
Expand Down
18 changes: 13 additions & 5 deletions eland/field_mappings.py
Expand Up @@ -202,6 +202,11 @@ def __init__(
)

get_mapping = client.indices.get_mapping(index=index_pattern)
if not get_mapping: # dict is empty
raise ValueError(
f"Can not get mapping for {index_pattern} "
f"check indexes exist and client has permission to get mapping."
)

# Get all fields (including all nested) and then all field_caps
all_fields = FieldMappings._extract_fields_from_mapping(get_mapping)
Expand Down Expand Up @@ -307,7 +312,10 @@ def flatten(x, name=""):
if field_type == "date" and "format" in x:
date_format = x["format"]
# If there is a conflicting type, warn - first values added wins
if field_name in fields and fields[field_name] != field_type:
if field_name in fields and fields[field_name] != (
field_type,
date_format,
):
warnings.warn(
f"Field {field_name} has conflicting types "
f"{fields[field_name]} != {field_type}",
Expand Down Expand Up @@ -403,14 +411,14 @@ def _create_capability_matrix(all_fields, source_fields, all_fields_caps):

if "non_aggregatable_indices" in vv:
warnings.warn(
"Field {} has conflicting aggregatable fields across indexes {}",
format(field, vv["non_aggregatable_indices"]),
f"Field {field} has conflicting aggregatable fields across indexes "
f"{str(vv['non_aggregatable_indices'])}",
UserWarning,
)
if "non_searchable_indices" in vv:
warnings.warn(
"Field {} has conflicting searchable fields across indexes {}",
format(field, vv["non_searchable_indices"]),
f"Field {field} has conflicting searchable fields across indexes "
f"{str(vv['non_searchable_indices'])}",
UserWarning,
)

Expand Down
8 changes: 0 additions & 8 deletions eland/ml/transformers/__init__.py
Expand Up @@ -65,19 +65,15 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer:
try:
from .xgboost import _MODEL_TRANSFORMERS as _XGBOOST_MODEL_TRANSFORMERS
from .xgboost import (
XGBClassifier,
XGBoostClassifierTransformer,
XGBoostForestTransformer,
XGBoostRegressorTransformer,
XGBRegressor,
)

__all__ += [
"XGBoostClassifierTransformer",
"XGBClassifier",
"XGBoostForestTransformer",
"XGBoostRegressorTransformer",
"XGBRegressor",
]
_MODEL_TRANSFORMERS.update(_XGBOOST_MODEL_TRANSFORMERS)
except ImportError:
Expand All @@ -86,16 +82,12 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer:
try:
from .lightgbm import _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS
from .lightgbm import (
LGBMClassifier,
LGBMClassifierTransformer,
LGBMForestTransformer,
LGBMRegressor,
LGBMRegressorTransformer,
)

__all__ += [
"LGBMRegressor",
"LGBMClassifier",
"LGBMForestTransformer",
"LGBMRegressorTransformer",
"LGBMClassifierTransformer",
Expand Down