Skip to content

Commit 9eb0959

Browse files
committed
var names + docs
1 parent a798640 commit 9eb0959

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

azure_functions_worker/dispatcher.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -686,17 +686,19 @@ def index_functions(self, function_path: str):
686686
indexed_functions))
687687

688688
indexed_function_logs: List[str] = []
689-
bindings_info = []
689+
indexed_function_bindings_logs = []
690690
for func in indexed_functions:
691-
fx_bindings = fx_bindings_logs.get(func)
691+
func_binding_logs = fx_bindings_logs.get(func)
692692
for binding in func.get_bindings():
693-
deferred_binding_info = fx_bindings.get(binding.name)\
694-
if fx_bindings.get(binding.name) else ""
695-
bindings_info.append((binding.type, binding.name,
696-
deferred_binding_info))
693+
deferred_binding_info = func_binding_logs.get(
694+
binding.name)\
695+
if func_binding_logs.get(binding.name) else ""
696+
indexed_function_bindings_logs.append((
697+
binding.type, binding.name, deferred_binding_info))
697698

698699
function_log = "Function Name: {}, Function Binding: {}" \
699-
.format(func.get_function_name(), bindings_info)
700+
.format(func.get_function_name(),
701+
indexed_function_bindings_logs)
700702
indexed_function_logs.append(function_log)
701703

702704
logger.info(

tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44

55
import azure.functions as func
6-
import azurefunctions.extensions.bindings.blob as bindings
6+
import azurefunctions.extensions.bindings.blob as blob
77

88
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
99

@@ -25,7 +25,7 @@ def put_bc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
2525
@app.blob_output(arg_name="$return",
2626
path="python-worker-tests/test-blobclient-triggered.txt",
2727
connection="AzureWebJobsStorage")
28-
def bc_blob_trigger(client: bindings.BlobClient) -> str:
28+
def bc_blob_trigger(client: blob.BlobClient) -> str:
2929
blob_properties = client.get_blob_properties()
3030
file = client.download_blob(encoding='utf-8').readall()
3131
return json.dumps({
@@ -41,7 +41,7 @@ def bc_blob_trigger(client: bindings.BlobClient) -> str:
4141
connection="AzureWebJobsStorage")
4242
@app.route(route="get_bc_blob_triggered")
4343
def get_bc_blob_triggered(req: func.HttpRequest,
44-
client: bindings.BlobClient) -> str:
44+
client: blob.BlobClient) -> str:
4545
return client.download_blob(encoding='utf-8').readall()
4646

4747

@@ -62,7 +62,7 @@ def put_cc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
6262
@app.blob_output(arg_name="$return",
6363
path="python-worker-tests/test-containerclient-triggered.txt",
6464
connection="AzureWebJobsStorage")
65-
def cc_blob_trigger(client: bindings.ContainerClient) -> str:
65+
def cc_blob_trigger(client: blob.ContainerClient) -> str:
6666
container_properties = client.get_container_properties()
6767
file = client.download_blob("test-containerclient-trigger.txt",
6868
encoding='utf-8').readall()
@@ -78,7 +78,7 @@ def cc_blob_trigger(client: bindings.ContainerClient) -> str:
7878
connection="AzureWebJobsStorage")
7979
@app.route(route="get_cc_blob_triggered")
8080
def get_cc_blob_triggered(req: func.HttpRequest,
81-
client: bindings.ContainerClient) -> str:
81+
client: blob.ContainerClient) -> str:
8282
return client.download_blob("test-containerclient-triggered.txt",
8383
encoding='utf-8').readall()
8484

@@ -100,7 +100,7 @@ def put_ssd_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
100100
@app.blob_output(arg_name="$return",
101101
path="python-worker-tests/test-ssd-triggered.txt",
102102
connection="AzureWebJobsStorage")
103-
def ssd_blob_trigger(stream: bindings.StorageStreamDownloader) -> str:
103+
def ssd_blob_trigger(stream: blob.StorageStreamDownloader) -> str:
104104
# testing chunking
105105
file = ""
106106
for chunk in stream.chunks():
@@ -116,7 +116,7 @@ def ssd_blob_trigger(stream: bindings.StorageStreamDownloader) -> str:
116116
connection="AzureWebJobsStorage")
117117
@app.route(route="get_ssd_blob_triggered")
118118
def get_ssd_blob_triggered(req: func.HttpRequest,
119-
stream: bindings.StorageStreamDownloader) -> str:
119+
stream: blob.StorageStreamDownloader) -> str:
120120
return stream.readall().decode('utf-8')
121121

