Repository navigation
Conversation
alpkom
left a comment
There was a problem hiding this comment.
Could you adjust the RPT mock responses in the tests/mock.py to reflect the API changes?
And maybe adjust the integration_tests as well, in order to make use of the new attributes in the API?
Current tests are failing partly because of the optional vs. required behavior of |
It's not only about fixing tests. We need to adjust the mock to reflect the backend behavior properly. |
|
In the current test environment, there is no such RPT-1.6 deployment, and we need to deploy it for the tests to work |
|
|
||
| name: str | ||
| prediction_placeholder: str = "[PREDICT]" | ||
| prediction_placeholder: Optional[Union[str, int, float]] |
There was a problem hiding this comment.
This is a mandatory field, not optional.
There was a problem hiding this comment.
"TargetColumnConfig": {
...,
"properties": {
..., "prediction_placeholder": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "null"
}
],
"description": "The prediction placeholder in any column for which to predict a value. The model will predict a value for all table cells containing this value.",
"title": "Prediction Placeholder"
}, ..., "required": [
"name",
"prediction_placeholder"
], ...According to this spec, yes, it is required. But still, it needs to be a nullable number | string union. Is it wrong to set optional here?
There was a problem hiding this comment.
It might be actually the case that it's optional, and they just defined it in a weird way in the spec.
To be on the safe side, could you find out, how the server behaves when it's sent as null vs. when it's not sent at all as part of the request? And how would the model know what to predict at all, if it's not provided?
There was a problem hiding this comment.
My interpretation: It is indeed required (not send at all will error) and if it is sent as null then all null entries in the table will be replaced by the RPT predictions.
The current code should enforce this if I understand the Pydantic conventions correctly. Though Union[str, int, float, None] should be the same and may make intentions more clear. All under the assumptions that it is indeed required ofc.
There was a problem hiding this comment.
I didn't fully get the difference between Optional[Union[str, int, float]] and Union[str, int, float, None]. Subjectively, the latter seems to have a "required" energy by leaving out Optional type. But I believe it might be more consistent with the overall repo to still keep the first option with explicit Optional, so I would rather keep it as it is. At the end, I leave it up to you, what do you think?
There was a problem hiding this comment.
Both should be identical on a technical level. If you prefer the Optional one, then I'm fine with that. More important is to double-check that the field is indeed required.
There was a problem hiding this comment.
I still believe it's counterintuitive to set a default value implicitly for a parameter which is required by the backend. (I don't think it matters if the 'null' is an accepted value for that parameter or not.)
Regarding the consistency with the rest of the SDK: for the cases where SDK defines a parameter as Optional, that parameters is actually optional in the backend, as well. (Let me know if there's an exception to this). So that's where this case differs from the rest. This one is required by the backend. It just happens to be that 'null' is a valid value.
There was a problem hiding this comment.
If I understand correctly, then only doing prediction_placeholder: Optional[Union[str, int, float]] = None would set None implicitly as default value. In the code above (without = None), it would set no default value and Pydantic excepts either None, str, int, float but one of those needs to be explicitly given.
|
@alpkom Here is my thought process: How do we happy-test if there is only one client (which is 1.6)? For example in case of Since we only have decided to keep only one RPT client (which is fully 1.6 compliant) and want to also preserve 1.0 and 1.5 functionalities, the only way out is to automatically detect what version the current RPT deployment belongs to. Names can be customized, so I don't think pattern-matching on deployment names is a maintainable solution. Does that match to your comments? |
We need to be backward compatible. So, for the newly added optional parameters, don't set the default value at all. Leave them optional, without a default value, so if the parameter is not set, they'll be dropped when the HTTP request is formed. No harm done, since the backend will anyways set the default value. Only reason we set them in SDK was convenience. |
| from tests.mock import ( | ||
| get_mocked_ai_core_client, | ||
| sap_rpt_mock_response_code_0, | ||
| sap_rpt_mock_response_code_0_with_explanations, |
There was a problem hiding this comment.
This is imported but not used. So, the new mock response is not tested at all.
Context
Closes SAP/ai-sdk-python-backlog#17.
What this PR does and why it is needed
This PR aims to upgrade the RPT Client logic on the SDK side for the newest version 1.6, grouped in 6 significant sections:
components.schemas.SchemaFieldConfigfrom spec: We add the missing data types to the dtype field in the currentDataTypecomponents.schemas.PredictionResultfrom spec:confidence_intervalis added into Predictionitem (current implementation). And also, we addminimum/maximumbounds toconfidenceas in 1.6.components.schemas.PredictionConfigfrom spec:explanationsare added to PredictionConfig response, so that it is not silently discarded.context_modeis added to PredictionConfig and ResponseMetadata (1.6 specific issue).components.schemas.TargetColumnConfigfrom spec:top_kis added to TargetColumn. Second of all,prediction_placeholderis casted to be nullable: as of now >=1.5 allowsnullornumericas placeholders, while current model enforcesstr. Corresponding linkcomponents.schemas.{ExplanationConfig / ExplanationResult}models didn't exist before, so they are implemented from scratch.Definition of Done