From 52ad5aa85642a130825acd3d1e7b69c4811186cd Mon Sep 17 00:00:00 2001 From: Yuge Zhang Date: Mon, 18 Sep 2023 17:43:01 +0800 Subject: [PATCH] Fix lint issues --- coml/cli.py | 7 +++++-- coml/orm.py | 8 ++------ coml/suggest.py | 5 +---- test/test_surrogate_utils.py | 6 +----- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/coml/cli.py b/coml/cli.py index 29ff823..881d7ed 100644 --- a/coml/cli.py +++ b/coml/cli.py @@ -1,6 +1,7 @@ -import click from typing import Optional +import click + from .orm import database_proxy @@ -25,12 +26,14 @@ def main( if ctx.params["space"] is None or ctx.params["task"] is None: print("Please specify space ID and a task description.") return - from .suggest import suggest, print_suggested_configs from .space import import_space + from .suggest import print_suggested_configs, suggest + results = suggest(import_space(ctx.params["space"]), ctx.params["task"]) print_suggested_configs(*results) database_proxy.close() + @main.command() @click.argument("space", nargs=1) @click.argument("history", nargs=1) diff --git a/coml/orm.py b/coml/orm.py index 90d65ea..8b52d94 100644 --- a/coml/orm.py +++ b/coml/orm.py @@ -87,9 +87,7 @@ def cosine_distance(self, text: str): password=COML_DB_PASSWORD, ) else: - raise NotImplementedError( - f"COML_DB_BACKEND {COML_DB_BACKEND} not supported." - ) + raise NotImplementedError(f"COML_DB_BACKEND {COML_DB_BACKEND} not supported.") def init_db(): @@ -128,9 +126,7 @@ class Space(BaseModel): class Task(BaseModel): task_id: str = TextField(primary_key=True) - embedding = ( - ArrayField() if COML_DB_BACKEND == "sqlite" else VectorField(EMBED_DIM) - ) + embedding = ArrayField() if COML_DB_BACKEND == "sqlite" else VectorField(EMBED_DIM) desc = TextField() row_desc = TextField() diff --git a/coml/suggest.py b/coml/suggest.py index b3cc92c..b28a245 100644 --- a/coml/suggest.py +++ b/coml/suggest.py @@ -21,10 +21,7 @@ ) -def print_suggested_configs( - configurations: Any, - knowledge: str | None -) -> None: +def print_suggested_configs(configurations: Any, knowledge: str | None) -> None: if knowledge: print(f"\n* Rationale: ") print(knowledge) diff --git a/test/test_surrogate_utils.py b/test/test_surrogate_utils.py index 4d63675..c9d5f9e 100644 --- a/test/test_surrogate_utils.py +++ b/test/test_surrogate_utils.py @@ -2,11 +2,7 @@ import pandas as pd import pytest -from coml.surrogate_utils import ( - evaluate_configs, - process_history_df, - train_surrogate, -) +from coml.surrogate_utils import evaluate_configs, process_history_df, train_surrogate def test_process_history_df():