122122

@@ -125,7 +125,7 @@ def get_ssd_blob_triggered(req: func.HttpRequest,
125125
@app.blob_input(arg_name="client",
126126
path="python-worker-tests/test-blob-extension-bytes.txt",
127127
connection="AzureWebJobsStorage")
128-
def get_bc_bytes(req: func.HttpRequest, client: bindings.BlobClient) -> str:
128+
def get_bc_bytes(req: func.HttpRequest, client: blob.BlobClient) -> str:
129129
return client.download_blob(encoding='utf-8').readall()
130130

131131

@@ -135,7 +135,7 @@ def get_bc_bytes(req: func.HttpRequest, client: bindings.BlobClient) -> str:
135135
path="python-worker-tests/test-blob-extension-bytes.txt",
136136
connection="AzureWebJobsStorage")
137137
def get_cc_bytes(req: func.HttpRequest,
138-
client: bindings.ContainerClient) -> str:
138+
client: blob.ContainerClient) -> str:
139139
return client.download_blob("test-blob-extension-bytes.txt",
140140
encoding='utf-8').readall()
141141

@@ -146,7 +146,7 @@ def get_cc_bytes(req: func.HttpRequest,
146146
path="python-worker-tests/test-blob-extension-bytes.txt",
147147
connection="AzureWebJobsStorage")
148148
def get_ssd_bytes(req: func.HttpRequest,
149-
stream: bindings.StorageStreamDownloader) -> str:
149+
stream: blob.StorageStreamDownloader) -> str:
150150
return stream.readall().decode('utf-8')
151151

152152

@@ -155,7 +155,7 @@ def get_ssd_bytes(req: func.HttpRequest,
155155
@app.blob_input(arg_name="client",
156156
path="python-worker-tests/test-blob-extension-str.txt",
157157
connection="AzureWebJobsStorage")
158-
def get_bc_str(req: func.HttpRequest, client: bindings.BlobClient) -> str:
158+
def get_bc_str(req: func.HttpRequest, client: blob.BlobClient) -> str:
159159
return client.download_blob(encoding='utf-8').readall()
160160

161161

@@ -164,7 +164,7 @@ def get_bc_str(req: func.HttpRequest, client: bindings.BlobClient) -> str:
164164
@app.blob_input(arg_name="client",
165165
path="python-worker-tests",
166166
connection="AzureWebJobsStorage")
167-
def get_cc_str(req: func.HttpRequest, client: bindings.ContainerClient) -> str:
167+
def get_cc_str(req: func.HttpRequest, client: blob.ContainerClient) -> str:
168168
return client.download_blob("test-blob-extension-str.txt",
169169
encoding='utf-8').readall()
170170

@@ -174,7 +174,7 @@ def get_cc_str(req: func.HttpRequest, client: bindings.ContainerClient) -> str:
174174
@app.blob_input(arg_name="stream",
175175
path="python-worker-tests/test-blob-extension-str.txt",
176176
connection="AzureWebJobsStorage")
177-
def get_ssd_str(req: func.HttpRequest, stream: bindings.StorageStreamDownloader) -> str:
177+
def get_ssd_str(req: func.HttpRequest, stream: blob.StorageStreamDownloader) -> str:
178178
return stream.readall().decode('utf-8')
179179

180180

@@ -188,7 +188,7 @@ def get_ssd_str(req: func.HttpRequest, stream: bindings.StorageStreamDownloader)
188188
path="python-worker-tests/test-blob-extension-str.txt",
189189
data_type="STRING",
190190
connection="AzureWebJobsStorage")
191-
def bc_and_inputstream_input(req: func.HttpRequest, client: bindings.BlobClient,
191+
def bc_and_inputstream_input(req: func.HttpRequest, client: blob.BlobClient,
192192
blob: func.InputStream) -> str:
193193
output_msg = ""
194194
file = blob.read().decode('utf-8')
@@ -208,7 +208,7 @@ def bc_and_inputstream_input(req: func.HttpRequest, client: bindings.BlobClient,
208208
data_type="STRING",
209209
connection="AzureWebJobsStorage")
210210
def inputstream_and_bc_input(req: func.HttpRequest, blob: func.InputStream,
211-
client: bindings.BlobClient) -> str:
211+
client: blob.BlobClient) -> str:
212212
output_msg = ""
213213
file = blob.read().decode('utf-8')
214214
client_file = client.download_blob(encoding='utf-8').readall()
@@ -223,9 +223,9 @@ def inputstream_and_bc_input(req: func.HttpRequest, blob: func.InputStream,
223223
data_type="STRING",
224224
connection="AzureWebJobsStorage")
225225
def type_undefined(req: func.HttpRequest, file) -> str:
226-
assert not isinstance(file, bindings.BlobClient)
227-
assert not isinstance(file, bindings.ContainerClient)
228-
assert not isinstance(file, bindings.StorageStreamDownloader)
226+
assert not isinstance(file, blob.BlobClient)
227+
assert not isinstance(file, blob.ContainerClient)
228+
assert not isinstance(file, blob.StorageStreamDownloader)
229229
return file.read().decode('utf-8')
230230

