Skip to content

Commit 5329d72

Browse files
Fix pyright type errors in project_multi_tenant example
- Cast row.prompt to str for pandas Scalar type in enriched_products - Use Callable from collections.abc instead of builtin callable in io_managers - Add ... body to Protocol methods in SupportsGenerate - Use getattr loop instead of direct attribute access in test helper - Add None guard before str `in` operator on skip_message Made-with: Cursor
1 parent 7e80854 commit 5329d72

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

examples/project_multi_tenant/harbor_outfitters/assets/gold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def enriched_products(
1616
context.add_output_metadata(llm.runtime_metadata())
1717
rows: list[dict[str, object]] = []
1818
for row in catalog_prompt_inputs.itertuples(index=False):
19-
response = llm.generate(row.prompt)
19+
response = llm.generate(str(row.prompt))
2020
rows.append(
2121
{
2222
"product_id": row.product_id,

examples/project_multi_tenant/shared/io_managers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import time
4+
from collections.abc import Callable
45
from pathlib import Path
56

67
import dagster as dg
@@ -53,7 +54,7 @@ def _load_table(self, table_name: str) -> pd.DataFrame:
5354
with duckdb.connect(self.database) as connection:
5455
return connection.execute(f"select * from {self.db_schema}.{table_name}").fetch_df()
5556

56-
def _with_retry(self, fn: callable, *, action: str):
57+
def _with_retry(self, fn: Callable, *, action: str):
5758
last_error: Exception | None = None
5859
for attempt in range(1, self.retry_attempts + 1):
5960
try:

examples/project_multi_tenant/shared/resources.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
class SupportsGenerate(Protocol):
1616
def generate(self, prompt: str) -> str:
1717
"""Generate a text response for the provided prompt."""
18+
...
1819

1920
def runtime_metadata(self) -> dict[str, object]:
2021
"""Return metadata describing the active model runtime."""
22+
...
2123

2224

2325
class BaseLLMResource(dg.ConfigurableResource):

examples/project_multi_tenant/tests/test_beacon_hq.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ def _build_success_context(
5858
def _get_run_success_event(
5959
result: dg.ExecuteInProcessResult,
6060
) -> dg.DagsterEvent:
61-
if hasattr(result, "get_run_success_event"):
62-
return result.get_run_success_event()
63-
64-
if hasattr(result, "get_job_success_event"):
65-
return result.get_job_success_event()
61+
for method_name in ("get_run_success_event", "get_job_success_event"):
62+
getter = getattr(result, method_name, None)
63+
if getter is not None:
64+
return getter()
6665

6766
for event in reversed(result.all_events):
6867
if getattr(event, "event_type_value", "") == "PIPELINE_SUCCESS":
@@ -113,6 +112,7 @@ def test_beacon_sensor_waits_for_missing_upstream_job() -> None:
113112
response = beacon_after_upstream_success_sensor(_build_success_context(instance, harbor_result))
114113

115114
assert isinstance(response, dg.SkipReason)
115+
assert response.skip_message is not None
116116
assert "summit_risk_scoring_job" in response.skip_message
117117

118118

0 commit comments

Comments
 (0)