From 5a6541e206e787203110a2d050ac3bf3169f1d3e Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 06:02:29 -0500 Subject: [PATCH 01/13] test --- pyproject.toml | 1 - weave/trace/cli.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52cd63e4fddd..2fc278bcd24e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -206,7 +206,6 @@ reportAssignmentType = false reportInconsistentOverload = false reportTypedDictNotRequiredAccess = false reportOptionalSubscript = false -reportFunctionMemberAccess = false [tool.mypy] warn_unused_configs = true diff --git a/weave/trace/cli.py b/weave/trace/cli.py index 53fcc774f2e5..d8300d9fd51e 100644 --- a/weave/trace/cli.py +++ b/weave/trace/cli.py @@ -18,7 +18,7 @@ def cli() -> None: pass -@cli.command(help="Serve weave models.") +@cli.command(help="Serve weave models.") # type: ignore @click.argument("model_ref") @click.option("--method", help="Method name to serve.") @click.option("--project", help="W&B project name.") @@ -54,7 +54,7 @@ def serve( ) -@cli.group(help="Deploy weave models.") +@cli.group(help="Deploy weave models.") # type: ignore def deploy() -> None: pass From e3453ac0911716882ebda860a506acb992d23b8d Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 06:20:55 -0500 Subject: [PATCH 02/13] test --- weave/trace/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weave/trace/cli.py b/weave/trace/cli.py index d8300d9fd51e..7a1c3709d327 100644 --- a/weave/trace/cli.py +++ b/weave/trace/cli.py @@ -18,7 +18,7 @@ def cli() -> None: pass -@cli.command(help="Serve weave models.") # type: ignore +@cli.command(help="Serve weave models.") # pyright: ignore[reportFunctionMemberAccess] @click.argument("model_ref") @click.option("--method", help="Method name to serve.") @click.option("--project", help="W&B project name.") @@ -54,7 +54,7 @@ def serve( ) -@cli.group(help="Deploy weave models.") # type: ignore +@cli.group(help="Deploy weave models.") # pyright: ignore[reportFunctionMemberAccess] def deploy() -> None: pass From ffe5f9710969e15b971d24cddb6e7d43b5dcdf80 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 06:04:59 -0500 Subject: [PATCH 03/13] test --- pyproject.toml | 1 - weave/integrations/instructor/instructor_iterable_utils.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2fc278bcd24e..ed3dfc3e3335 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -205,7 +205,6 @@ reportOperatorIssue = false reportAssignmentType = false reportInconsistentOverload = false reportTypedDictNotRequiredAccess = false -reportOptionalSubscript = false [tool.mypy] warn_unused_configs = true diff --git a/weave/integrations/instructor/instructor_iterable_utils.py b/weave/integrations/instructor/instructor_iterable_utils.py index 879181709fec..8287cb2c0d1b 100644 --- a/weave/integrations/instructor/instructor_iterable_utils.py +++ b/weave/integrations/instructor/instructor_iterable_utils.py @@ -8,10 +8,10 @@ def instructor_iterable_accumulator( - acc: Optional[BaseModel], value: BaseModel + acc: Optional[list[BaseModel]], value: BaseModel ) -> list[BaseModel]: if acc is None: - acc = [value] + return [value] if acc[-1] != value: acc.append(value) return acc From 9e3dd6a2d22aeaa4869668befa917e33b8f1c2e4 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 06:15:42 -0500 Subject: [PATCH 04/13] test --- .pre-commit-config.yaml | 2 ++ pyproject.toml | 1 - weave/flow/obj.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 385644f9dd84..fb837f5e0200 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,8 @@ repos: rev: v1.1.387 hooks: - id: pyright + additional_dependencies: + - pydantic # This is legacy Weave when we were building a notebook product - should be removed - repo: local diff --git a/pyproject.toml b/pyproject.toml index ed3dfc3e3335..8dc049fd99ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -204,7 +204,6 @@ reportIndexIssue = false reportOperatorIssue = false reportAssignmentType = false reportInconsistentOverload = false -reportTypedDictNotRequiredAccess = false [tool.mypy] warn_unused_configs = true diff --git a/weave/flow/obj.py b/weave/flow/obj.py index b59067608d3c..64e078b36bcf 100644 --- a/weave/flow/obj.py +++ b/weave/flow/obj.py @@ -73,7 +73,7 @@ def handle_relocatable_object( # pydantic validation will construct a new pydantic object def is_ignored_type(v: type) -> bool: - return isinstance(v, cls.model_config["ignored_types"]) + return isinstance(v, cls.model_config["ignored_types"]) # pyright: ignore[reportTypedDictNotRequiredAccess] allowed_fields = {k: v for k, v in fields.items() if not is_ignored_type(v)} new_obj = handler(allowed_fields) From 70fc4a66f0d5fb80a101fcd4a34741ca2237b151 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 09:55:48 -0500 Subject: [PATCH 05/13] test --- .pre-commit-config.yaml | 3 +-- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb837f5e0200..5afb89ca97d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,8 +24,7 @@ repos: rev: v1.1.387 hooks: - id: pyright - additional_dependencies: - - pydantic + additional_dependencies: [".[tests]"] # This is legacy Weave when we were building a notebook product - should be removed - repo: local diff --git a/pyproject.toml b/pyproject.toml index 8dc049fd99ef..44ab71ef49ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,7 +200,6 @@ reportGeneralTypeIssues = false reportCallIssue = false reportIncompatibleMethodOverride = false reportRedeclaration = false -reportIndexIssue = false reportOperatorIssue = false reportAssignmentType = false reportInconsistentOverload = false From 47fe58b152834e9d7e47ec4614602ef594378f7c Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 09:56:41 -0500 Subject: [PATCH 06/13] test --- weave/flow/obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave/flow/obj.py b/weave/flow/obj.py index 64e078b36bcf..b59067608d3c 100644 --- a/weave/flow/obj.py +++ b/weave/flow/obj.py @@ -73,7 +73,7 @@ def handle_relocatable_object( # pydantic validation will construct a new pydantic object def is_ignored_type(v: type) -> bool: - return isinstance(v, cls.model_config["ignored_types"]) # pyright: ignore[reportTypedDictNotRequiredAccess] + return isinstance(v, cls.model_config["ignored_types"]) allowed_fields = {k: v for k, v in fields.items() if not is_ignored_type(v)} new_obj = handler(allowed_fields) From 8b652cd60dc1003c24324ef86081deac97548f63 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:00:32 -0500 Subject: [PATCH 07/13] test --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 44ab71ef49ca..104df713812e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,14 +193,11 @@ reportMissingImports = false reportAttributeAccessIssue = false reportPossiblyUnboundVariable = false reportOptionalMemberAccess = false -reportPrivateImportUsage = false reportArgumentType = false reportReturnType = false -reportGeneralTypeIssues = false reportCallIssue = false reportIncompatibleMethodOverride = false reportRedeclaration = false -reportOperatorIssue = false reportAssignmentType = false reportInconsistentOverload = false From 070004132e0f6144be6c1e812380dda091124da2 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:02:28 -0500 Subject: [PATCH 08/13] test --- pyproject.toml | 1 - weave/integrations/langchain/langchain.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 104df713812e..d1868a5c7ce9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -198,7 +198,6 @@ reportReturnType = false reportCallIssue = false reportIncompatibleMethodOverride = false reportRedeclaration = false -reportAssignmentType = false reportInconsistentOverload = false [tool.mypy] diff --git a/weave/integrations/langchain/langchain.py b/weave/integrations/langchain/langchain.py index 508bb70de8fc..8dd184e79af2 100644 --- a/weave/integrations/langchain/langchain.py +++ b/weave/integrations/langchain/langchain.py @@ -55,7 +55,7 @@ except ImportError: import_failed = True -from typing import Any, Dict, Generator, List, Optional +from typing import Any, Dict, Generator, List, Optional, cast RUNNABLE_SEQUENCE_NAME = "RunnableSequence" @@ -182,7 +182,9 @@ def _persist_run_single(self, run: Run) -> None: # Note: this is implemented as a network call - it would be much nice # to refactor `create_call` such that it could accept a parent_id instead # of an entire Parent object. - parent_run = self.gc.get_call(wv_current_run.parent_id) + parent_run = cast( + Call, self.gc.get_call(wv_current_run.parent_id) + ) fn_name = make_pythonic_function_name(run.name) complete_op_name = f"langchain.{run.run_type.capitalize()}.{fn_name}" From 0763695f706f04f18693fa6def40a10329466acf Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:04:20 -0500 Subject: [PATCH 09/13] test --- pyproject.toml | 1 - weave/flow/prompt/prompt.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d1868a5c7ce9..ae4610120bf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -198,7 +198,6 @@ reportReturnType = false reportCallIssue = false reportIncompatibleMethodOverride = false reportRedeclaration = false -reportInconsistentOverload = false [tool.mypy] warn_unused_configs = true diff --git a/weave/flow/prompt/prompt.py b/weave/flow/prompt/prompt.py index 016e9d3f9962..a26e91c6fdce 100644 --- a/weave/flow/prompt/prompt.py +++ b/weave/flow/prompt/prompt.py @@ -242,7 +242,7 @@ def bind_rows(self, dataset: Union[list[dict], Any]) -> list["Prompt"]: return bound @overload - def __getitem__(self, index: SupportsIndex) -> Any: ... + def __getitem__(self, key: SupportsIndex) -> Any: ... @overload def __getitem__(self, key: slice) -> "EasyPrompt": ... From be479cec27abe8235c8990a3ef538a1af6dc918d Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:07:26 -0500 Subject: [PATCH 10/13] test --- pyproject.toml | 1 - weave/integrations/notdiamond/custom_router.py | 1 + weave/scorers/base_scorer.py | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ae4610120bf6..58dd68b975a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -196,7 +196,6 @@ reportOptionalMemberAccess = false reportArgumentType = false reportReturnType = false reportCallIssue = false -reportIncompatibleMethodOverride = false reportRedeclaration = false [tool.mypy] diff --git a/weave/integrations/notdiamond/custom_router.py b/weave/integrations/notdiamond/custom_router.py index 03d234e5dda4..cc5477915c2f 100644 --- a/weave/integrations/notdiamond/custom_router.py +++ b/weave/integrations/notdiamond/custom_router.py @@ -83,6 +83,7 @@ def _get_model_results(provider_name: str) -> pd.DataFrame: class _DummyEvalModel(weave.Model): model_results: pd.DataFrame + @weave.op() def predict(self, prompt: str) -> Dict[str, Any]: response, score = self.model_results[ self.model_results[prompt_column] == prompt diff --git a/weave/scorers/base_scorer.py b/weave/scorers/base_scorer.py index 080149af0aa1..650c1d3d2e02 100644 --- a/weave/scorers/base_scorer.py +++ b/weave/scorers/base_scorer.py @@ -18,6 +18,7 @@ class Scorer(Object): description="A mapping from column names in the dataset to the names expected by the scorer", ) + @weave.op def score(self, *, output: Any, **kwargs: Any) -> Any: raise NotImplementedError From 024c0e0a3a1abc38b72fccd4f4fbece1d6033966 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:24:30 -0500 Subject: [PATCH 11/13] test --- weave/scorers/base_scorer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/weave/scorers/base_scorer.py b/weave/scorers/base_scorer.py index 650c1d3d2e02..1934ef59f997 100644 --- a/weave/scorers/base_scorer.py +++ b/weave/scorers/base_scorer.py @@ -88,6 +88,7 @@ def auto_summarize(data: list) -> Optional[dict[str, Any]]: def get_scorer_attributes( scorer: Union[Callable, Op, Scorer], ) -> Tuple[str, Callable, Callable]: + score_fn: Union[Op, Callable[..., Any]] if weave_isinstance(scorer, Scorer): scorer_name = scorer.name if scorer_name is None: From beb4b76fbb658d4029f63015cd83764d2b82b5fb Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:09:12 -0500 Subject: [PATCH 12/13] test --- pyproject.toml | 1 - weave/trace/weave_client.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 58dd68b975a5..d1783ad5cb9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -194,7 +194,6 @@ reportAttributeAccessIssue = false reportPossiblyUnboundVariable = false reportOptionalMemberAccess = false reportArgumentType = false -reportReturnType = false reportCallIssue = false reportRedeclaration = false diff --git a/weave/trace/weave_client.py b/weave/trace/weave_client.py index 0a3d4ad514e9..f1636a15829b 100644 --- a/weave/trace/weave_client.py +++ b/weave/trace/weave_client.py @@ -267,7 +267,8 @@ def children(self) -> "CallsIter": def delete(self) -> bool: """Delete the call.""" client = weave_client_context.require_weave_client() - return client.delete_call(call=self) + client.delete_call(call=self) + return True def set_display_name(self, name: Optional[str]) -> None: """ From 6d8473eaaec2f67458fecac6dd63c937acad2b15 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 5 Nov 2024 10:13:34 -0500 Subject: [PATCH 13/13] test --- pyproject.toml | 1 - weave/integrations/langchain/langchain.py | 2 +- weave/integrations/llamaindex/llamaindex.py | 2 +- weave/trace/op.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d1783ad5cb9e..b89d442888f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -195,7 +195,6 @@ reportPossiblyUnboundVariable = false reportOptionalMemberAccess = false reportArgumentType = false reportCallIssue = false -reportRedeclaration = false [tool.mypy] warn_unused_configs = true diff --git a/weave/integrations/langchain/langchain.py b/weave/integrations/langchain/langchain.py index 8dd184e79af2..ea291a5d956a 100644 --- a/weave/integrations/langchain/langchain.py +++ b/weave/integrations/langchain/langchain.py @@ -89,7 +89,7 @@ def _run_to_dict(run: Run, as_input: bool = False) -> dict: run_dict = {k: v for k, v in run_dict.items() if v} return run_dict - class WeaveTracer(BaseTracer): + class WeaveTracer(BaseTracer): # pyright: ignore[reportRedeclaration] run_inline: bool = True def __init__(self, **kwargs: Any) -> None: diff --git a/weave/integrations/llamaindex/llamaindex.py b/weave/integrations/llamaindex/llamaindex.py index 4abadb6cb7aa..0427dfb2dccc 100644 --- a/weave/integrations/llamaindex/llamaindex.py +++ b/weave/integrations/llamaindex/llamaindex.py @@ -25,7 +25,7 @@ if not import_failed: - class WeaveCallbackHandler(BaseCallbackHandler): + class WeaveCallbackHandler(BaseCallbackHandler): # pyright: ignore[reportRedeclaration] """Base callback handler that can be used to track event starts and ends.""" def __init__( diff --git a/weave/trace/op.py b/weave/trace/op.py index ae85d65e7b83..94d072ed3264 100644 --- a/weave/trace/op.py +++ b/weave/trace/op.py @@ -611,7 +611,7 @@ def create_wrapper(func: Callable) -> Op: if is_async: @wraps(func) - async def wrapper(*args: Any, **kwargs: Any) -> Any: + async def wrapper(*args: Any, **kwargs: Any) -> Any: # pyright: ignore[reportRedeclaration] res, _ = await _do_call_async( cast(Op, wrapper), *args, __should_raise=True, **kwargs )