icenet-ai / icenet-event-processor

IceNet event processing engine
MIT License
0 stars 0 forks source link

Create processing application #2

Closed JimCircadian closed 1 year ago

JimCircadian commented 1 year ago

Create the application that ingests the configurations available to do X, Y or Z

JimCircadian commented 1 year ago

Direct email for all events seems to be failing through the email communications service, which probably is down to something I've neglected to configure, but as yet unsure. The output below suggests an issue with the service (HTTP 503 - unavailable) but I suspect it's another issue that requires investigation:

2023-01-06T15:12:52Z   [Information]   Python EventGrid trigger processed an event: /blobServices/default/containers/input/blobs/north.1987-10-01.nc
2023-01-06T15:12:52Z   [Information]   Request URL: 'https://[[REDACTED]].communication.azure.com/emails:send?api-version=REDACTED'
Request method: 'POST'
Request headers:
    'Content-Type': 'application/json'
    'Content-Length': '416'
    'repeatability-request-id': 'REDACTED'
    'repeatability-first-sent': 'REDACTED'
    'Accept': 'application/json'
    'x-ms-client-request-id': '96f9a7da-8dd4-11ed-a3f5-a66420be5c9d'
    'User-Agent': 'azsdk-python-communication-email/1.0.0b1 Python/3.9.15 (Linux-5.10.134.1-2.cm1-x86_64-with-glibc2.31)'
    'x-ms-date': 'REDACTED'
    'x-ms-content-sha256': 'REDACTED'
    'x-ms-return-client-request-id': 'true'
    'Authorization': 'REDACTED'
A body is sent with the request
2023-01-06T15:13:23Z   [Information]   Request URL: 'https://[[REDACTED]].communication.azure.com/emails:send?api-version=REDACTED'
Request method: 'POST'
Request headers:
    'Content-Type': 'application/json'
    'Content-Length': '416'
    'repeatability-request-id': 'REDACTED'
    'repeatability-first-sent': 'REDACTED'
    'Accept': 'application/json'
    'x-ms-client-request-id': '96f9a7da-8dd4-11ed-a3f5-a66420be5c9d'
    'User-Agent': 'azsdk-python-communication-email/1.0.0b1 Python/3.9.15 (Linux-5.10.134.1-2.cm1-x86_64-with-glibc2.31)'
    'x-ms-date': 'REDACTED'
    'x-ms-content-sha256': 'REDACTED'
    'x-ms-return-client-request-id': 'true'
    'Authorization': 'REDACTED'
A body is sent with the request
2023-01-06T15:13:23Z   [Information]   Response status: 503
Response headers:
    'Cache-Control': 'no-store'
    'Content-Length': '1002'
    'Content-Type': 'text/html'
    'X-Azure-ExternalError': 'REDACTED'
    'X-Azure-Ref': 'REDACTED'
    'Date': 'Fri, 06 Jan 2023 15:13:22 GMT'
2023-01-06T15:13:55Z   [Information]   Response status: 503
Response headers:
    'Cache-Control': 'no-store'
    'Content-Length': '1002'
    'Content-Type': 'text/html'
    'X-Azure-ExternalError': 'REDACTED'
    'X-Azure-Ref': 'REDACTED'
    'Date': 'Fri, 06 Jan 2023 15:13:54 GMT'
2023-01-06T15:13:57Z   [Information]   Request URL: 'https://[[REDACTED]].communication.azure.com/emails:send?api-version=REDACTED'
Request method: 'POST'
Request headers:
    'Content-Type': 'application/json'
    'Content-Length': '416'
    'repeatability-request-id': 'REDACTED'
    'repeatability-first-sent': 'REDACTED'
    'Accept': 'application/json'
    'x-ms-client-request-id': '96f9a7da-8dd4-11ed-a3f5-a66420be5c9d'
    'User-Agent': 'azsdk-python-communication-email/1.0.0b1 Python/3.9.15 (Linux-5.10.134.1-2.cm1-x86_64-with-glibc2.31)'
    'x-ms-date': 'REDACTED'
    'x-ms-content-sha256': 'REDACTED'
    'x-ms-return-client-request-id': 'true'
    'Authorization': 'REDACTED'
A body is sent with the request
2023-01-06T15:14:27Z   [Information]   Response status: 503
Response headers:
    'Cache-Control': 'no-store'
    'Content-Length': '1002'
    'Content-Type': 'text/html'
    'X-Azure-ExternalError': 'REDACTED'
    'X-Azure-Ref': 'REDACTED'
    'Date': 'Fri, 06 Jan 2023 15:14:26 GMT'
