This commit is contained in:
Victoria Hall 2024-05-29 10:37:40 -05:00
Родитель 4d0feb7993
Коммит 26395f6b20
3 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -181,10 +181,10 @@ async def from_incoming_proto(
# if the binding is an sdk type binding
if is_deferred_binding:
return await deferred_bindings_decode(binding=binding,
pb=pb,
pytype=pytype,
datum=datum,
metadata=metadata)
pb=pb,
pytype=pytype,
datum=datum,
metadata=metadata)
return binding.decode(datum, trigger_metadata=metadata)
except NotImplementedError:
# Binding does not support the data.
@ -278,10 +278,10 @@ def to_outgoing_param_binding(binding: str, obj: typing.Any, *,
async def deferred_bindings_decode(binding: typing.Any,
pb: protos.ParameterBinding, *,
pytype: typing.Optional[type],
datum: typing.Any,
metadata: typing.Any):
pb: protos.ParameterBinding, *,
pytype: typing.Optional[type],
datum: typing.Any,
metadata: typing.Any):
"""
This cache holds deferred binding types (ie. BlobClient, ContainerClient)
That have already been created, so that the worker can reuse the
@ -299,8 +299,8 @@ async def deferred_bindings_decode(binding: typing.Any,
datum.value.content))
else:
deferred_binding_type = await binding.decode(datum,
trigger_metadata=metadata,
pytype=pytype)
trigger_metadata=metadata,
pytype=pytype)
deferred_bindings_cache[(pb.name,
pytype,
datum.value.content)] = deferred_binding_type

Просмотреть файл

@ -296,7 +296,7 @@ async def aio_ssd(req: func.HttpRequest,
decoded = file.decode('utf-8')
return str(decoded)
@app.function_name(name="invalid_connection_info")
@app.blob_input(arg_name="client",
path="python-worker-tests/test-blobclient-triggered.txt",

Просмотреть файл

@ -183,12 +183,16 @@ class TestDeferredBindingsBlobFunctions(testutils.WebHostTestCase):
def test_aio_clients(self):
r = self.webhost.request('GET', 'aio_blob_client')
self.assertEqual(r.status_code, 200)
self.assertEqual(r.text, ('b\'{"name": "test-blobclient-trigger.txt", "length": 9, "content": '
'"DummyData"}\''))
self.assertEqual(r.text,
('b\'{"name": "test-blobclient-trigger.txt",'
' "length": 9, "content": '
'"DummyData"}\''))
r = self.webhost.request('GET', 'aio_container_client')
self.assertEqual(r.status_code, 200)
self.assertEqual(r.text, '{\r\n "name": "python-worker-tests",\r\n "content": "DummyData"\r\n}')
self.assertEqual(r.text,
'{\r\n "name": "python-worker-tests",\r\n '
'"content": "DummyData"\r\n}')
r = self.webhost.request('GET', 'aio_ssd')
self.assertEqual(r.status_code, 200)