From 969c02b081436da7f374204d528c75fe9e95d752 Mon Sep 17 00:00:00 2001 From: Madeesh Kannan Date: Fri, 9 Feb 2024 17:48:47 +0100 Subject: [PATCH] refactor!: Standardize namespace and add CI for API docs (#387) --- integrations/uptrain/example/example.py | 2 +- integrations/uptrain/pydoc/config.yml | 30 +++++++++++++++++++ integrations/uptrain/pyproject.toml | 3 +- .../components/evaluators/__init__.py | 7 ----- .../components/evaluators/uptrain/__init__.py | 7 +++++ .../evaluator.py} | 8 +++-- .../metrics.py} | 2 +- integrations/uptrain/tests/test_evaluator.py | 2 +- integrations/uptrain/tests/test_metrics.py | 2 +- 9 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 integrations/uptrain/pydoc/config.yml delete mode 100644 integrations/uptrain/src/haystack_integrations/components/evaluators/__init__.py create mode 100644 integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/__init__.py rename integrations/uptrain/src/haystack_integrations/components/evaluators/{uptrain_evaluator.py => uptrain/evaluator.py} (98%) rename integrations/uptrain/src/haystack_integrations/components/evaluators/{uptrain_metrics.py => uptrain/metrics.py} (99%) diff --git a/integrations/uptrain/example/example.py b/integrations/uptrain/example/example.py index fe332548d..36387b06c 100644 --- a/integrations/uptrain/example/example.py +++ b/integrations/uptrain/example/example.py @@ -1,7 +1,7 @@ # A valid OpenAI API key is required to run this example. from haystack import Pipeline -from haystack_integrations.components.evaluators import UpTrainEvaluator, UpTrainMetric +from haystack_integrations.components.evaluators.uptrain import UpTrainEvaluator, UpTrainMetric from haystack.utils import Secret QUESTIONS = [ diff --git a/integrations/uptrain/pydoc/config.yml b/integrations/uptrain/pydoc/config.yml new file mode 100644 index 000000000..c2e7f8da0 --- /dev/null +++ b/integrations/uptrain/pydoc/config.yml @@ -0,0 +1,30 @@ +loaders: + - type: haystack_pydoc_tools.loaders.CustomPythonLoader + search_path: [../src] + modules: + [ + "haystack_integrations.components.evaluators.uptrain.evaluator", + "haystack_integrations.components.evaluators.uptrain.metrics", + ] + ignore_when_discovered: ["__init__"] +processors: + - type: filter + expression: + documented_only: true + do_not_filter_modules: false + skip_empty_modules: true + - type: smart + - type: crossref +renderer: + type: haystack_pydoc_tools.renderers.ReadmePreviewRenderer + excerpt: UpTrain integration for Haystack + category_slug: haystack-integrations + title: UpTrain + slug: integrations-uptrain + order: 1 + markdown: + descriptive_class_title: false + descriptive_module_title: true + add_method_class_prefix: true + add_member_class_prefix: false + filename: _readme_uptrain.md diff --git a/integrations/uptrain/pyproject.toml b/integrations/uptrain/pyproject.toml index d86d12bd1..a7b434acb 100644 --- a/integrations/uptrain/pyproject.toml +++ b/integrations/uptrain/pyproject.toml @@ -40,12 +40,13 @@ root = "../.." git_describe_command = 'git describe --tags --match="integrations/uptrain-v[0-9]*"' [tool.hatch.envs.default] -dependencies = ["coverage[toml]>=6.5", "pytest"] +dependencies = ["coverage[toml]>=6.5", "pytest", "haystack-pydoc-tools"] [tool.hatch.envs.default.scripts] test = "pytest {args:tests}" test-cov = "coverage run -m pytest {args:tests}" cov-report = ["- coverage combine", "coverage report"] cov = ["test-cov", "cov-report"] +docs = ["pydoc-markdown pydoc/config.yml"] [[tool.hatch.envs.all.matrix]] python = ["3.8", "3.9", "3.10", "3.11"] diff --git a/integrations/uptrain/src/haystack_integrations/components/evaluators/__init__.py b/integrations/uptrain/src/haystack_integrations/components/evaluators/__init__.py deleted file mode 100644 index b9a3d231f..000000000 --- a/integrations/uptrain/src/haystack_integrations/components/evaluators/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .uptrain_evaluator import UpTrainEvaluator -from .uptrain_metrics import UpTrainMetric - -__all__ = ( - "UpTrainEvaluator", - "UpTrainMetric", -) diff --git a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/__init__.py b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/__init__.py new file mode 100644 index 000000000..e8366dfc0 --- /dev/null +++ b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/__init__.py @@ -0,0 +1,7 @@ +from .evaluator import UpTrainEvaluator +from .metrics import UpTrainMetric + +__all__ = ( + "UpTrainEvaluator", + "UpTrainMetric", +) diff --git a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_evaluator.py b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py similarity index 98% rename from integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_evaluator.py rename to integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py index f9a9b863c..4e7307602 100644 --- a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_evaluator.py +++ b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py @@ -3,14 +3,16 @@ from haystack import DeserializationError, component, default_from_dict, default_to_dict from haystack.utils import Secret, deserialize_secrets_inplace -from haystack_integrations.components.evaluators.uptrain_metrics import ( + +from uptrain import APIClient, EvalLLM, Evals # type: ignore +from uptrain.framework.evals import ParametricEval + +from .metrics import ( METRIC_DESCRIPTORS, InputConverters, OutputConverters, UpTrainMetric, ) -from uptrain import APIClient, EvalLLM, Evals -from uptrain.framework.evals import ParametricEval @component diff --git a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_metrics.py b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/metrics.py similarity index 99% rename from integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_metrics.py rename to integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/metrics.py index 1020f391e..6f7854aee 100644 --- a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain_metrics.py +++ b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/metrics.py @@ -5,7 +5,7 @@ from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Type, Union -from uptrain import CritiqueTone, Evals, GuidelineAdherence, ResponseMatching +from uptrain import CritiqueTone, Evals, GuidelineAdherence, ResponseMatching # type: ignore from uptrain.framework.evals import ParametricEval diff --git a/integrations/uptrain/tests/test_evaluator.py b/integrations/uptrain/tests/test_evaluator.py index 829734708..0f2eaba4d 100644 --- a/integrations/uptrain/tests/test_evaluator.py +++ b/integrations/uptrain/tests/test_evaluator.py @@ -7,7 +7,7 @@ import pytest from haystack import DeserializationError -from haystack_integrations.components.evaluators import UpTrainEvaluator, UpTrainMetric +from haystack_integrations.components.evaluators.uptrain import UpTrainEvaluator, UpTrainMetric from haystack.utils import Secret DEFAULT_QUESTIONS = [ diff --git a/integrations/uptrain/tests/test_metrics.py b/integrations/uptrain/tests/test_metrics.py index b73b2aa92..805c82fbf 100644 --- a/integrations/uptrain/tests/test_metrics.py +++ b/integrations/uptrain/tests/test_metrics.py @@ -1,6 +1,6 @@ import pytest -from haystack_integrations.components.evaluators import UpTrainMetric +from haystack_integrations.components.evaluators.uptrain import UpTrainMetric def test_uptrain_metric():