Skip to content

Commit cfb6048

Browse files
committed
Get rid of pydantic sandbox hack
1 parent 3d48ace commit cfb6048

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

tests/contrib/test_pydantic.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dataclasses
21
import uuid
32
from datetime import datetime, timedelta
43
from ipaddress import IPv4Address
@@ -10,10 +9,6 @@
109
from temporalio.client import Client
1110
from temporalio.contrib.pydantic.converter import pydantic_data_converter
1211
from temporalio.worker import Worker
13-
from temporalio.worker.workflow_sandbox import (
14-
SandboxedWorkflowRunner,
15-
SandboxRestrictions,
16-
)
1712

1813

1914
class MyPydanticModel(BaseModel):
@@ -37,29 +32,6 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]:
3732
)
3833

3934

40-
# Due to known issues with Pydantic's use of issubclass and our inability to
41-
# override the check in sandbox, Pydantic will think datetime is actually date
42-
# in the sandbox. At the expense of protecting against datetime.now() use in
43-
# workflows, we're going to remove datetime module restrictions. See sdk-python
44-
# README's discussion of known sandbox issues for more details.
45-
def new_sandbox_runner() -> SandboxedWorkflowRunner:
46-
# TODO(cretz): Use with_child_unrestricted when https://github.com/temporalio/sdk-python/issues/254
47-
# is fixed and released
48-
invalid_module_member_children = dict(
49-
SandboxRestrictions.invalid_module_members_default.children
50-
)
51-
del invalid_module_member_children["datetime"]
52-
return SandboxedWorkflowRunner(
53-
restrictions=dataclasses.replace(
54-
SandboxRestrictions.default,
55-
invalid_module_members=dataclasses.replace(
56-
SandboxRestrictions.invalid_module_members_default,
57-
children=invalid_module_member_children,
58-
),
59-
)
60-
)
61-
62-
6335
async def test_workflow_with_pydantic_model(client: Client):
6436
# Replace data converter in client
6537
new_config = client.config()
@@ -83,7 +55,6 @@ async def test_workflow_with_pydantic_model(client: Client):
8355
task_queue=task_queue_name,
8456
workflows=[MyWorkflow],
8557
activities=[my_activity],
86-
workflow_runner=new_sandbox_runner(),
8758
):
8859
result = await client.execute_workflow(
8960
MyWorkflow.run,

0 commit comments

Comments
 (0)