From: Kefu Chai Date: Mon, 22 Feb 2021 14:43:32 +0000 (+0800) Subject: mgr/diskprediction_local: wrap line longer than 100 chars X-Git-Tag: v17.1.0~2855^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b7cc7ecb51be0f0e2cec4eb014c1ec7e9b423e4;p=ceph.git mgr/diskprediction_local: wrap line longer than 100 chars to appease flake8 and autopep8 Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/diskprediction_local/module.py b/src/pybind/mgr/diskprediction_local/module.py index 64ca49893f8a..f839ead7d7dc 100644 --- a/src/pybind/mgr/diskprediction_local/module.py +++ b/src/pybind/mgr/diskprediction_local/module.py @@ -13,7 +13,7 @@ from mgr_module import CommandResult, MgrModule, Option # from .predictor import get_diskfailurepredictor_path # # in a command thread. See https://tracker.ceph.com/issues/42764 -import scipy # noqa: ignore=F401 +import scipy # noqa: ignore=F401 from .predictor import DevSmartT, Predictor, get_diskfailurepredictor_path @@ -130,7 +130,8 @@ class Module(MgrModule): health_data: Dict[str, Dict[str, Any]] = {} predict_datas: List[DevSmartT] = [] try: - r, outb, outs = self.remote('devicehealth', 'show_device_metrics', devid=devid, sample='') + r, outb, outs = self.remote( + 'devicehealth', 'show_device_metrics', devid=devid, sample='') if r != 0: self.log.error('failed to get device %s health', devid) health_data = {} @@ -145,7 +146,8 @@ class Module(MgrModule): self.log.error('invalid value received for MODULE_OPTIONS.predictor_model') return predicted_result try: - obj_predictor.initialize("{}/models/{}".format(get_diskfailurepredictor_path(), self.predictor_model)) + obj_predictor.initialize( + "{}/models/{}".format(get_diskfailurepredictor_path(), self.predictor_model)) except Exception as e: self.log.error('Error initializing predictor: %s', e) return predicted_result diff --git a/src/pybind/mgr/diskprediction_local/predictor.py b/src/pybind/mgr/diskprediction_local/predictor.py index 21f4711d7c18..e2b1ae9286ef 100644 --- a/src/pybind/mgr/diskprediction_local/predictor.py +++ b/src/pybind/mgr/diskprediction_local/predictor.py @@ -167,13 +167,14 @@ class RHDiskFailurePredictor(Predictor): roll_window_size = 6 # rolling means generator + dataset_size = disk_days_attrs.shape[0] - roll_window_size + 1 gen = (disk_days_attrs[i: i + roll_window_size, ...].mean(axis=0) - for i in range(0, disk_days_attrs.shape[0] - roll_window_size + 1)) + for i in range(dataset_size)) means = np.vstack(gen) # rolling stds generator gen = (disk_days_attrs[i: i + roll_window_size, ...].std(axis=0, ddof=1) - for i in range(0, disk_days_attrs.shape[0] - roll_window_size + 1)) + for i in range(dataset_size)) stds = np.vstack(gen) # coefficient of variation @@ -182,8 +183,7 @@ class RHDiskFailurePredictor(Predictor): featurized = np.hstack((means, stds, cvs, - disk_days_sa['user_capacity'][: disk_days_attrs.shape[0] - roll_window_size + 1].reshape(-1, 1) - )) + disk_days_sa['user_capacity'][: dataset_size].reshape(-1, 1))) # scale features scaler_path = os.path.join(self.model_dirpath, manufacturer + "_scaler.pkl")