Skip to content

Commit 4bfd0c5

Browse files
committed
Cleanup package build
1 parent f3d7808 commit 4bfd0c5

31 files changed

+60
-64
lines changed

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ benchmark:
215215
stage: benchmark
216216
interruptible: true
217217
script:
218-
- python src/dbally_benchmark/evaluate.py neptune.log=True
218+
- PYTHONPATH=benchmark/ python benchmark/dbally_benchmark/evaluate.py neptune.log=True
219219
rules:
220220
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
221221
when: manual
File renamed without changes.

src/dbally_benchmark/config.py benchmark/dbally_benchmark/config.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from pydantic.v1 import BaseSettings
2-
31
from dbally_benchmark.paths import PATH_PACKAGE
2+
from pydantic.v1 import BaseSettings
43

54

65
class BenchmarkConfig(BaseSettings):

src/dbally_benchmark/constants.py benchmark/dbally_benchmark/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from enum import Enum
22
from typing import Dict, Type
33

4-
from dbally.views.sqlalchemy_base import SqlAlchemyBaseView
54
from dbally_benchmark.views.superhero import SuperheroCountByPowerView, SuperheroView
65

6+
from dbally.views.sqlalchemy_base import SqlAlchemyBaseView
7+
78

89
class ViewName(Enum):
910
"""Enum representing the name of the view."""

src/dbally_benchmark/dataset/bird_dataset.py benchmark/dbally_benchmark/dataset/bird_dataset.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
from pathlib import Path
55
from typing import Iterator
66

7+
from dbally_benchmark.utils import load_data
78
from pydantic import BaseModel, RootModel
89

9-
from dbally_benchmark.io import load_data
10-
1110

1211
class DifficultyLevel(str, enum.Enum):
1312
"""Enum representing BIRD example difficulty level."""

src/dbally_benchmark/e2e_benchmark.py benchmark/dbally_benchmark/e2e_benchmark.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
import hydra
99
import neptune
10+
from dbally_benchmark.config import BenchmarkConfig
11+
from dbally_benchmark.constants import VIEW_REGISTRY, EvaluationType, ViewName
12+
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
13+
from dbally_benchmark.paths import PATH_EXPERIMENTS
14+
from dbally_benchmark.text2sql.metrics import calculate_dataset_metrics
15+
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
16+
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
1017
from hydra.utils import instantiate
1118
from loguru import logger
1219
from neptune.utils import stringify_unsupported
@@ -18,13 +25,6 @@
1825
from dbally.data_models.prompts.iql_prompt_template import default_iql_template
1926
from dbally.data_models.prompts.view_selector_prompt_template import default_view_selector_template
2027
from dbally.utils.errors import NoViewFoundError, UnsupportedQueryError
21-
from dbally_benchmark.config import BenchmarkConfig
22-
from dbally_benchmark.constants import VIEW_REGISTRY, EvaluationType, ViewName
23-
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
24-
from dbally_benchmark.paths import PATH_EXPERIMENTS
25-
from dbally_benchmark.text2sql.metrics import calculate_dataset_metrics
26-
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
27-
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
2828

2929

3030
async def _run_dbally_for_single_example(example: BIRDExample, collection: Collection) -> Text2SQLResult:

src/dbally_benchmark/evaluate.py benchmark/dbally_benchmark/evaluate.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
from typing import Callable, Dict
33

44
import hydra
5-
from omegaconf import DictConfig
6-
75
from dbally_benchmark.constants import EvaluationType
86
from dbally_benchmark.e2e_benchmark import evaluate as e2e_evaluate
97
from dbally_benchmark.iql_benchmark import evaluate as iql_evaluate
108
from dbally_benchmark.text2sql_benchmark import evaluate as text2sql_evaluate
9+
from omegaconf import DictConfig
1110

1211

1312
async def evaluate(cfg: DictConfig) -> None:

src/dbally_benchmark/iql/metrics.py benchmark/dbally_benchmark/iql/metrics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import ast
22
from typing import Dict, List, Tuple
33

4+
from dbally_benchmark.iql.iql_result import IQLResult
5+
from dbally_benchmark.iql.method_call_visitor import MethodCallVisitor
46
from loguru import logger
57

