Skip to content

Commit

Permalink
Tweaks for some pylint warnings (#858)
Browse files Browse the repository at this point in the history
Minor adjustments to both display in vscode and quiet some pylint
warnings.

Note: in the future I'd like to get some changes from #330 incorporated
to allow more self-contained config examples, with relative paths
support, added, which means changing a pile of APIs, in which case we
can probably make all of these require named position values and remove
those exceptions.
  • Loading branch information
bpkroth authored Sep 24, 2024
1 parent 0e8ef2c commit fcc49aa
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
],
"esbonio.sphinx.confDir": "${workspaceFolder}/doc/source",
"esbonio.sphinx.buildDir": "${workspaceFolder}/doc/build/",
"pylint.severity": {
// display refactor warnings as information messages
"refactor": "Information"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
Expand Down
9 changes: 6 additions & 3 deletions mlos_bench/mlos_bench/services/config_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,15 @@ def build_scheduler( # pylint: disable=too-many-arguments
_LOG.info("Created: Scheduler %s", inst)
return inst

def build_environment( # pylint: disable=too-many-arguments
def build_environment(
self,
config: Dict[str, Any],
tunables: TunableGroups,
global_config: Optional[Dict[str, Any]] = None,
parent_args: Optional[Dict[str, TunableValue]] = None,
service: Optional[Service] = None,
) -> Environment:
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Factory method for a new environment with a given config.
Expand Down Expand Up @@ -566,14 +567,15 @@ def build_service(

return self._build_composite_service(config_list, global_config, parent)

def load_environment( # pylint: disable=too-many-arguments
def load_environment(
self,
json_file_name: str,
tunables: TunableGroups,
global_config: Optional[Dict[str, Any]] = None,
parent_args: Optional[Dict[str, TunableValue]] = None,
service: Optional[Service] = None,
) -> Environment:
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Load and build new environment from the config file.
Expand All @@ -600,14 +602,15 @@ def load_environment( # pylint: disable=too-many-arguments
assert isinstance(config, dict)
return self.build_environment(config, tunables, global_config, parent_args, service)

def load_environment_list( # pylint: disable=too-many-arguments
def load_environment_list(
self,
json_file_name: str,
tunables: TunableGroups,
global_config: Optional[Dict[str, Any]] = None,
parent_args: Optional[Dict[str, TunableValue]] = None,
service: Optional[Service] = None,
) -> List[Environment]:
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Load and build a list of environments from the config file.
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/services/remote/azure/azure_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_credential(self) -> TokenCredential:
cert_bytes = b64decode(secret.value)

# Reauthenticate as the service principal.
self._cred = CertificateCredential(
self._cred = CertificateCredential( # pylint: disable=redefined-variable-type
tenant_id=tenant_id,
client_id=sp_client_id,
certificate_data=cert_bytes,
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/services/remote/ssh/ssh_fileshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def _start_file_copy(
remote_path: str,
recursive: bool = True,
) -> None:
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Starts a file copy operation.
Expand Down
4 changes: 3 additions & 1 deletion mlos_bench/mlos_bench/services/types/config_loader_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def build_environment( # pylint: disable=too-many-arguments
parent_args: Optional[Dict[str, TunableValue]] = None,
service: Optional["Service"] = None,
) -> "Environment":
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Factory method for a new environment with a given config.
Expand Down Expand Up @@ -106,14 +107,15 @@ def build_environment( # pylint: disable=too-many-arguments
An instance of the `Environment` class initialized with `config`.
"""

def load_environment_list( # pylint: disable=too-many-arguments
def load_environment_list(
self,
json_file_name: str,
tunables: "TunableGroups",
global_config: Optional[dict] = None,
parent_args: Optional[Dict[str, TunableValue]] = None,
service: Optional["Service"] = None,
) -> List["Environment"]:
# pylint: disable=too-many-arguments,too-many-positional-arguments
"""
Load and build a list of environments from the config file.
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def locked_docker_services(
"""A locked version of the docker_services fixture to implement xdist single
instance locking.
"""
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-positional-arguments
# Mark the services as in use with the reader lock.
docker_services_lock.acquire_read_lock()
# Acquire the setup lock to prevent multiple setup operations at once.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def test_wait_network_deployment_retry(
],
)
@patch("mlos_bench.services.remote.azure.azure_deployment_services.requests")
# pylint: disable=too-many-arguments
def test_network_operation_status(
mock_requests: MagicMock,
azure_network_service: AzureNetworkService,
Expand All @@ -85,6 +84,7 @@ def test_network_operation_status(
operation_status: Status,
) -> None:
"""Test network operation status."""
# pylint: disable=too-many-arguments,too-many-positional-arguments
mock_response = MagicMock()
mock_response.status_code = http_status_code
mock_requests.post.return_value = mock_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def test_azure_vm_service_custom_data(azure_auth_service: AzureAuthService) -> N
],
)
@patch("mlos_bench.services.remote.azure.azure_deployment_services.requests")
# pylint: disable=too-many-arguments
def test_vm_operation_status(
mock_requests: MagicMock,
azure_vm_service: AzureVMService,
Expand All @@ -149,6 +148,7 @@ def test_vm_operation_status(
operation_status: Status,
) -> None:
"""Test VM operation status."""
# pylint: disable=too-many-arguments,too-many-positional-arguments
mock_response = MagicMock()
mock_response.status_code = http_status_code
mock_requests.post.return_value = mock_response
Expand Down

0 comments on commit fcc49aa

Please sign in to comment.