You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
Review fixes and ruff settings
This commit is contained in:
committed by
Serguey Zefirov
parent
9446b3d99a
commit
4f8418cea6
@@ -11,7 +11,6 @@ import os
|
||||
import socket
|
||||
import time
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
from random import random
|
||||
from shutil import copyfile
|
||||
from typing import Tuple, Optional
|
||||
@@ -603,11 +602,6 @@ def get_dbroots(node, config=DEFAULT_MCS_CONF_PATH):
|
||||
smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text
|
||||
)
|
||||
|
||||
if dbroots and nc.is_read_only():
|
||||
logger = logging.getLogger('dbroots')
|
||||
logger.warning(f'Config contains dbroots {dbroots} for this read-only node, ignoring')
|
||||
return []
|
||||
|
||||
return dbroots
|
||||
|
||||
|
||||
|
@@ -398,7 +398,7 @@ def _remove_node(root, node):
|
||||
for n in (root.find("./DesiredNodes"), root.find("./InactiveNodes"), root.find("./ActiveNodes")):
|
||||
__remove_helper(n, node)
|
||||
|
||||
read_only_nodes = root.find("./ReadOnlyNodes")
|
||||
read_only_nodes = root.find('./ReadOnlyNodes')
|
||||
if read_only_nodes is not None:
|
||||
__remove_helper(read_only_nodes, node)
|
||||
|
||||
@@ -1015,11 +1015,11 @@ def _add_WES(root, pm_num, node):
|
||||
etree.SubElement(wes_node, "Port").text = "8630"
|
||||
|
||||
|
||||
def _add_read_only_node(root, node) -> None:
|
||||
"""Add node name to ReadOnlyNodes if it's not already there"""
|
||||
read_only_nodes = root.find("./ReadOnlyNodes")
|
||||
def _add_read_only_node(root: etree.Element, node: str) -> None:
|
||||
'''Add node name to ReadOnlyNodes if it is not already there'''
|
||||
read_only_nodes = root.find('./ReadOnlyNodes')
|
||||
if read_only_nodes is None:
|
||||
read_only_nodes = etree.SubElement(root, "ReadOnlyNodes")
|
||||
read_only_nodes = etree.SubElement(root, 'ReadOnlyNodes')
|
||||
else:
|
||||
for n in read_only_nodes.findall("./Node"):
|
||||
if n.text == node:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import socket
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, ANY
|
||||
from lxml import etree
|
||||
|
||||
from cmapi_server import node_manipulation
|
||||
@@ -97,7 +97,7 @@ class NodeManipTester(BaseNodeManipTestCase):
|
||||
|
||||
mock_rebalance_dbroots.assert_not_called()
|
||||
mock_move_primary_node.assert_not_called()
|
||||
mock_add_dbroots_of_other_nodes.assert_called_once_with(root, 2)
|
||||
mock_add_dbroots_of_other_nodes.assert_called_once_with(ANY, 2)
|
||||
|
||||
# Test read-only node removal
|
||||
node_manipulation.remove_node(
|
||||
@@ -111,7 +111,7 @@ class NodeManipTester(BaseNodeManipTestCase):
|
||||
|
||||
mock_rebalance_dbroots.assert_not_called()
|
||||
mock_move_primary_node.assert_not_called()
|
||||
mock_remove_dbroots_of_node.assert_called_once_with(root, 2)
|
||||
mock_remove_dbroots_of_node.assert_called_once_with(ANY, 2)
|
||||
|
||||
|
||||
def test_add_dbroots_nodes_rebalance(self):
|
||||
|
@@ -567,11 +567,6 @@ has dbroot {subel.text}')
|
||||
for j in range(1, int(smc_node.find(f"./ModuleDBRootCount{i}-3").text) + 1):
|
||||
dbroots.append(smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text)
|
||||
|
||||
# TODO not sure about it
|
||||
if dbroots and self.is_read_only(root):
|
||||
module_logger.warning("Config contains dbroots %s for this read-only node, ignoring", dbroots)
|
||||
return []
|
||||
|
||||
return dbroots
|
||||
|
||||
def is_read_only(self, root=None) -> bool:
|
||||
|
22
cmapi/pyproject.toml
Normal file
22
cmapi/pyproject.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[tool.ruff]
|
||||
line-length = 80
|
||||
target-version = "py39"
|
||||
# Enable common rule sets
|
||||
select = [
|
||||
"E", # pycodestyle errors
|
||||
"F", # pyflakes: undefined names, unused imports, etc.
|
||||
"I", # isort: import sorting
|
||||
"B", # flake8-bugbear: common bugs and anti-patterns
|
||||
"UP", # pyupgrade: use modern Python syntax
|
||||
"N", # pep8-naming: naming conventions
|
||||
]
|
||||
|
||||
ignore = []
|
||||
|
||||
# Exclude cache and temporary directories
|
||||
exclude = [
|
||||
"__pycache__",
|
||||
]
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "single"
|
Reference in New Issue
Block a user