microsoft / AIforEarth-API-Platform

The AI for Earth API Platform is a distributed infrastructure designed to provide a secure, scalable, and customizable API hosting, designed to handle the needs of long-running/asynchronous machine learning model inference. It is to be used with the AI For Earth API Framework (https://github.com/microsoft/AIforEarth-API-Development).
MIT License
45 stars 26 forks source link

Getting 'Request content too large' after modifying `content_max_length` in `api_sync_func` #15

Closed chiroptical closed 3 years ago

chiroptical commented 3 years ago

I am trying to finish up a container for our AI4E requirements and I am getting the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>413 Request Entity Too Large</title>
<h1>Request Entity Too Large</h1>
<p>{'message': 'Request content too large (441078). Must be smaller than: 10000'}</p>

I have tried to set content_max_length in this call

@ai4e_service.api_sync_func(
    api_path="/detect/cardinalis_cardinalis",
    methods=["POST"],
    request_processing_function=process_request_data,
    maximum_concurrent_requests=5,
    content_types=ACCEPTED_CONTENT_TYPES,
    content_max_length=MAX_CONTENT_LENGTH,
    trace_name="post:detect_cardinalis_cardinalis",
)
def detect(*args, **kwargs):
   ...

I also tried modifying this for the Flask app itself via app.config['MAX_CONTENT_LENGTH'] = MAX_CONTENT_LENGTH. MAX_CONTENT_LENGTH = 1 * 1024 * 1024. I see the following code: https://github.com/microsoft/AIforEarth-API-Platform/blob/7987f350c7d74f2bad254b1b3fbac8ecce10804f/APIs/1.0/base-py/ai4e_service.py#L103-L105 which makes me think this should work. Any thoughts?

My code is available here: https://github.com/chiroptical/ai4e-example/tree/opensoundscape_0_4_4

chiroptical commented 3 years ago

The code in the master branch doesn't have this issue but I need python 3.7+ so it was easier to base the container on Ubuntu 20. If you need anything extra let me know.

chiroptical commented 3 years ago

I had a bug in one of my deployment scripts which cause this. Closing.