68
from dbally.iql._exceptions import IQLError, IQLUnsupportedSyntaxError
79
from dbally.iql._query import IQLQuery
810
from dbally.views.base import ExposedFunction
9-
from dbally_benchmark.iql.iql_result import IQLResult
10-
from dbally_benchmark.iql.method_call_visitor import MethodCallVisitor
1111

1212

1313
def _count_hallucinated_methods_for_single_example(iql: str, allowed_methods: List[str]) -> Tuple[int, int]:

src/dbally_benchmark/iql_benchmark.py benchmark/dbally_benchmark/iql_benchmark.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
import hydra
88
import neptune
9+
from dbally_benchmark.config import BenchmarkConfig
10+
from dbally_benchmark.constants import VIEW_REGISTRY, EvaluationType, ViewName
11+
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
12+
from dbally_benchmark.iql.iql_result import IQLResult
13+
from dbally_benchmark.iql.metrics import calculate_dataset_metrics
14+
from dbally_benchmark.paths import PATH_EXPERIMENTS
15+
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
916
from hydra.utils import instantiate
1017
from loguru import logger
1118
from neptune.utils import stringify_unsupported
@@ -18,13 +25,6 @@
1825
from dbally.llm_client.openai_client import OpenAIClient
1926
from dbally.utils.errors import UnsupportedQueryError
2027
from dbally.views.base import AbstractBaseView
21-
from dbally_benchmark.config import BenchmarkConfig
22-
from dbally_benchmark.constants import VIEW_REGISTRY, EvaluationType, ViewName
23-
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
24-
from dbally_benchmark.iql.iql_result import IQLResult
25-
from dbally_benchmark.iql.metrics import calculate_dataset_metrics
26-
from dbally_benchmark.paths import PATH_EXPERIMENTS
27-
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
2828

2929

