fix: resolve type hint issues and import dependencies (#1176)

# What does this PR do?

- Fixed type hinting and missing imports across multiple modules.
- Improved compatibility by using `TYPE_CHECKING` for conditional
imports.
- Updated `pyproject.toml` to enforce stricter linting.

Signed-off-by: Sébastien Han <seb@redhat.com>

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-02-25 20:06:47 +01:00 committed by GitHub
parent 1a044ef894
commit c223b1862b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 5 deletions

View file

@ -231,7 +231,7 @@ def worker_process_entrypoint(
while True:
try:
task = req_gen.send(result)
if isinstance(task, str) and task == _END_SENTINEL:
if isinstance(task, str) and task == EndSentinel():
break
assert isinstance(task, TaskRequest)

View file

@ -12,6 +12,7 @@ import os
from typing import Any, Dict, List, Optional
import torch
from fairscale.nn.model_parallel.initialize import get_model_parallel_rank
from fairscale.nn.model_parallel.layers import ColumnParallelLinear, RowParallelLinear
from fairscale.nn.model_parallel.mappings import reduce_from_model_parallel_region
from llama_models.llama3.api.args import ModelArgs

View file

@ -73,7 +73,10 @@ def show():
image_data.append({"image_base64": image_base64})
buf.close()
req_con, resp_con = _open_connections()
# The _open_connections method is dynamically made available to
# the interpreter by bundling code from "code_env_prefix.py" -- by literally prefixing it -- and
# then "eval"ing it within a sandboxed interpreter.
req_con, resp_con = _open_connections() # noqa: F821
_json_dump = _json.dumps(
{