Skip to content

Commit

Permalink
[Misc] Add python format script (#357)
Browse files Browse the repository at this point in the history
* add ruff lint and format rules

* add format scripts

* doc: format

* add version check

* refact: tool version check

* format with new rules
  • Loading branch information
brosoul authored Nov 8, 2024
1 parent 84bb220 commit 65b74ed
Show file tree
Hide file tree
Showing 16 changed files with 327 additions and 207 deletions.
21 changes: 20 additions & 1 deletion python/aibrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,26 @@ At present, `vLLM` engine is supported, and in the future, `SGLang` and other in
For more details on integrate with `vLLM`, please refer to our [Runtime docs](https://github.com/aibrix/aibrix/blob/main/docs/source/features/runtime.rst#metric-standardization).

## Contributing
We welcome contributions from the community! Check out our [contributing guidelines](https://github.com/aibrix/aibrix/CONTRIBUTING.md) to see how you can make a difference.
We welcome contributions from the community! Check out our [contributing guidelines](https://github.com/aibrix/aibrix/blob/main/CONTRIBUTING.md) to see how you can make a difference.

### Build from source

```bash
# This may take several minutes
pip install -e .
```

### Lint, Format and Type Check

Before contribute your code, please run the following commands to ensure that your code passes the tests and linting checks.

```bash
# install dependencies
poetry install --no-root --with dev

# linting, formatting and type checking
bash ./scripts/format.sh
```

## License

Expand Down
16 changes: 8 additions & 8 deletions python/aibrix/aibrix/app.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import argparse
import os
import shutil
from pathlib import Path
import time
from pathlib import Path
from urllib.parse import urljoin

from aibrix.config import EXCLUDE_METRICS_HTTP_ENDPOINTS
from aibrix.metrics.metrics import (
HTTP_COUNTER_METRICS,
HTTP_LATENCY_METRICS,
INFO_METRICS,
REGISTRY,
)
import uvicorn
from fastapi import APIRouter, FastAPI, Request, Response
from fastapi.datastructures import State
Expand All @@ -20,9 +13,16 @@
from starlette.routing import Mount

from aibrix import __version__, envs
from aibrix.config import EXCLUDE_METRICS_HTTP_ENDPOINTS
from aibrix.logger import init_logger
from aibrix.metrics.engine_rules import get_metric_standard_rules
from aibrix.metrics.http_collector import HTTPCollector
from aibrix.metrics.metrics import (
HTTP_COUNTER_METRICS,
HTTP_LATENCY_METRICS,
INFO_METRICS,
REGISTRY,
)
from aibrix.openapi.engine.base import InferenceEngine, get_inference_engine
from aibrix.openapi.protocol import (
ErrorResponse,
Expand Down
4 changes: 2 additions & 2 deletions python/aibrix/aibrix/batch/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.

import asyncio
from aibrix.batch.constant import DEFAULT_JOB_POOL_SIZE

import aibrix.batch.storage as _storage
from aibrix.batch.scheduler import JobScheduler
from aibrix.batch.constant import DEFAULT_JOB_POOL_SIZE
from aibrix.batch.job_manager import JobManager
from aibrix.batch.request_proxy import RequestProxy
from aibrix.batch.scheduler import JobScheduler


class BatchDriver:
Expand Down
3 changes: 2 additions & 1 deletion python/aibrix/aibrix/batch/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import time
import asyncio
import time
from enum import Enum

import aibrix.batch.storage as _storage


Expand Down
6 changes: 3 additions & 3 deletions python/aibrix/aibrix/batch/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from enum import Enum
import time
import asyncio
import bisect
import queue
import time
from abc import ABC, abstractmethod
from enum import Enum

from aibrix.batch.constant import EXPIRE_INTERVAL, DEFAULT_JOB_POOL_SIZE
from aibrix.batch.constant import DEFAULT_JOB_POOL_SIZE, EXPIRE_INTERVAL
from aibrix.batch.job_manager import JobStatus


Expand Down
4 changes: 2 additions & 2 deletions python/aibrix/aibrix/batch/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from aibrix.batch.storage.generic_storage import StorageType
from aibrix.batch.storage.batch_storage import (
get_job_request_len,
get_storage_job_results,
initialize_batch_storage,
put_storage_job_results,
read_job_requests,
remove_storage_job_data,
upload_input_data,
initialize_batch_storage,
)
from aibrix.batch.storage.generic_storage import StorageType


def initialize_storage(storage_type=StorageType.LocalDiskFile, params={}):
Expand Down
4 changes: 2 additions & 2 deletions python/aibrix/aibrix/batch/storage/batch_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import uuid

from aibrix.batch.storage.generic_storage import LocalDiskFiles, StorageType

# [TODO] Add S3 as another storage
from aibrix.batch.storage.tos_storage import TOSStorage
from aibrix.batch.storage.generic_storage import LocalDiskFiles
from aibrix.batch.storage.generic_storage import StorageType

current_job_offsets = {}
job_input_requests = {}
Expand Down
3 changes: 1 addition & 2 deletions python/aibrix/aibrix/batch/storage/generic_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

import json
import os
from enum import Enum
from abc import ABC, abstractmethod

from enum import Enum

LOCAL_STORAGE_PATH_VAR = "LOCAL_STORAGE_PATH"

Expand Down
6 changes: 4 additions & 2 deletions python/aibrix/aibrix/batch/storage/tos_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import logging
import tos
from io import StringIO
import json

import tos

from aibrix.batch.storage.generic_storage import PersistentStorage


Expand Down
1 change: 0 additions & 1 deletion python/aibrix/aibrix/downloader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from aibrix.config import DOWNLOAD_CACHE_DIR
from aibrix.logger import init_logger


logger = init_logger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/aibrix/aibrix/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from prometheus_client import CollectorRegistry, Counter, Histogram, Info


REGISTRY = CollectorRegistry()

INFO_METRICS = Info(
Expand Down
Loading

0 comments on commit 65b74ed

Please sign in to comment.