SIENTIAPDE-1243: Add type ignores and fix datetime index formatting in gates and model repository.
This commit is contained in:
@@ -126,9 +126,9 @@ class Gates(BaseActivity):
|
|||||||
self.error(f'Filter {fil} not found', metadata)
|
self.error(f'Filter {fil} not found', metadata)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if input_filter_functions[fil](data, config['config']):
|
if input_filter_functions[fil](data, config['config']): # type: ignore[operator]
|
||||||
self.debug(f'Data not passed the input filter {fil}:{config}', metadata)
|
self.debug(f'Data not passed the input filter {fil}:{config}', metadata)
|
||||||
filter_output.append(config['policy'])
|
filter_output.append(config['policy']) # type: ignore[index]
|
||||||
except Exception as e: # noqa: BLE001
|
except Exception as e: # noqa: BLE001
|
||||||
trace = traceback.format_exc()
|
trace = traceback.format_exc()
|
||||||
self.send_notification(
|
self.send_notification(
|
||||||
@@ -145,7 +145,7 @@ class Gates(BaseActivity):
|
|||||||
self.info(f'Input gate result: {path_flag}', metadata)
|
self.info(f'Input gate result: {path_flag}', metadata)
|
||||||
return (
|
return (
|
||||||
path_flag,
|
path_flag,
|
||||||
input_filter_functions['path_confidence'][path_flag],
|
input_filter_functions['path_confidence'][path_flag], # type: ignore[index]
|
||||||
'Input data with bad quality',
|
'Input data with bad quality',
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -205,8 +205,8 @@ class Gates(BaseActivity):
|
|||||||
self.error(f'Filter {fil} not found', metadata)
|
self.error(f'Filter {fil} not found', metadata)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if mlflow_response_filter_functions[fil](data, config):
|
if mlflow_response_filter_functions[fil](data, config): # type: ignore[operator]
|
||||||
filter_output.append(config['policy'])
|
filter_output.append(config['policy']) # type: ignore[index]
|
||||||
comments.append(data['content']['message'])
|
comments.append(data['content']['message'])
|
||||||
self.send_notification(
|
self.send_notification(
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
@@ -232,7 +232,7 @@ class Gates(BaseActivity):
|
|||||||
self.info(f'Mlflow response gate result: {path_flag}', metadata)
|
self.info(f'Mlflow response gate result: {path_flag}', metadata)
|
||||||
return (
|
return (
|
||||||
path_flag,
|
path_flag,
|
||||||
mlflow_response_filter_functions['path_confidence'][path_flag],
|
mlflow_response_filter_functions['path_confidence'][path_flag], # type: ignore[index]
|
||||||
', '.join(comments),
|
', '.join(comments),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ class Gates(BaseActivity):
|
|||||||
if fil not in mlflow_content_filter_functions:
|
if fil not in mlflow_content_filter_functions:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if mlflow_content_filter_functions[fil](data, config):
|
if mlflow_content_filter_functions[fil](data, config): # type: ignore[operator]
|
||||||
filter_output.append(config['policy'])
|
filter_output.append(config['policy']) # type: ignore[index]
|
||||||
self.send_notification(
|
self.send_notification(
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
notification_id=f'{gate_type.upper()}_GATE_CONTENT_FILTER__{fil}',
|
notification_id=f'{gate_type.upper()}_GATE_CONTENT_FILTER__{fil}',
|
||||||
@@ -316,7 +316,7 @@ class Gates(BaseActivity):
|
|||||||
self.info(f'Mlflow content gate result: {path_flag}', metadata)
|
self.info(f'Mlflow content gate result: {path_flag}', metadata)
|
||||||
return (
|
return (
|
||||||
path_flag,
|
path_flag,
|
||||||
mlflow_content_filter_functions['path_confidence'][path_flag],
|
mlflow_content_filter_functions['path_confidence'][path_flag], # type: ignore[index]
|
||||||
'Transformed data not passed the content filter',
|
'Transformed data not passed the content filter',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class MLFlowRepository:
|
|||||||
raise ValueError(f'{message}') from e
|
raise ValueError(f'{message}') from e
|
||||||
|
|
||||||
elif index_type == datetime or index_type == pd.Timestamp:
|
elif index_type == datetime or index_type == pd.Timestamp:
|
||||||
data.index = data.index.strftime(DATETIME_FORMAT_WITH_TZ)
|
data.index = data.index.strftime(DATETIME_FORMAT_WITH_TZ) # type: ignore[attr-defined]
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'{message}')
|
raise ValueError(f'{message}')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user