Skip to content

Commit f3d8ffb

Browse files
authored
format all files with yapf (#539)
1 parent aab9495 commit f3d8ffb

27 files changed

+147
-118
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ RUN python3 -m pip install types-requests
8181
RUN python3 -m pip install types-protobuf
8282
RUN python3 -m pip install mkdocs
8383
RUN python3 -m pip install mkdocs-htmlproofer-plugin
84+
RUN python3 -m pip install yapf==0.32.0
8485

8586
RUN apt-get install -y wkhtmltopdf
8687

experiments/experiment_plot.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,17 @@ def get_top_n_values(self, metric_name, n=10, ascending=False):
103103
result = result.head(n=n).reset_index(drop=True)
104104
return result
105105

106-
def plot_histogram(self, data, title, x_label, y_label="Frequency",
107-
xticks=None, bins=None, align="left", figsize=None,
108-
fontsize=None, alpha=0.7):
106+
def plot_histogram(self,
107+
data,
108+
title,
109+
x_label,
110+
y_label="Frequency",
111+
xticks=None,
112+
bins=None,
113+
align="left",
114+
figsize=None,
115+
fontsize=None,
116+
alpha=0.7):
109117
"""
110118
Plot histogram of the given data.
111119
@@ -115,8 +123,13 @@ def plot_histogram(self, data, title, x_label, y_label="Frequency",
115123
A dictionary that maps a name to its corresponding
116124
data of type pd.DataFrame.
117125
"""
118-
self._ax = data.plot(kind="hist", xticks=xticks, bins=bins, align=align,
119-
figsize=figsize, fontsize=fontsize, alpha=alpha)
126+
self._ax = data.plot(kind="hist",
127+
xticks=xticks,
128+
bins=bins,
129+
align=align,
130+
figsize=figsize,
131+
fontsize=fontsize,
132+
alpha=alpha)
120133

121134
self._ax.set_title(title, fontsize=fontsize)
122135
self._ax.set_xlabel(x_label, fontsize=fontsize)

format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def visit(path):
8181

8282
# Check the version of yapf. Needs a consistent version
8383
# of yapf to prevent unneccessary changes in the code.
84-
if (yapf.__version__ != '0.30.0'):
85-
print("Needs yapf 0.30.0, but got yapf {}".format(yapf.__version__))
84+
if (yapf.__version__ != '0.32.0'):
85+
print("Needs yapf 0.32.0, but got yapf {}".format(yapf.__version__))
8686

8787
if (FLAGS.paths is None) or (len(FLAGS.paths) == 0):
8888
parser.print_help()

model_analyzer/config/generate/automatic_model_config_generator.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@
3030
class AutomaticModelConfigGenerator(BaseModelConfigGenerator):
3131
""" Given a model, generates model configs in automatic search mode """
3232

33-
def __init__(self,
34-
config: ConfigCommandProfile,
35-
gpus: List[GPUDevice],
36-
model: ModelProfileSpec,
37-
client: TritonClient,
38-
model_variant_name_manager: ModelVariantNameManager,
39-
default_only: bool,
40-
early_exit_enable: bool) -> None:
33+
def __init__(self, config: ConfigCommandProfile, gpus: List[GPUDevice],
34+
model: ModelProfileSpec, client: TritonClient,
35+
model_variant_name_manager: ModelVariantNameManager,
36+
default_only: bool, early_exit_enable: bool) -> None:
4137
"""
4238
Parameters
4339
----------

model_analyzer/config/generate/base_model_config_generator.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@
3131
class BaseModelConfigGenerator(ConfigGeneratorInterface):
3232
""" Base class for generating model configs """
3333

34-
def __init__(self,
35-
config: ConfigCommandProfile,
36-
gpus: List[GPUDevice],
37-
model: ModelProfileSpec,
38-
client: TritonClient,
39-
model_variant_name_manager: ModelVariantNameManager,
40-
default_only: bool,
41-
early_exit_enable: bool) -> None:
34+
def __init__(self, config: ConfigCommandProfile, gpus: List[GPUDevice],
35+
model: ModelProfileSpec, client: TritonClient,
36+
model_variant_name_manager: ModelVariantNameManager,
37+
default_only: bool, early_exit_enable: bool) -> None:
4238
"""
4339
Parameters
4440
----------
@@ -93,7 +89,8 @@ def get_configs(self) -> Generator[ModelConfig, None, None]:
9389
yield (config)
9490
self._step()
9591

96-
def set_last_results(self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
92+
def set_last_results(
93+
self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
9794
"""
9895
Given the results from the last ModelConfig, make decisions
9996
about future configurations to generate
@@ -144,7 +141,8 @@ def _make_remote_model_config(self) -> ModelConfig:
144141
if not self._config.reload_model_disable:
145142
self._client.load_model(self._base_model_name)
146143
model_config = ModelConfig.create_from_triton_api(
147-
self._client, self._base_model_name, self._config.client_max_retries)
144+
self._client, self._base_model_name,
145+
self._config.client_max_retries)
148146
model_config.set_cpu_only(self._cpu_only)
149147
if not self._config.reload_model_disable:
150148
self._client.unload_model(self._base_model_name)
@@ -158,8 +156,9 @@ def _make_direct_mode_model_config(self, param_combo: Dict) -> ModelConfig:
158156
model_variant_name_manager=self._model_variant_name_manager)
159157

160158
@staticmethod
161-
def make_model_config(param_combo: dict, model: ModelProfileSpec,
162-
model_variant_name_manager: ModelVariantNameManager) -> ModelConfig:
159+
def make_model_config(
160+
param_combo: dict, model: ModelProfileSpec,
161+
model_variant_name_manager: ModelVariantNameManager) -> ModelConfig:
163162
"""
164163
Loads the base model config from the model repository, and then applies the
165164
parameters in the param_combo on top to create and return a new model config

model_analyzer/config/generate/brute_run_config_generator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from model_analyzer.device.gpu_device import GPUDevice
2828
from model_analyzer.result.run_config_measurement import RunConfigMeasurement
2929

30+
3031
class BruteRunConfigGenerator(ConfigGeneratorInterface):
3132
"""
3233
Generates all RunConfigs to execute via brute force given a list of models
@@ -66,13 +67,16 @@ def __init__(self,
6667

6768
self._num_models = len(models)
6869

69-
self._curr_model_run_configs: List[Optional[ModelRunConfig]] = [None for n in range(self._num_models)]
70+
self._curr_model_run_configs: List[Optional[ModelRunConfig]] = [
71+
None for n in range(self._num_models)
72+
]
7073
self._curr_results: List = [[] for n in range(self._num_models)]
7174
self._curr_generators: Dict[int, ConfigGeneratorInterface] = {}
7275

7376
self._skip_default_config = skip_default_config
7477

75-
def set_last_results(self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
78+
def set_last_results(
79+
self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
7680
for index in range(self._num_models):
7781
self._curr_results[index].extend(measurements)
7882

@@ -96,7 +100,9 @@ def _get_next_config(self) -> Generator[RunConfig, None, None]:
96100
def _should_generate_non_default_configs(self) -> bool:
97101
return self._config.triton_launch_mode != 'remote'
98102

99-
def _generate_subset(self, index: int, default_only: bool) -> Generator[RunConfig, None, None]:
103+
def _generate_subset(
104+
self, index: int,
105+
default_only: bool) -> Generator[RunConfig, None, None]:
100106
mrcg = ModelRunConfigGenerator(self._config, self._gpus,
101107
self._models[index], self._client,
102108
self._model_variant_name_manager,
@@ -125,7 +131,8 @@ def _send_results_to_generator(self, index: int) -> None:
125131
self._curr_results[index] = []
126132

127133
@classmethod
128-
def determine_triton_server_env(cls, models: List[ModelProfileSpec]) -> Dict:
134+
def determine_triton_server_env(cls,
135+
models: List[ModelProfileSpec]) -> Dict:
129136
"""
130137
Given a list of models, return the triton environment
131138
"""

model_analyzer/config/generate/config_generator_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from typing import List, Optional, Generator, Any
1717
from model_analyzer.result.run_config_measurement import RunConfigMeasurement
1818

19+
1920
class ConfigGeneratorInterface(abc.ABC):
2021
"""
2122
An interface class for config generators
@@ -40,5 +41,6 @@ def get_configs(self) -> Generator[Any, None, None]:
4041
raise NotImplementedError
4142

4243
@abc.abstractmethod
43-
def set_last_results(self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
44+
def set_last_results(
45+
self, measurements: List[Optional[RunConfigMeasurement]]) -> None:
4446
raise NotImplementedError

model_analyzer/config/generate/coordinate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from copy import deepcopy
1616
from typing import Iterator, Any, Union, List
1717

18+
1819
class Coordinate:
1920
"""
2021
Class to define a coordinate in n-dimension space

model_analyzer/config/generate/coordinate_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818

1919
CoordinateKey = Tuple[Coordinate, ...]
2020

21+
2122
class CoordinateData:
2223
"""
2324
A class that tracks the measurement data in the current neighborhood
2425
and the visit counts of all the coordinates in the coordinate space.
2526
"""
2627

2728
def __init__(self) -> None:
28-
self._measurements: Dict[CoordinateKey, Optional[RunConfigMeasurement]] = {}
29+
self._measurements: Dict[CoordinateKey,
30+
Optional[RunConfigMeasurement]] = {}
2931
self._visit_counts: Dict[CoordinateKey, int] = {}
3032
self._is_measured: Dict[CoordinateKey, bool] = {}
3133

model_analyzer/config/generate/generator_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from itertools import product
1616
from typing import Dict, List
1717

18+
1819
class GeneratorUtils:
1920
''' Class for utility functions for Generators '''
2021

0 commit comments

Comments
 (0)