From a9cd68f26b76408d432f33a53e3e2a97e8535ac0 Mon Sep 17 00:00:00 2001 From: Motin Date: Thu, 25 Jan 2024 09:19:46 +0200 Subject: [PATCH] Linting --- .../custom_configuration/gpt4_evaluator.py | 3 +-- .../custom_configuration/gpt4_evaluator_config.py | 1 + .../custom_configuration/llms/alibaba_complete.py | 10 ++++++---- .../custom_configuration/model_compare.py | 10 +++++----- .../model_config_variation_generator.py | 5 ++--- .../model_config_variation_generator_config.py | 4 ++-- .../custom_configuration/model_config_wrapper.py | 4 ++-- .../custom_configuration/question_reader.py | 2 +- .../custom_configuration/question_reader_config.py | 1 + .../yival_experiments/scripts/fetch_questions.py | 2 +- .../scripts/generate_experiment_config.py | 8 +++++--- .../yival_experiments/scripts/generate_result.py | 4 ++-- 12 files changed, 29 insertions(+), 25 deletions(-) diff --git a/automation-api/yival_experiments/custom_configuration/gpt4_evaluator.py b/automation-api/yival_experiments/custom_configuration/gpt4_evaluator.py index 775ecf7..59648b5 100644 --- a/automation-api/yival_experiments/custom_configuration/gpt4_evaluator.py +++ b/automation-api/yival_experiments/custom_configuration/gpt4_evaluator.py @@ -13,9 +13,8 @@ # for exponential backoff import litellm -from tenacity import before_sleep_log, retry, stop_after_attempt, wait_random - from gpt4_evaluator_config import GPT4EvaluatorConfig +from tenacity import before_sleep_log, retry, stop_after_attempt, wait_random from yival.evaluators.base_evaluator import BaseEvaluator from yival.schemas.evaluator_config import ( EvaluatorOutput, diff --git a/automation-api/yival_experiments/custom_configuration/gpt4_evaluator_config.py b/automation-api/yival_experiments/custom_configuration/gpt4_evaluator_config.py index f3f9e39..3fc2d01 100644 --- a/automation-api/yival_experiments/custom_configuration/gpt4_evaluator_config.py +++ b/automation-api/yival_experiments/custom_configuration/gpt4_evaluator_config.py @@ -1,5 +1,6 @@ from dataclasses import asdict, dataclass, field from typing import Any, Dict, List, Optional, Union + from yival.schemas.evaluator_config import EvaluatorConfig, EvaluatorType diff --git a/automation-api/yival_experiments/custom_configuration/llms/alibaba_complete.py b/automation-api/yival_experiments/custom_configuration/llms/alibaba_complete.py index 44c99e3..9156130 100644 --- a/automation-api/yival_experiments/custom_configuration/llms/alibaba_complete.py +++ b/automation-api/yival_experiments/custom_configuration/llms/alibaba_complete.py @@ -1,16 +1,18 @@ # encoding: utf-8 +import random +from http import HTTPStatus + +import dashscope +from dashscope import Generation from tenacity import ( retry, retry_if_exception_type, retry_if_not_result, stop_after_attempt, ) -from http import HTTPStatus -import dashscope -from dashscope import Generation + from lib.config import read_config -import random def response_is_ok(response): diff --git a/automation-api/yival_experiments/custom_configuration/model_compare.py b/automation-api/yival_experiments/custom_configuration/model_compare.py index 5e07b89..d36e4b8 100644 --- a/automation-api/yival_experiments/custom_configuration/model_compare.py +++ b/automation-api/yival_experiments/custom_configuration/model_compare.py @@ -1,13 +1,13 @@ +import litellm +from litellm import completion +from llms.alibaba_complete import llm_complete as alibaba_llm_complete +from llms.palm_completion import safety_settings +from model_config_wrapper import ModelConfigWrapper from yival.logger.token_logger import TokenLogger from yival.schemas.experiment_config import MultimodalOutput from yival.schemas.model_configs import Response from yival.states.experiment_state import ExperimentState from yival.wrappers.string_wrapper import StringWrapper -from model_config_wrapper import ModelConfigWrapper -from llms.alibaba_complete import llm_complete as alibaba_llm_complete -from llms.palm_completion import safety_settings -import litellm -from litellm import completion # load env vars from lib.config import read_config diff --git a/automation-api/yival_experiments/custom_configuration/model_config_variation_generator.py b/automation-api/yival_experiments/custom_configuration/model_config_variation_generator.py index 2c93131..f708a6a 100644 --- a/automation-api/yival_experiments/custom_configuration/model_config_variation_generator.py +++ b/automation-api/yival_experiments/custom_configuration/model_config_variation_generator.py @@ -1,13 +1,12 @@ from dataclasses import asdict, dataclass, field from typing import Any, Iterator, List, Optional +from model_config_variation_generator_config import ModelConfigVariationGeneratorConfig + # from yival.schemas.experiment_config import WrapperVariation # ^ this is not working for dict so I write my own version - from yival.variation_generators.base_variation_generator import BaseVariationGenerator -from model_config_variation_generator_config import ModelConfigVariationGeneratorConfig - @dataclass class WrapperVariation: diff --git a/automation-api/yival_experiments/custom_configuration/model_config_variation_generator_config.py b/automation-api/yival_experiments/custom_configuration/model_config_variation_generator_config.py index eed4ffb..7369f2b 100644 --- a/automation-api/yival_experiments/custom_configuration/model_config_variation_generator_config.py +++ b/automation-api/yival_experiments/custom_configuration/model_config_variation_generator_config.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -from yival.schemas.varation_generator_configs import BaseVariationGeneratorConfig +from typing import Any, Dict, List, Optional -from typing import Optional, List, Dict, Any +from yival.schemas.varation_generator_configs import BaseVariationGeneratorConfig @dataclass diff --git a/automation-api/yival_experiments/custom_configuration/model_config_wrapper.py b/automation-api/yival_experiments/custom_configuration/model_config_wrapper.py index b84dd16..239ce79 100644 --- a/automation-api/yival_experiments/custom_configuration/model_config_wrapper.py +++ b/automation-api/yival_experiments/custom_configuration/model_config_wrapper.py @@ -1,8 +1,8 @@ -from typing import Optional, Dict, Any +from typing import Any, Dict, Optional from model_config_wrapper_config import ModelConfigWrapperConfig -from yival.wrappers.base_wrapper import BaseWrapper from yival.experiment.experiment_runner import ExperimentState +from yival.wrappers.base_wrapper import BaseWrapper class ModelConfigWrapper(BaseWrapper): diff --git a/automation-api/yival_experiments/custom_configuration/question_reader.py b/automation-api/yival_experiments/custom_configuration/question_reader.py index 57a916b..0561c2a 100644 --- a/automation-api/yival_experiments/custom_configuration/question_reader.py +++ b/automation-api/yival_experiments/custom_configuration/question_reader.py @@ -4,7 +4,7 @@ from yival.data.base_reader import BaseReader from yival.schemas.common_structures import InputData -from lib.pilot.helpers import read_ai_eval_spreadsheet, get_questions +from lib.pilot.helpers import get_questions, read_ai_eval_spreadsheet class QuestionReader(BaseReader): diff --git a/automation-api/yival_experiments/custom_configuration/question_reader_config.py b/automation-api/yival_experiments/custom_configuration/question_reader_config.py index f5f4922..a27c9a7 100644 --- a/automation-api/yival_experiments/custom_configuration/question_reader_config.py +++ b/automation-api/yival_experiments/custom_configuration/question_reader_config.py @@ -1,4 +1,5 @@ from dataclasses import asdict, dataclass + from yival.data.base_reader import BaseReaderConfig diff --git a/automation-api/yival_experiments/scripts/fetch_questions.py b/automation-api/yival_experiments/scripts/fetch_questions.py index 14a5c25..4fe2d6a 100644 --- a/automation-api/yival_experiments/scripts/fetch_questions.py +++ b/automation-api/yival_experiments/scripts/fetch_questions.py @@ -1,6 +1,6 @@ import pandas as pd -from lib.pilot.helpers import read_ai_eval_spreadsheet, get_questions +from lib.pilot.helpers import get_questions, read_ai_eval_spreadsheet correctness_map = {1: "Correct", 2: "Wrong", 3: "Very Wrong"} output_file = "../data/questions.csv" diff --git a/automation-api/yival_experiments/scripts/generate_experiment_config.py b/automation-api/yival_experiments/scripts/generate_experiment_config.py index 68a78ca..1ae214b 100644 --- a/automation-api/yival_experiments/scripts/generate_experiment_config.py +++ b/automation-api/yival_experiments/scripts/generate_experiment_config.py @@ -1,15 +1,17 @@ import os from datetime import datetime +from typing import Any, Dict + import yaml + +from lib.ai_eval_spreadsheet.wrapper import AiEvalData from lib.pilot.helpers import ( - read_ai_eval_spreadsheet, get_metrics, get_model_configs, get_prompt_variants, load_model_parameters, + read_ai_eval_spreadsheet, ) -from lib.ai_eval_spreadsheet.wrapper import AiEvalData -from typing import Dict, Any # to make pyyaml's dumper generate good looking strings diff --git a/automation-api/yival_experiments/scripts/generate_result.py b/automation-api/yival_experiments/scripts/generate_result.py index 5098cca..8dd9814 100644 --- a/automation-api/yival_experiments/scripts/generate_result.py +++ b/automation-api/yival_experiments/scripts/generate_result.py @@ -1,8 +1,8 @@ import os.path as osp -from glob import glob -import pandas as pd import pickle +from glob import glob +import pandas as pd from yival.experiment.experiment_runner import Experiment # all Yival experiment results are exported into pickle files.