231231

@@ -255,5 +255,5 @@ def put_blob_bytes(req: func.HttpRequest, file: func.Out[bytes]) -> str:
255255
connection="AzureWebJobsStorage")
256256
@app.route(route="blob_cache")
257257
def blob_cache(req: func.HttpRequest,
258-
client: bindings.BlobClient) -> str:
258+
client: blob.BlobClient) -> str:
259259
return client.download_blob(encoding='utf-8').readall()

tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_enabled/function_app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33
import azure.functions as func
4-
import azurefunctions.extensions.bindings.blob as bindings
4+
import azurefunctions.extensions.bindings.blob as blob
55

66
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
77

@@ -12,5 +12,5 @@
1212
connection="AzureWebJobsStorage")
1313
@app.route(route="get_bc_blob_triggered")
1414
def get_bc_blob_triggered(req: func.HttpRequest,
15-
client: bindings.BlobClient) -> str:
15+
client: blob.BlobClient) -> str:
1616
return client.download_blob(encoding='utf-8').readall()

tests/extension_tests/deferred_bindings_tests/deferred_bindings_functions/deferred_bindings_enabled_dual/function_app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44

55
import azure.functions as func
6-
import azurefunctions.extensions.bindings.blob as bindings
6+
import azurefunctions.extensions.bindings.blob as blob
77

88
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
99

@@ -14,7 +14,7 @@
1414
connection="AzureWebJobsStorage")
1515
@app.route(route="get_bc_blob_triggered")
1616
def get_bc_blob_triggered(req: func.HttpRequest,
17-
client: bindings.BlobClient) -> str:
17+
client: blob.BlobClient) -> str:
1818
return client.download_blob(encoding='utf-8').readall()
1919

2020

tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ def test_deferred_bindings_decode(self):
105105
self.assertIsNotNone(obj)
106106

107107
async def test_check_deferred_bindings_enabled(self):
108+
"""
109+
check_deferred_bindings_enabled checks if deferred bindings is enabled at fx
110+
and single binding level.
111+
112+
The first bool represents if deferred bindings is enabled at a fx level. This
113+
means that at least one binding in the function is a deferred binding type.
114+
115+
The second represents if the current binding is deferred binding. If this is
116+
True, then deferred bindings must also be enabled at the function level.
117+
"""
108118
async with testutils.start_mockhost(
109119
script_root=DEFERRED_BINDINGS_DISABLED_DIR) as host:
110120
await host.init_worker()

0 commit comments

Comments
 (0)