-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adding RestrictedFeatures Support to the Python Frontend Bindings #7775
base: main
Are you sure you want to change the base?
Conversation
def validate_features(features: List[Feature]) -> List[Feature]: | ||
invalid_features = [item for item in features if not isinstance(item, Feature)] | ||
if invalid_features: | ||
raise tritonserver.InvalidArgumentError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Investigating why @field_validator
is incompatible with @handle_triton_server
nested underneath. To unblock, directly raised tritonserver
equivalent error.
HTTP_ARGS = (KServeHttp, httpclient, "localhost:8000") # Default HTTP args | ||
GRPC_ARGS = (KServeGrpc, grpcclient, "localhost:8001") # Default GRPC args | ||
METRICS_ARGS = (Metrics, "localhost:8002") # Default Metrics args | ||
RESTRICTED_FEATURE_ARG = RestrictedFeatures() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the pytest way to set test suit level parameters? Can you point me to the guide on that?
|
||
utils.teardown_service(service) | ||
utils.teardown_server(server) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for:
- multiple feature groups
- overwrite feature groups
- remove feature groups
- duplicate feature in different groups
self.add_feature_group(group) | ||
|
||
@handle_triton_error | ||
def _gather_rest_data(self) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is rest_data
?
Co-authored-by: GuanLuo <[email protected]>
What does the PR do?
This PR provides Restricted Features support to the python frontend bindings, a.k.a
tritonfrontend
.This PR introduces 3 new classes to the
tritonfrontend
package:Feature
: 1-to-1 mapping of RestrictedCategory EnumFeatureGroup
: Pydantic@dataclass
that stores (key, value, features) information while performing type validation.RestrictedFeatures
: Store collections ofFeatureGroup
instances, apply an additional layer of validation to check for collisions (ensuring that each feature belongs to only one group), and serialize the data into a JSON string.With these changes, we can pass a
RestrictedFeatures
to theKServeHttp
andKServeGrpc
frontends, which looks along the lines of:A
RestrictedFeatures
instance can be created with:Where should the reviewer start?
Take a look at
api/_restricted_features.py
andtritonfrontend.h
Test plan:
In
L0_python_api/test_kserve.py
added:test_correct_rf_parameters()
andtest_wrong_rf_parameters()
: Tests for valid/invalid arguments passed/selected forFeature
,FeatureGroup
andRestrictedFeature
To test if restricted features are working correctly with the frontends:
test_restricted_features()
: Restricts inference. Then, sends an inference request with a correct and incorrect header to verify proper functionality.CI Pipeline ID: 20189649
Background
For more information about restricted features support in Triton, please take a look at this: [Link]
Additonal Changes Made in this PR
tritonfrontend.h
andtritonfrontend_pybind.cc
.@handle_triton_error
for non-void functions.send_and_test_inference_identity()
so that we can re-use utility function for restricted features testing.