aws / sagemaker-inference-toolkit

Serve machine learning models within a 🐳 Docker container using 🧠 Amazon SageMaker.
Apache License 2.0
385 stars 82 forks source link

[DRAFT] Support CustomAttributes / request context in handler function overrides #111

Open athewsey opened 2 years ago

athewsey commented 2 years ago

Issue #, if available: #110

Description of changes:

Initial draft of a non-breaking option to support passing an extra "request context" parameter to handler override functions (transform_fn, input_fn, predict_fn, output_fn), ONLY when the signature of the provided function includes the extra parameter.

This should allow script mode users to access additional request context (such as the SageMaker CustomAttributes header) without breaking implementations using the existing function APIs.

Outstanding TODOs (hoping for input from reviewers!) include:

Testing done:

Added some unit tests to show initial non-breaking-ness, but would be nice to get an integration test too maybe?

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

lopesdaniel09 commented 1 year ago

Hello, I was also looking for this feature. Any progress? Do you need help?