-
Notifications
You must be signed in to change notification settings - Fork 156
adding tenantId to the connector executor when this is inline connector #3837
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,10 @@ public void initModel(MLModel model, Map<String, Object> params, Encryptor encry | |
Connector connector = model.getConnector().cloneConnector(); | ||
connector | ||
.decrypt(PREDICT.name(), (credential, tenantId) -> encryptor.decrypt(credential, model.getTenantId()), model.getTenantId()); | ||
// This situation can only happen for inline connector where we don't provide tenant id. | ||
if (connector.getTenantId() == null && model.getTenantId() != null) { | ||
connector.setTenantId(model.getTenantId()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering why we don't set tenantId for the inline connector when registering the model which can make a consistent connector to use anywhere. Now the cloned connector and connectorExecutor has the tenantId but the original connector doesn't has it. If we want to use model.getConnector in code to reference, we have to check tenantId again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Model already has the tenantId information. So in the same entity to have the tenant id twice seems like redundant to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's pros and cons. I am OK to merge it for now, we can have more discussion later. |
||
} | ||
this.connectorExecutor = MLEngineClassLoader.initInstance(connector.getProtocol(), connector, Connector.class); | ||
this.connectorExecutor.setScriptService((ScriptService) params.get(SCRIPT_SERVICE)); | ||
this.connectorExecutor.setClusterService((ClusterService) params.get(CLUSTER_SERVICE)); | ||
|
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.
if model.getTenantId == null, this code won't do anything. But if that is an edge case to avoid in serverLess, you should check it and throw an exception.
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.
If both are null, that means this is a single tenant environment, so we don't need this anyway.