2023-01-06T15:14:31Z   [Information]   Request URL: 'https://[[REDACTED]].communication.azure.com/emails:send?api-version=REDACTED'
Request method: 'POST'
Request headers:
    'Content-Type': 'application/json'
    'Content-Length': '416'
    'repeatability-request-id': 'REDACTED'
    'repeatability-first-sent': 'REDACTED'
    'Accept': 'application/json'
    'x-ms-client-request-id': '96f9a7da-8dd4-11ed-a3f5-a66420be5c9d'
    'User-Agent': 'azsdk-python-communication-email/1.0.0b1 Python/3.9.15 (Linux-5.10.134.1-2.cm1-x86_64-with-glibc2.31)'
    'x-ms-date': 'REDACTED'
    'x-ms-content-sha256': 'REDACTED'
    'x-ms-return-client-request-id': 'true'
    'Authorization': 'REDACTED'
A body is sent with the request
2023-01-06T15:15:03Z   [Information]   Response status: 503
Response headers:
    'Cache-Control': 'no-store'
    'Content-Length': '1002'
    'Content-Type': 'text/html'
    'X-Azure-ExternalError': 'REDACTED'
    'X-Azure-Ref': 'REDACTED'
    'Date': 'Fri, 06 Jan 2023 15:15:02 GMT'
2023-01-06T15:15:03Z   [Warning]   Ran into a deserialization error. Ignoring since this is failsafe deserialization
Traceback (most recent call last):
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1509, in failsafe_deserialize
    return self(target_obj, data, content_type=content_type)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1376, in __call__
    return self._deserialize(target_obj, data)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1454, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
