From 60ca0c1fb17f0535c2df1b441c251cafd1ede7ae Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:43:39 +0000 Subject: [PATCH 1/7] ignore f-string nested quote diffferences --- mlos_bench/mlos_bench/optimizers/base_optimizer.py | 2 +- mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py | 2 +- .../services/remote/azure/azure_network_services.py | 4 +++- .../mlos_bench/services/remote/azure/azure_vm_services.py | 7 +++++-- mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py | 1 + mlos_bench/mlos_bench/storage/util.py | 8 ++++++-- mlos_bench/mlos_bench/tests/dict_templater_test.py | 2 +- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mlos_bench/mlos_bench/optimizers/base_optimizer.py b/mlos_bench/mlos_bench/optimizers/base_optimizer.py index 14eb3eba6ce..dc2e1d23cfb 100644 --- a/mlos_bench/mlos_bench/optimizers/base_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/base_optimizer.py @@ -103,7 +103,7 @@ def _validate_json_config(self, config: dict) -> None: def __repr__(self) -> str: opt_targets = ",".join( - f"{opt_target}:{({1: 'min', -1: 'max'}[opt_dir])}" + f"{opt_target}:{({1: 'min', -1: 'max'}[opt_dir])}" # pylint: disable=inconsistent-quotes # noqa: E501 for (opt_target, opt_dir) in self._opt_targets.items() ) return f"{self.name}({opt_targets},config={self._config})" diff --git a/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py b/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py index f9d5685ae8f..8ffc4d2d0a7 100644 --- a/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py @@ -65,7 +65,7 @@ def __init__( if "max_trials" not in self._config: self._config["max_trials"] = self._max_suggestions assert int(self._config["max_trials"]) >= self._max_suggestions, ( - f"max_trials {self._config.get('max_trials')} " + f"max_trials {self._config.get('max_trials')} " # pylint: disable=inconsistent-quotes # noqa: E501 f"<= max_suggestions{self._max_suggestions}" ) diff --git a/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py b/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py index 4f11e89aa2f..b6caaeeac97 100644 --- a/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py +++ b/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py @@ -84,7 +84,9 @@ def _set_default_params(self, params: dict) -> dict: # pylint: disable=no-self- # since this is a common way to set the deploymentName and can same some # config work for the caller. if "vnetName" in params and "deploymentName" not in params: - params["deploymentName"] = f"{params['vnetName']}-deployment" + params["deploymentName"] = ( + f"{params['vnetName']}-deployment" # pylint: disable=inconsistent-quotes + ) _LOG.info( "deploymentName missing from params. Defaulting to '%s'.", params["deploymentName"], diff --git a/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py b/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py index 856f5e99126..9aecd1cc9d4 100644 --- a/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py +++ b/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py @@ -190,7 +190,10 @@ def _set_default_params(self, params: dict) -> dict: # pylint: disable=no-self- # since this is a common way to set the deploymentName and can same some # config work for the caller. if "vmName" in params and "deploymentName" not in params: - params["deploymentName"] = f"{params['vmName']}-deployment" + params["deploymentName"] = ( + f"{params['vmName']}-deployment" # pylint: disable=inconsistent-quotes + ) + _LOG.info( "deploymentName missing from params. Defaulting to '%s'.", params["deploymentName"], @@ -239,7 +242,7 @@ def wait_host_operation(self, params: dict) -> Tuple[Status, dict]: """ _LOG.info("Wait for operation on VM %s", params["vmName"]) # Try and provide a semi sane default for the deploymentName - params.setdefault(f"{params['vmName']}-deployment") + params.setdefault(f"{params['vmName']}-deployment") # pylint: disable=inconsistent-quotes return self._wait_while(self._check_operation_status, Status.RUNNING, params) def wait_remote_exec_operation(self, params: dict) -> Tuple["Status", dict]: diff --git a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py index 7e33d715ec3..84c709577fa 100644 --- a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py +++ b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py @@ -70,6 +70,7 @@ def id_from_connection(connection: SSHClientConnection) -> str: def id_from_params(connect_params: dict) -> str: """Gets a unique id repr for the connection.""" return ( + # pylint: disable=inconsistent-quotes f"{connect_params.get('username')}@{connect_params['host']}" f":{connect_params.get('port')}" ) diff --git a/mlos_bench/mlos_bench/storage/util.py b/mlos_bench/mlos_bench/storage/util.py index 173f7d95d69..2e2388818d5 100644 --- a/mlos_bench/mlos_bench/storage/util.py +++ b/mlos_bench/mlos_bench/storage/util.py @@ -30,10 +30,14 @@ def kv_df_to_dict(dataframe: pandas.DataFrame) -> Dict[str, Optional[TunableValu data = {} for _, row in dataframe.astype("O").iterrows(): if not isinstance(row["value"], TunableValueTypeTuple): - raise TypeError(f"Invalid column type: {type(row['value'])} value: {row['value']}") + raise TypeError( + f"Invalid column type: {type(row['value'])} value: {row['value']}" # pylint: disable=inconsistent-quotes # noqa: E501 + ) assert isinstance(row["parameter"], str) if row["parameter"] in data: - raise ValueError(f"Duplicate parameter '{row['parameter']}' in dataframe") + raise ValueError( + f"Duplicate parameter '{row['parameter']}' in dataframe" # pylint: disable=inconsistent-quotes # noqa: E501 + ) data[row["parameter"]] = ( try_parse_val(row["value"]) if isinstance(row["value"], str) else row["value"] ) diff --git a/mlos_bench/mlos_bench/tests/dict_templater_test.py b/mlos_bench/mlos_bench/tests/dict_templater_test.py index 588d1f0ee40..33bb83b74be 100644 --- a/mlos_bench/mlos_bench/tests/dict_templater_test.py +++ b/mlos_bench/mlos_bench/tests/dict_templater_test.py @@ -103,7 +103,7 @@ def test_os_env_expansion(source_template_dict: Dict[str, Any]) -> None: ], "dict": { "nested-str-ref": "nested-string-ref", - "nested-extra-str-ref": f"nested-{environ['extra_str']}-ref", + "nested-extra-str-ref": f"nested-{environ['extra_str']}-ref", # pylint: disable=inconsistent-quotes # noqa: E501 }, } From eeeb656afbb397fe5b4ce8541fe8f9835f8dc3b6 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:44:20 +0000 Subject: [PATCH 2/7] ignore generatory typehint advise for modern python while we still support old ones --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b5014df8a87..214c3b58ff6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,7 @@ disable = [ "docstring-first-line-empty", "consider-alternative-union-syntax", # disable for now - still supporting python 3.8 "missing-raises-doc", + "unnecessary-default-type-args", # affects Generator type hints, but we still support python 3.8 ] [tool.pylint.string] From deaa62ea5b070b7257f5827554fa9f4e39eba5ec Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:44:43 +0000 Subject: [PATCH 3/7] alternative way of ignoring things --- .../mlos_bench/environments/local/local_fileshare_env.py | 2 +- .../mlos_bench/tests/services/remote/ssh/fixtures.py | 2 +- .../tests/services/remote/ssh/test_ssh_fileshare.py | 4 +++- mlos_bench/mlos_bench/tests/storage/sql/fixtures.py | 6 +++--- mlos_bench/mlos_bench/tunables/tunable_groups.py | 8 +++++++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py b/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py index 70281b5a036..4e83d898915 100644 --- a/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py +++ b/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py @@ -90,7 +90,7 @@ def _template_from_to(self, config_key: str) -> List[Tuple[Template, Template]]: def _expand( from_to: Iterable[Tuple[Template, Template]], params: Mapping[str, TunableValue], - ) -> Generator[Tuple[str, str], None, None]: + ) -> Generator[Tuple[str, str], None, None]: # pylint: disable=unnecessary-default-type-args """ Substitute $var parameters in from/to path templates. diff --git a/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py b/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py index f4042cf62f9..1169bef41d2 100644 --- a/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py +++ b/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py @@ -51,7 +51,7 @@ def ssh_test_server( ssh_test_server_hostname: str, docker_compose_project_name: str, locked_docker_services: DockerServices, -) -> Generator[SshTestServerInfo, None, None]: +) -> Generator[SshTestServerInfo, None, None]: # pylint: disable=unnecessary-default-type-args """ Fixture for getting the ssh test server services setup via docker-compose using pytest-docker. diff --git a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py index c0bb730a1e1..904af700638 100644 --- a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py +++ b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py @@ -22,7 +22,9 @@ @contextmanager -def closeable_temp_file(**kwargs: Any) -> Generator[_TemporaryFileWrapper, None, None]: +def closeable_temp_file( + **kwargs: Any, +) -> Generator[_TemporaryFileWrapper, None, None]: # pylint: disable=unnecessary-default-type-args """ Provides a context manager for a temporary file that can be closed and still unlinked. diff --git a/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py b/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py index 4e92d9ab9d1..bbdeccece96 100644 --- a/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py +++ b/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py @@ -38,7 +38,7 @@ def storage() -> SqlStorage: def exp_storage( storage: SqlStorage, tunable_groups: TunableGroups, -) -> Generator[SqlStorage.Experiment, None, None]: +) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args """ Test fixture for Experiment using in-memory SQLite3 storage. @@ -60,7 +60,7 @@ def exp_storage( @pytest.fixture def exp_no_tunables_storage( storage: SqlStorage, -) -> Generator[SqlStorage.Experiment, None, None]: +) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args """ Test fixture for Experiment using in-memory SQLite3 storage. @@ -84,7 +84,7 @@ def exp_no_tunables_storage( def mixed_numerics_exp_storage( storage: SqlStorage, mixed_numerics_tunable_groups: TunableGroups, -) -> Generator[SqlStorage.Experiment, None, None]: +) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args """ Test fixture for an Experiment with mixed numerics tunables using in-memory SQLite3 storage. diff --git a/mlos_bench/mlos_bench/tunables/tunable_groups.py b/mlos_bench/mlos_bench/tunables/tunable_groups.py index 99772acfd05..525ee58c89e 100644 --- a/mlos_bench/mlos_bench/tunables/tunable_groups.py +++ b/mlos_bench/mlos_bench/tunables/tunable_groups.py @@ -172,7 +172,13 @@ def __setitem__( self._index[name][name] = value return self._index[name][name] - def __iter__(self) -> Generator[Tuple[Tunable, CovariantTunableGroup], None, None]: + def __iter__( + self, + ) -> Generator[ # pylint: disable=unnecessary-default-type-args + Tuple[Tunable, CovariantTunableGroup], + None, + None, + ]: """ An iterator over all tunables in the group. From 7b7f8f4c3ae7e9cfb93837e27a43922154365d92 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:44:47 +0000 Subject: [PATCH 4/7] Revert "alternative way of ignoring things" This reverts commit deaa62ea5b070b7257f5827554fa9f4e39eba5ec. --- .../mlos_bench/environments/local/local_fileshare_env.py | 2 +- .../mlos_bench/tests/services/remote/ssh/fixtures.py | 2 +- .../tests/services/remote/ssh/test_ssh_fileshare.py | 4 +--- mlos_bench/mlos_bench/tests/storage/sql/fixtures.py | 6 +++--- mlos_bench/mlos_bench/tunables/tunable_groups.py | 8 +------- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py b/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py index 4e83d898915..70281b5a036 100644 --- a/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py +++ b/mlos_bench/mlos_bench/environments/local/local_fileshare_env.py @@ -90,7 +90,7 @@ def _template_from_to(self, config_key: str) -> List[Tuple[Template, Template]]: def _expand( from_to: Iterable[Tuple[Template, Template]], params: Mapping[str, TunableValue], - ) -> Generator[Tuple[str, str], None, None]: # pylint: disable=unnecessary-default-type-args + ) -> Generator[Tuple[str, str], None, None]: """ Substitute $var parameters in from/to path templates. diff --git a/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py b/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py index 1169bef41d2..f4042cf62f9 100644 --- a/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py +++ b/mlos_bench/mlos_bench/tests/services/remote/ssh/fixtures.py @@ -51,7 +51,7 @@ def ssh_test_server( ssh_test_server_hostname: str, docker_compose_project_name: str, locked_docker_services: DockerServices, -) -> Generator[SshTestServerInfo, None, None]: # pylint: disable=unnecessary-default-type-args +) -> Generator[SshTestServerInfo, None, None]: """ Fixture for getting the ssh test server services setup via docker-compose using pytest-docker. diff --git a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py index 904af700638..c0bb730a1e1 100644 --- a/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py +++ b/mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py @@ -22,9 +22,7 @@ @contextmanager -def closeable_temp_file( - **kwargs: Any, -) -> Generator[_TemporaryFileWrapper, None, None]: # pylint: disable=unnecessary-default-type-args +def closeable_temp_file(**kwargs: Any) -> Generator[_TemporaryFileWrapper, None, None]: """ Provides a context manager for a temporary file that can be closed and still unlinked. diff --git a/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py b/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py index bbdeccece96..4e92d9ab9d1 100644 --- a/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py +++ b/mlos_bench/mlos_bench/tests/storage/sql/fixtures.py @@ -38,7 +38,7 @@ def storage() -> SqlStorage: def exp_storage( storage: SqlStorage, tunable_groups: TunableGroups, -) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args +) -> Generator[SqlStorage.Experiment, None, None]: """ Test fixture for Experiment using in-memory SQLite3 storage. @@ -60,7 +60,7 @@ def exp_storage( @pytest.fixture def exp_no_tunables_storage( storage: SqlStorage, -) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args +) -> Generator[SqlStorage.Experiment, None, None]: """ Test fixture for Experiment using in-memory SQLite3 storage. @@ -84,7 +84,7 @@ def exp_no_tunables_storage( def mixed_numerics_exp_storage( storage: SqlStorage, mixed_numerics_tunable_groups: TunableGroups, -) -> Generator[SqlStorage.Experiment, None, None]: # pylint: disable=unnecessary-default-type-args +) -> Generator[SqlStorage.Experiment, None, None]: """ Test fixture for an Experiment with mixed numerics tunables using in-memory SQLite3 storage. diff --git a/mlos_bench/mlos_bench/tunables/tunable_groups.py b/mlos_bench/mlos_bench/tunables/tunable_groups.py index 525ee58c89e..99772acfd05 100644 --- a/mlos_bench/mlos_bench/tunables/tunable_groups.py +++ b/mlos_bench/mlos_bench/tunables/tunable_groups.py @@ -172,13 +172,7 @@ def __setitem__( self._index[name][name] = value return self._index[name][name] - def __iter__( - self, - ) -> Generator[ # pylint: disable=unnecessary-default-type-args - Tuple[Tunable, CovariantTunableGroup], - None, - None, - ]: + def __iter__(self) -> Generator[Tuple[Tunable, CovariantTunableGroup], None, None]: """ An iterator over all tunables in the group. From 07e36c65da53ff6cfb6bdf7da7aee9a5a0fd498d Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:53:19 +0000 Subject: [PATCH 5/7] better way of fixing inconsistent quotes --- mlos_bench/mlos_bench/optimizers/base_optimizer.py | 2 +- mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py | 2 +- .../services/remote/azure/azure_network_services.py | 4 +--- .../mlos_bench/services/remote/azure/azure_vm_services.py | 6 ++---- mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py | 5 ++--- mlos_bench/mlos_bench/storage/util.py | 8 ++------ mlos_bench/mlos_bench/tests/dict_templater_test.py | 8 ++++---- 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/mlos_bench/mlos_bench/optimizers/base_optimizer.py b/mlos_bench/mlos_bench/optimizers/base_optimizer.py index dc2e1d23cfb..25824043daf 100644 --- a/mlos_bench/mlos_bench/optimizers/base_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/base_optimizer.py @@ -103,7 +103,7 @@ def _validate_json_config(self, config: dict) -> None: def __repr__(self) -> str: opt_targets = ",".join( - f"{opt_target}:{({1: 'min', -1: 'max'}[opt_dir])}" # pylint: disable=inconsistent-quotes # noqa: E501 + f"""{opt_target}:{({1: "min", -1: "max"}[opt_dir])}""" for (opt_target, opt_dir) in self._opt_targets.items() ) return f"{self.name}({opt_targets},config={self._config})" diff --git a/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py b/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py index 8ffc4d2d0a7..327c0e6aba7 100644 --- a/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/mlos_core_optimizer.py @@ -65,7 +65,7 @@ def __init__( if "max_trials" not in self._config: self._config["max_trials"] = self._max_suggestions assert int(self._config["max_trials"]) >= self._max_suggestions, ( - f"max_trials {self._config.get('max_trials')} " # pylint: disable=inconsistent-quotes # noqa: E501 + f"""max_trials {self._config.get("max_trials")} """ f"<= max_suggestions{self._max_suggestions}" ) diff --git a/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py b/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py index b6caaeeac97..de1a5a7118a 100644 --- a/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py +++ b/mlos_bench/mlos_bench/services/remote/azure/azure_network_services.py @@ -84,9 +84,7 @@ def _set_default_params(self, params: dict) -> dict: # pylint: disable=no-self- # since this is a common way to set the deploymentName and can same some # config work for the caller. if "vnetName" in params and "deploymentName" not in params: - params["deploymentName"] = ( - f"{params['vnetName']}-deployment" # pylint: disable=inconsistent-quotes - ) + params["deploymentName"] = f"""{params["vnetName"]}-deployment""" _LOG.info( "deploymentName missing from params. Defaulting to '%s'.", params["deploymentName"], diff --git a/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py b/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py index 9aecd1cc9d4..ff24cbaa66f 100644 --- a/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py +++ b/mlos_bench/mlos_bench/services/remote/azure/azure_vm_services.py @@ -190,9 +190,7 @@ def _set_default_params(self, params: dict) -> dict: # pylint: disable=no-self- # since this is a common way to set the deploymentName and can same some # config work for the caller. if "vmName" in params and "deploymentName" not in params: - params["deploymentName"] = ( - f"{params['vmName']}-deployment" # pylint: disable=inconsistent-quotes - ) + params["deploymentName"] = f"""{params["vmName"]}-deployment""" _LOG.info( "deploymentName missing from params. Defaulting to '%s'.", @@ -242,7 +240,7 @@ def wait_host_operation(self, params: dict) -> Tuple[Status, dict]: """ _LOG.info("Wait for operation on VM %s", params["vmName"]) # Try and provide a semi sane default for the deploymentName - params.setdefault(f"{params['vmName']}-deployment") # pylint: disable=inconsistent-quotes + params.setdefault(f"""{params["vmName"]}-deployment""") return self._wait_while(self._check_operation_status, Status.RUNNING, params) def wait_remote_exec_operation(self, params: dict) -> Tuple["Status", dict]: diff --git a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py index 84c709577fa..646e0f53b38 100644 --- a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py +++ b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py @@ -70,9 +70,8 @@ def id_from_connection(connection: SSHClientConnection) -> str: def id_from_params(connect_params: dict) -> str: """Gets a unique id repr for the connection.""" return ( - # pylint: disable=inconsistent-quotes - f"{connect_params.get('username')}@{connect_params['host']}" - f":{connect_params.get('port')}" + f"""{connect_params.get("username")}@{connect_params['host']}""" + f""":{connect_params.get("port")}""" ) def connection_made(self, conn: SSHClientConnection) -> None: diff --git a/mlos_bench/mlos_bench/storage/util.py b/mlos_bench/mlos_bench/storage/util.py index 2e2388818d5..e1c6c1fa054 100644 --- a/mlos_bench/mlos_bench/storage/util.py +++ b/mlos_bench/mlos_bench/storage/util.py @@ -30,14 +30,10 @@ def kv_df_to_dict(dataframe: pandas.DataFrame) -> Dict[str, Optional[TunableValu data = {} for _, row in dataframe.astype("O").iterrows(): if not isinstance(row["value"], TunableValueTypeTuple): - raise TypeError( - f"Invalid column type: {type(row['value'])} value: {row['value']}" # pylint: disable=inconsistent-quotes # noqa: E501 - ) + raise TypeError(f"""Invalid column type: {type(row["value"])} value: {row["value"]}""") assert isinstance(row["parameter"], str) if row["parameter"] in data: - raise ValueError( - f"Duplicate parameter '{row['parameter']}' in dataframe" # pylint: disable=inconsistent-quotes # noqa: E501 - ) + raise ValueError(f"""Duplicate parameter '{row["parameter"]}' in dataframe""") data[row["parameter"]] = ( try_parse_val(row["value"]) if isinstance(row["value"], str) else row["value"] ) diff --git a/mlos_bench/mlos_bench/tests/dict_templater_test.py b/mlos_bench/mlos_bench/tests/dict_templater_test.py index 33bb83b74be..52ec21bd5ae 100644 --- a/mlos_bench/mlos_bench/tests/dict_templater_test.py +++ b/mlos_bench/mlos_bench/tests/dict_templater_test.py @@ -85,7 +85,7 @@ def test_os_env_expansion(source_template_dict: Dict[str, Any]) -> None: results = DictTemplater(source_template_dict).expand_vars(use_os_env=True) assert results == { - "extra_str-ref": f"{environ['extra_str']}-ref", # pylint: disable=inconsistent-quotes + "extra_str-ref": f"""{environ["extra_str"]}-ref""", "str": "string", "str_ref": "string-ref", "secondary_expansion": "string-ref", @@ -103,7 +103,7 @@ def test_os_env_expansion(source_template_dict: Dict[str, Any]) -> None: ], "dict": { "nested-str-ref": "nested-string-ref", - "nested-extra-str-ref": f"nested-{environ['extra_str']}-ref", # pylint: disable=inconsistent-quotes # noqa: E501 + "nested-extra-str-ref": f"""nested-{environ["extra_str"]}-ref""", }, } @@ -116,7 +116,7 @@ def test_from_extras_expansion(source_template_dict: Dict[str, Any]) -> None: } results = DictTemplater(source_template_dict).expand_vars(extra_source_dict=extra_source_dict) assert results == { - "extra_str-ref": f"{extra_source_dict['extra_str']}-ref", # pylint: disable=inconsistent-quotes # noqa: E501 + "extra_str-ref": f"""{extra_source_dict["extra_str"]}-ref""", "str": "string", "str_ref": "string-ref", "secondary_expansion": "string-ref", @@ -134,6 +134,6 @@ def test_from_extras_expansion(source_template_dict: Dict[str, Any]) -> None: ], "dict": { "nested-str-ref": "nested-string-ref", - "nested-extra-str-ref": f"nested-{extra_source_dict['extra_str']}-ref", # pylint: disable=inconsistent-quotes # noqa: E501 + "nested-extra-str-ref": f"""nested-{extra_source_dict["extra_str"]}-ref""", }, } From 0e2ecea09623d1ebd1e78f4d2d0c4b3fd6e95e4f Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 16:56:14 +0000 Subject: [PATCH 6/7] one more --- mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py index 646e0f53b38..c0590e55cfa 100644 --- a/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py +++ b/mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py @@ -70,7 +70,7 @@ def id_from_connection(connection: SSHClientConnection) -> str: def id_from_params(connect_params: dict) -> str: """Gets a unique id repr for the connection.""" return ( - f"""{connect_params.get("username")}@{connect_params['host']}""" + f"""{connect_params.get("username")}@{connect_params["host"]}""" f""":{connect_params.get("port")}""" ) From 22d8839817d8921174aa0807e4aff9ecc6153c3e Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Nov 2024 17:06:02 +0000 Subject: [PATCH 7/7] comments (to help us when deprecating python 3.8) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 214c3b58ff6..04595e1ed9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ disable = [ "fixme", "no-else-return", "consider-using-assignment-expr", - "deprecated-typing-alias", # disable for now - only deprecated recently + "deprecated-typing-alias", # disable for now - still supporting python 3.8 "docstring-first-line-empty", "consider-alternative-union-syntax", # disable for now - still supporting python 3.8 "missing-raises-doc",