[Bug] `SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH` warns on import of the workflow itself to the sandbox
还没有人认领这个 Issue。
评估
调研方向
从 temporalio/worker/workflow_sandbox/_importer.py 中第 323 行附近的警告开始,然后在启用 WARN_ON_UNINTENTIONAL_PASSTHROUGH 的情况下运行 issue 中的最小 worker 复现。跟踪 workflow 模块如何加载到 sandbox 中,并确保加载 workflow 本身不会产生 unintentional-passthrough 警告,同时保持所请求的警告行为不变。
由索引模型根据 Issue 内容生成。
描述
What are you really trying to do?
Leverage SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH to identify imports that aren't intentionally passed through to the sandbox.
Describe the bug
Using a sandboxed runner with the workflows defined in a separate from the worker triggers the unintentional passthrough warning. The workflow must be loaded into the sandbox each time and therefore should be exempt from this warning.
Minimal Reproduction
# workflows.py
from datetime import timedelta
from temporalio import workflow
from warning.activities import echo_activity
@workflow.defn
class ExampleWorkflow:
@workflow.run
async def run(self) -> str:
activity_result = await workflow.execute_activity(
echo_activity,
"example",
task_queue="example-task-queue",
start_to_close_timeout=timedelta(seconds=10),
)
return activity_result
# activities.py
from temporalio import activity
@activity.defn
async def echo_activity(input: str) -> str:
return f"hello {input}"
# worker.py
import asyncio
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker
from temporalio.worker.workflow_sandbox import (
SandboxedWorkflowRunner,
SandboxRestrictions,
)
from temporalio.workflow import SandboxImportNotificationPolicy
from warning.activities import echo_activity
from warning.workflows import ExampleWorkflow
async def main():
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
# Start client
client = await Client.connect(**config)
worker = Worker(
client,
task_queue="example-task-queue",
workflows=[ExampleWorkflow],
activities=[echo_activity],
workflow_runner=SandboxedWorkflowRunner(
restrictions=SandboxRestrictions.default.with_import_notification_policy(
SandboxImportNotificationPolicy.WARN_ON_DYNAMIC_IMPORT
| SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH
)
),
)
await worker.run()
if __name__ == "__main__":
asyncio.run(main())
Starting the above worker yields this log on startup and workflow execution:
uv run warning/worker.py
/.../temporalio/worker/workflow_sandbox/_importer.py:323: UserWarning: Module warning.workflows was not intentionally passed through to the sandbox.
warnings.warn(
/.../temporalio/worker/workflow_sandbox/_importer.py:323: UserWarning: Module warning.activities was not intentionally passed through to the sandbox.
warnings.warn(
Environment/Versions
- Temporal Version: SDK 1.20
Additional context
- 主要语言
- Python
- 星标
- 1.2k
- 派生
- 241
- 平均合并
- 3 天 2 小时
- 30 天内合并 PR
- 49
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
temporalio/sdk-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
temporalio/sdk-python#1517 · 10 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
temporalio/sdk-python#496 ·
-
难度 5/5 一周以上 新手友好度 25/100
temporalio/sdk-python#1890 ·
-
难度 4/5 3-5 天 新手友好度 52/100
temporalio/sdk-python#1881 · 1 条评论 ·
-
bug
temporalio/sdk-python#1817 · 1 条评论 · 已指派 1 人 ·
查看 temporalio/sdk-python 的全部 Issue
相似的 Issue
-
documentation help wanted
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 90/100
simonw/sqlite-utils#872 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100