azure.core.exceptions.DeserializationError: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'"))
2023-01-06T15:15:04Z   [Information]   Executed 'Functions.EventGridProcessor' (Succeeded, Id=04e413eb-6d64-40fb-99e7-f36808ea385d, Duration=131228ms)
2023-01-06T15:15:04Z   [Error]   Operation returned an invalid status 'Service Unavailable'
Content: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body {font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Service unavailable</title></head><body><div id='content'><div id='message'><h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p></div><div id='errorref'><span>[[REDACTED]]</span></div></div></body></html>
Traceback (most recent call last):
  File "/home/site/wwwroot/EventGridProcessor/__init__.py", line 40, in main
    response = client.send(message)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/communication/email/_email_client.py", line 77, in send
    return self._generated_client.email.send(
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/communication/email/_generated/operations/_patch.py", line 51, in send
    message_id = super().send(
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/communication/email/_generated/operations/_email_operations.py", line 349, in send
    raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Service Unavailable'
Content: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body {font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Service unavailable</title></head><body><div id='content'><div id='message'><h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p></div><div id='errorref'><span>[[REDACTED]]</span></div></div></body></html>
JimCircadian commented 1 year ago

Solved the email sending issue:

2023-01-09T18:24:22Z   [Information]   Response status: 200
Response headers:
    'Content-Length': '78'
    'Content-Type': 'application/json; charset=utf-8'
    'mise-correlation-id': 'REDACTED'
    'api-supported-versions': 'REDACTED'
    'X-Cache': 'REDACTED'
    'X-Azure-Ref': 'REDACTED'
    'Date': 'Mon, 09 Jan 2023 18:24:21 GMT'
2023-01-09T18:24:22Z   [Information]   Email status for message_id e57fdb9f-279a-4a28-aa08-35b6ddccae53 is OutForDelivery.
2023-01-09T18:24:22Z   [Information]   Email delivered for message_id e57fdb9f-279a-4a28-aa08-35b6ddccae53.
2023-01-09T18:24:22Z   [Information]   Executed 'Functions.EventGridProcessor' (Succeeded, Id=5fa9a243-40b6-40b0-9090-61eeb7eaba40, Duration=11539ms)
JimCircadian commented 1 year ago

Have built the custom container and deployed to the functionapp, but experiencing this issue

JimCircadian commented 1 year ago

The application code and docker image now work fine, but need to evaluate deployment options. Leaving open for the moment and will continue development herein

JimCircadian commented 1 year ago

Completed run

Connected!
2023-08-14T15:21:19Z   [Information]   Email send poller status: Running
2023-08-14T15:21:29Z   [Information]   Email send poller status: Running
2023-08-14T15:21:29Z   [Information]   Successfully sent the email (operation id: 3e8fbe69-b68e-4dab-abad-d4b6e1863ef9)
2023-08-14T15:21:29Z   [Information]   Email sent, no further threshold checks will be carried out
2023-08-14T15:21:30Z   [Information]   Executed 'Functions.EventGridProcessor' (Succeeded, Id=07369d53-aa95-4429-b4d9-c75bcb63bbeb, Duration=41448ms)
2023-08-14T15:23:19Z   [Information]   Executing 'Functions.EventGridProcessor' (Reason='EventGrid trigger fired at 2023-08-14T15:23:19.1810139+00:00', Id=ea524c49-c662-4e29-a4bc-da3f07d88292)
2023-08-14T15:23:19Z   [Verbose]   Sending invocation id: 'ea524c49-c662-4e29-a4bc-da3f07d88292
2023-08-14T15:23:19Z   [Verbose]   Posting invocation id:ea524c49-c662-4e29-a4bc-da3f07d88292 on workerId:4c1cfe51-fd5d-42be-a2db-f8fa26bf2137
2023-08-14T15:23:19Z   [Information]   IceNet EventGrid trigger processed an event: [[REDACTED]]
2023-08-14T15:23:19Z   [Verbose]   Configuration provided: [[REDACTED]]
2023-08-14T15:23:19Z   [Warning]   No configuration provided, or we've been instructed to send the default event email
2023-08-14T15:23:19Z   [Information]   send_email message:
[[REDACTED]]
2023-08-14T15:23:19Z   [Information]   Request URL: [[REDACTED]]
A body is sent with the request
2023-08-14T15:23:19Z   [Verbose]   Starting new HTTPS connection (1): icenetuat-comms.unitedstates.communication.azure.com:443
2023-08-14T15:23:20Z   [Verbose]   [[REDACTED]]
2023-08-14T15:23:20Z   [Information]   Email send poller status: Running
2023-08-14T15:23:30Z   [Information]   Email send poller status: Running
2023-08-14T15:23:40Z   [Information]   Email send poller status: Running
2023-08-14T15:23:50Z   [Information]   Email send poller status: Running
2023-08-14T15:23:50Z   [Information]   Successfully sent the email (operation id: 0f3f6e09-3101-4171-9e3d-44888ab9d66f)
2023-08-14T15:23:50Z   [Information]   Forecast upload event received
2023-08-14T15:23:50Z   [Information]   Processing event Microsoft.Storage.BlobCreated
2023-08-14T15:23:51Z   [Warning]   We already have /data/fc.2023-07-31_north.nc, continuing...
2023-08-14T15:23:51Z   [Information]   Opening /data/fc.2023-07-31_north.nc
2023-08-14T15:23:51Z   [Information]   ecCodes library found using name 'eccodes'.
2023-08-14T15:23:51Z   [Verbose]   Could not import boto3, continuing with reduced functionality.
2023-08-14T15:23:51Z   [Verbose]   GDAL data found in package: path='/usr/local/lib/python3.8/site-packages/rasterio/gdal_data'.
2023-08-14T15:23:51Z   [Verbose]   PROJ data found in package: path='/usr/local/lib/python3.8/site-packages/rasterio/proj_data'.
2023-08-14T15:23:51Z   [Information]   Processing output configuration [{'implementation': 'output_forecast'}, {'implementation': 'output_histogram'}, {'implementation': 'output_sie_growth'}, {'implementation': 'output_trend'}, {'implementation': 'list_assets'}]
2023-08-14T15:23:51Z   [Information]   Processing output configuration [[REDACTED]]
2023-08-14T15:23:51Z   [Information]   Calling threshold_check in EventGridProcessor.checks
[[REDACTED]]
2023-08-14T15:23:59Z   [Verbose]   Year 2022 has 0/11570688 violations of threshold
2023-08-14T15:23:59Z   [Verbose]   Starting new HTTPS connection (1): icenetuat-comms.unitedstates.communication.azure.com:443
2023-08-14T15:23:59Z   [Information]   We have message going to jambyr@bas.ac.uk, eller@bas.ac.uk:

    Forecast from 2023-09-01 to 2023-11-01 has regions that exceed the SIC threshold 0.85 for
    7 in relation to previous years, where there were crossings.

    The years that compare are [0]. You might want to get yourself over to the IceNet dashboard for a
    look at the latest forecast.

    Thanks,

    The IceNet Team
2023-08-14T15:23:59Z   [Information]   send_email message:
[[REDACTED]]
A body is sent with the request
2023-08-14T15:24:00Z   [Verbose]   https://icenetuat-comms.unitedstates.communication.azure.com:443 "POST /emails:send?api-version=2023-03-31 HTTP/1.1" 202 77
2023-08-14T15:24:00Z   [Information]   Response status: 202
[[REDACTED]]
2023-08-14T15:24:00Z   [Information]   Email send poller status: Running
2023-08-14T15:24:10Z   [Information]   Email send poller status: Running
2023-08-14T15:24:20Z   [Information]   Email send poller status: Running
2023-08-14T15:24:30Z   [Information]   Email send poller status: Running
2023-08-14T15:24:30Z   [Information]   Successfully sent the email (operation id: ad214849-9358-426b-8fac-a29783917fb3)
2023-08-14T15:24:30Z   [Information]   Email sent, no further threshold checks will be carried out
2023-08-14T15:24:30Z   [Information]   Executed 'Functions.EventGridProcessor' (Succeeded, Id=ea524c49-c662-4e29-a4bc-da3f07d88292, Duration=71090ms)