3030
async def _run_iql_for_single_example(
File renamed without changes.

src/dbally_benchmark/text2sql/metrics.py benchmark/dbally_benchmark/text2sql/metrics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from typing import Dict, List
33

44
import pandas as pd
5+
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
6+
from dbally_benchmark.utils import batch
57
from sqlalchemy import Engine, text
68

79
from dbally.data_models.execution_result import ExecutionResult
8-
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
9-
from dbally_benchmark.utils import batch
1010

1111

1212
def _run_query(query: str, engine: Engine) -> ExecutionResult:

src/dbally_benchmark/text2sql_benchmark.py benchmark/dbally_benchmark/text2sql_benchmark.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
import hydra
88
import neptune
9+
from dbally_benchmark.config import BenchmarkConfig
10+
from dbally_benchmark.constants import EvaluationType
11+
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
12+
from dbally_benchmark.paths import PATH_EXPERIMENTS, PATH_SCHEMAS
13+
from dbally_benchmark.text2sql.metrics import calculate_dataset_metrics
14+
from dbally_benchmark.text2sql.prompt_template import TEXT2SQL_PROMPT_TEMPLATE
15+
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
16+
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
917
from hydra.utils import instantiate
1018
from loguru import logger
1119
from neptune.utils import stringify_unsupported
@@ -15,14 +23,6 @@
1523
from dbally.audit.event_tracker import EventTracker
1624
from dbally.llm_client.base import LLMClient
1725
from dbally.llm_client.openai_client import OpenAIClient
18-
from dbally_benchmark.config import BenchmarkConfig
19-
from dbally_benchmark.constants import EvaluationType
20-
from dbally_benchmark.dataset.bird_dataset import BIRDDataset, BIRDExample
21-
from dbally_benchmark.paths import PATH_EXPERIMENTS, PATH_SCHEMAS
22-
from dbally_benchmark.text2sql.metrics import calculate_dataset_metrics
23-
from dbally_benchmark.text2sql.prompt_template import TEXT2SQL_PROMPT_TEMPLATE
24-
from dbally_benchmark.text2sql.text2sql_result import Text2SQLResult
25-
from dbally_benchmark.utils import batch, get_datetime_str, set_up_gitlab_metadata
2626

2727

2828
def _load_db_schema(db_name: str, encoding: Optional[str] = None) -> str:

src/dbally_benchmark/utils.py benchmark/dbally_benchmark/utils.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
import os
22
from datetime import datetime
3-
from typing import Any, Iterator
3+
from pathlib import Path
4+
from typing import Any, Iterator, Optional, Union
45

56
from neptune.metadata_containers import Run
67

78

9+
def load_data(
10+
file_path: Union[str, Path],
11+
encoding: Optional[str] = None,
12+
) -> str:
13+
"""
14+
Load data from a file.
15+
16+
Args:
17+
file_path: Path of the data.
18+
encoding: Encoding of the input file.
19+
20+
Returns:
21+
String read from the file.
22+
"""
23+
24+
with open(file_path, encoding=encoding) as file_handle:
25+
return file_handle.read()
26+
27+
828
def get_datetime_str() -> str:
929
"""
1030
Obtain a string representing current datetime.

src/dbally_benchmark/views/superhero.py benchmark/dbally_benchmark/views/superhero.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# pylint: disable=missing-docstring, missing-return-doc, missing-param-doc
22

33
import sqlalchemy
4+
from dbally_benchmark.config import config
45
from sqlalchemy import create_engine
56
from sqlalchemy.dialects.postgresql import ARRAY
67
from sqlalchemy.ext.automap import automap_base
78
from sqlalchemy.orm import aliased
89

910
from dbally import SqlAlchemyBaseView, decorators
10-
from dbally_benchmark.config import config
1111

1212
engine = create_engine(config.pg_connection_string + "/superhero")
1313
SuperheroModel = automap_base()

tests/unit/benchmark/test_iql_metrics.py benchmark/tests/unit/test_iql_metrics.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from dbally.views.base import ExposedFunction, MethodParamWithTyping
21
from dbally_benchmark.iql.iql_result import IQLResult
32
from dbally_benchmark.iql.metrics import (
43
_count_hallucinated_methods_for_single_example,
@@ -7,6 +6,8 @@
76
calculate_valid_iql,
87
)
98

9+
from dbally.views.base import ExposedFunction, MethodParamWithTyping
10+
1011
ALLOWED_METHODS = [
1112
ExposedFunction(
1213
name="filter_by_name",

tests/unit/benchmark/test_main_evaluate.py benchmark/tests/unit/test_main_evaluate.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from unittest.mock import call, patch
22

33
import pytest
4-
from omegaconf import DictConfig
5-
64
from dbally_benchmark.evaluate import evaluate
5+
from omegaconf import DictConfig
76

87

98
@patch("dbally_benchmark.evaluate.e2e_evaluate")

tests/unit/benchmark/test_method_call_visitor.py benchmark/tests/unit/test_method_call_visitor.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ast
22

33
import pytest
4-
54
from dbally_benchmark.iql.method_call_visitor import MethodCallVisitor
65

76

docker/tests/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN python -m pip install --no-cache-dir --upgrade pip
66
COPY pyproject.toml setup.cfg requirements-dev.txt check_licenses.sh ./
77
COPY src/ src/
88
COPY data/ data/
9+
COPY benchmark/ benchmark/
910

1011
RUN pip install build twine bump2version wheel==0.41.3
1112
RUN pip install --no-cache-dir --upgrade -e .[benchmark]

src/dbally/examples/recruiting.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
from dataclasses import dataclass
33
from typing import List
44

5+
from dbally_benchmark.text2sql.prompt_template import TEXT2SQL_PROMPT_TEMPLATE
6+
57
import dbally
68
from dbally.audit.event_handlers.cli_event_handler import CLIEventHandler
79
from dbally.audit.event_tracker import EventTracker
810
from dbally.examples.db import ENGINE, fill_candidate_table, get_recruitment_db_description
911
from dbally.examples.views import RecruitmentView
1012
from dbally.llm_client.openai_client import OpenAIClient
11-
from dbally_benchmark.text2sql.prompt_template import TEXT2SQL_PROMPT_TEMPLATE
1213

1314

1415
@dataclass

src/dbally_benchmark/io.py

-21
This file was deleted.

tests/__init__.py

Whitespace-only changes.

tests/test_dbally.py

-2
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)