Skip to content

Commit

Permalink
cleanup linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrifiro committed Aug 7, 2024
1 parent b5b7942 commit b00ce05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def protogen():

try:
with chdir(working_dir):
subprocess.check_output(
[ # noqa: S603,S607
subprocess.check_output( # noqa: S603
[ # noqa: S607
"python",
"-m",
"grpc_tools.protoc",
Expand Down
10 changes: 5 additions & 5 deletions src/vllm_tgis_adapter/grpc/grpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async def GenerateStream(
)
service_metrics.observe_generation_success(start_time=start_time)

def _convert_input_details( # noqa: PLR0913
def _convert_input_details(
self,
result: RequestOutput,
resp_options: ResponseOptions,
Expand Down Expand Up @@ -733,7 +733,7 @@ def _convert_tokens( # noqa: PLR0913
)
token_infos.append(token_info)

async def _validate_prompt_and_tokenize( # noqa: PLR0913
async def _validate_prompt_and_tokenize(
self,
sampling_params: SamplingParams,
truncate_input_tokens: int | None,
Expand Down Expand Up @@ -902,12 +902,12 @@ async def start_grpc_server(
if ssl_keyfile and ssl_certfile:
require_client_auth = False
try:
with open(ssl_keyfile, "rb") as f: # noqa: ASYNC101
with open(ssl_keyfile, "rb") as f: # noqa: ASYNC230
ssl_key = f.read()
except Exception as e:
raise ValueError(f"Error reading `ssl_keyfile` file: {ssl_keyfile}") from e
try:
with open(ssl_certfile, "rb") as f: # noqa: ASYNC101
with open(ssl_certfile, "rb") as f: # noqa: ASYNC230
ssl_cert = f.read()
except Exception as e:
raise ValueError(
Expand All @@ -916,7 +916,7 @@ async def start_grpc_server(
if ssl_ca_certs:
require_client_auth = True
try:
with open(ssl_ca_certs, "rb") as f: # noqa: ASYNC101
with open(ssl_ca_certs, "rb") as f: # noqa: ASYNC230
root_certificates = f.read()
except Exception as e:
raise ValueError(
Expand Down
19 changes: 11 additions & 8 deletions src/vllm_tgis_adapter/tgis_utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ def _to_env_var(arg_name: str) -> str:

def _switch_action_default(action: argparse.Action) -> None:
"""Switch to using env var fallback for all args."""
val = os.environ.get(_to_env_var(action.dest))
if val:
if action.type == bool:
val = val.lower() == "true" or val == "1"
elif action.type == int:
val = int(val)
action.default = val
env_val = os.environ.get(_to_env_var(action.dest))
if not env_val:
return

val: bool | str | int
if action.type is bool:
val = env_val.lower() == "true" or env_val == "1"
elif action.type is int:
val = int(env_val)
action.default = val


class EnvVarArgumentParser(FlexibleArgumentParser):
Expand Down Expand Up @@ -51,7 +54,7 @@ def __init__(
if parser:
parents.append(parser)
for action in parser._actions: # noqa: SLF001
if type(action) == argparse._HelpAction: # noqa: SLF001
if isinstance(action, argparse._HelpAction): # noqa: SLF001
continue
_switch_action_default(action)
super().__init__(
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def make_request_stream(
text: str,
model_id: str | None = None,
max_new_tokens: int = 10,
) -> Generator[GenerationResponse, None, None]:
) -> Generator[GenerationResponse]:
# assert model_id # FIXME: is model_id required?

request = SingleGenerationRequest(
Expand Down

0 comments on commit b00ce05

Please sign in to comment.