Guy Altman
03/03/2023, 4:42 PMChristopher Boyd
03/03/2023, 4:46 PMGuy Altman
03/03/2023, 4:48 PMResult: Failure Exception: RuntimeError: no validator found for <class 'azure.functions._eventgrid.EventGridEvent'>, see `arbitrary_types_allowed` in Config Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 357, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py", line 132, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/home/site/wwwroot/bossEventTrigger/__init__.py", line 9, in <module> def main(event: func.EventGridEvent): File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/flows.py", line 659, in flow Flow( File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/context.py", line 176, in __register_init__ __init__(__self__, *args, **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/flows.py", line 192, in __init__ ValidatedFunction(self.fn, config=None) File "pydantic/decorator.py", line 126, in pydantic.decorator.ValidatedFunction.__init__ File "pydantic/decorator.py", line 264, in pydantic.decorator.ValidatedFunction.create_model File "pydantic/main.py", line 1027, in pydantic.main.create_model File "pydantic/main.py", line 198, in pydantic.main.ModelMetaclass.__new__ File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__ File "pydantic/fields.py", line 557, in pydantic.fields.ModelField.prepare File "pydantic/fields.py", line 831, in pydantic.fields.ModelField.populate_validators File "pydantic/validators.py", line 765, in find_validators
I believe it's an issue with the az function connecting to prefect cloud because the error message states that in line 1506 of orchestrate.py the response.json() is None.Guy Altman
03/03/2023, 4:51 PMfrom prefect.deployments import run_deployment
import azure.functions as func
def main(event: func.EventGridEvent):
file_name = get_file_from_subject(event.subject)
response = run_deployment(name='main-flow/dp_blob_ingestion_smart_rent_group',
flow_run_name= file_name,
parameters={
'blob_path': event.subject,
'target_schema': 'GALTMAN',
'github_params': {
'repo': 'my_repo',
'branch': 'my_branch'
},
'snwf_params': {
'account': 'my_account',
'warehouse': 'my_wh',
'db': 'TEMP',
'schema': 'my_schema',
'authenticator': 'snowflake'
}
},
timeout=0)
def get_file_from_subject(subject):
return subject.split('/')[-1].replace('.json', '').upper()
But note, i've also tried it with just a simple block secret string get() and it still had the same error. The az function only fails when prefect code is there.Christopher Boyd
03/03/2023, 4:54 PMResult: Failure Exception: RuntimeError: no validator found for <class 'azure.functions._eventgrid.EventGridEvent'>
It looks like it’s failing to validate the pydantic typing?Christopher Boyd
03/03/2023, 4:56 PMGuy Altman
03/03/2023, 4:58 PMException: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 452, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 718, in _run_sync_func
return ExtensionManager.get_sync_invocation_wrapper(context,
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper
result = function(**args)
File "/home/site/wwwroot/bossEventTrigger/__init__.py", line 10, in main
response = run_deployment(name='main-flow/dp_blob_ingestion_smart_rent_group',
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/utilities/asyncutils.py", line 230, in coroutine_wrapper
return run_async_in_new_loop(async_fn, *args, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/utilities/asyncutils.py", line 181, in run_async_in_new_loop
return anyio.run(partial(__fn, *args, **kwargs))
File "/home/site/wwwroot/.python_packages/lib/site-packages/anyio/_core/_eventloop.py", line 70, in run
return asynclib.run(func, *args, **backend_options)
File "/home/site/wwwroot/.python_packages/lib/site-packages/anyio/_backends/_asyncio.py", line 292, in run
return native_run(wrapper(), debug=debug)
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/home/site/wwwroot/.python_packages/lib/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
return await func(*args)
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
return await fn(*args, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/deployments.py", line 89, in run_deployment
deployment = await client.read_deployment_by_name(name)
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/client/orion.py", line 1444, in read_deployment_by_name
return schemas.responses.DeploymentResponse.parse_obj(response.json())
File "/home/site/wwwroot/.python_packages/lib/site-packages/httpx/_models.py", line 756, in json
return jsonlib.loads(self.text, **kwargs)
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
Guy Altman
03/03/2023, 5:02 PMFile "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/deployments.py", line 89, in run_deployment
deployment = await client.read_deployment_by_name(name)
File "/home/site/wwwroot/.python_packages/lib/site-packages/prefect/client/orion.py", line 1444, in read_deployment_by_name
return schemas.responses.DeploymentResponse.parse_obj(response.json())
Christopher Boyd
03/03/2023, 5:04 PMorion.py
was removed as part of a recent version, although I don’t know if that has bearing here.
can you do something even more simple, like just listing your deployments, or getting a health endpoint of your account, to simplify the problem, and determine if it’s azure or prefectChristopher Boyd
03/03/2023, 5:05 PMread_deployment_by_name
would be used by many flow runsGuy Altman
03/03/2023, 6:12 PMChristopher Boyd
03/03/2023, 6:16 PMcurl -v -H 'Authorization: Bearer <replace with your api key>' <https://api.prefect.cloud/api/accounts/><your accound id>/workspaces/<workspace_id>/health
Guy Altman
03/03/2023, 6:22 PMInvoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "Authorization: Bearer my_key" value of type
"System.String" to type "System.Collections.IDictionary".
At line:1 char:12
+ curl -v -H 'Authorization: Bearer my_key ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Christopher Boyd
03/03/2023, 6:25 PMGuy Altman
03/03/2023, 6:27 PMGuy Altman
03/03/2023, 6:32 PMChristopher Boyd
03/03/2023, 6:34 PMChristopher Boyd
03/03/2023, 6:34 PMChristopher Boyd
03/03/2023, 6:34 PMChristopher Boyd
03/03/2023, 6:34 PMChristopher Boyd
03/03/2023, 6:35 PM< HTTP/2 403
< date: Fri, 03 Mar 2023 18:35:14 GMT
< server: istio-envoy
< content-length: 30
< content-type: application/json
< x-envoy-upstream-service-time: 3
< via: 1.1 google
< content-security-policy: default-src 'none'; object-src 'none'
< x-content-type-options: nosniff
< strict-transport-security: max-age=63072000; includeSubDomains; preload
< permissions-policy: accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), serial=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()
< x-permitted-cross-domain-policies: none
< referrer-policy: same-origin
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
* Connection #0 to host api.prefect.cloud left intact
{"detail":"Not authenticated"}%4
Guy Altman
03/03/2023, 6:35 PMChristopher Boyd
03/03/2023, 6:35 PMGuy Altman
03/03/2023, 6:37 PM* Trying 23.100.231.127:80...
* Connected to Bearer (23.100.231.127) port 80 (#0)
> GET / HTTP/1.1
> Host: Bearer
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Fri, 03 Mar 2023 18:36:12 GMT
< Connection: close
< Content-Length: 315
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""<http://www.w3.org/TR/html4/strict.dtd>">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
* Closing connection 0
* Could not resolve host: my_key'
* Closing connection 1
curl: (6) Could not resolve host: my_key'
* Trying 34.111.36.90:443...
* Connected to api.prefect.cloud (34.111.36.90) port 443 (#2)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* ALPN: server accepted http/1.1
> GET /api/accounts/bae78ed9-1e37-409a-b34e-9c99aca8d81e/workspaces/7f678f7c-d100-4c3f-a9e2-928136ba7022/health HTTP/1.1
> Host: api.prefect.cloud
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< date: Fri, 03 Mar 2023 18:36:15 GMT
< server: istio-envoy
< content-length: 30
< content-type: application/json
< x-envoy-upstream-service-time: 4
< Via: 1.1 google
< Content-Security-Policy: default-src 'none'; object-src 'none'
< X-Content-Type-Options: nosniff
< Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
< Permissions-Policy: accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), serial=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()
< X-Permitted-Cross-Domain-Policies: none
< Referrer-Policy: same-origin
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
{"detail":"Not authenticated"}* Connection #2 to host api.prefect.cloud left intact
Christopher Boyd
03/03/2023, 6:41 PMcurl: (6) Could not resolve host: my_key'
but the 403 says it’s a bad api keyChristopher Boyd
03/03/2023, 6:42 PMChristopher Boyd
03/03/2023, 6:42 PMHTTP/2 200
date: Fri, 03 Mar 2023 18:42:10 GMT
server: istio-envoy
content-length: 4
content-type: application/json
x-envoy-upstream-service-time: 11
via: 1.1 google
content-security-policy: default-src 'none'; object-src 'none'
x-content-type-options: nosniff
strict-transport-security: max-age=63072000; includeSubDomains; preload
permissions-policy: accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), serial=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()
x-permitted-cross-domain-policies: none
referrer-policy: same-origin
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
true%
Guy Altman
03/03/2023, 6:42 PMGuy Altman
03/03/2023, 7:17 PMimport prefect
import anyio
# set up Prefect API URL and API key
api_url = "<https://app.prefect.cloud/account/bae78ed9-1e37-409a-b34e-9c99aca8d81e/workspace/141fc872-2acf-4c37-892a-d4aebeb77040>"
api_key = my_key
async def main():
client = prefect.get_cloud_client(api_key=api_key)
await client.api_healthcheck()
anyio.run(main)
Guy Altman
03/03/2023, 7:17 PMChristopher Boyd
03/03/2023, 7:40 PMChristopher Boyd
03/03/2023, 7:42 PMChristopher Boyd
03/03/2023, 7:42 PMGuy Altman
03/03/2023, 7:57 PMChristopher Boyd
03/03/2023, 8:01 PMGuy Altman
03/07/2023, 3:40 PMChristopher Boyd
03/07/2023, 7:12 PMGuy Altman
03/07/2023, 7:14 PM