Updated opensearch-php to reflect the latest OpenSearch API spec
Shouldn't be merged. ML namespace needs to be patched in generator to prevent breaking changes.
Let's block this PR to avoid merging accidentally.
@saimedhi are you fixing the
mlpart?
yes
@saimedhi There's another change in the spec that you might need to handle, similar to https://github.com/opensearch-project/opensearch-py/pull/777, see https://github.com/opensearch-project/opensearch-api-specification/pull/416 where node_id_or_metric should not be added as a parameter, but the individual items with title should.
@saimedhi There's another change in the spec that you might need to handle, similar to opensearch-project/opensearch-py#777, see opensearch-project/opensearch-api-specification#416 where
node_id_or_metricshould not be added as a parameter, but the individual items withtitleshould.
I'll take a look at this when I have a moment. Thank you :)
We would need to keep the name MachineLearningNamespace until the next major otherwise it's a type break
We would need to keep the name
MachineLearningNamespaceuntil the next major otherwise it's a type break
Hi @shyim,
-
The name was changed from MachineLearningNamespace to MlNamespace during the endpoint generation using the spec. PR.
-
I tested the change here to see if it's breaking. But didn't notice any breaking.
-
If it's a type break, we can modify the generator here in a way that if $namespace is 'Ml', replace it with 'MachineLearning.'
-
With the above step, ensure that the property ml here is not replaced with machineLearning during generation, as it creates a breaking change. A few small changes might need to go to ClientEndpoint.php to prevent this.
-
Please try to contribute if you find some time. Thank you.
Renaming a class or namespace is a break, I would stick to Ml as previous.
maybe we should add https://github.com/Roave/BackwardCompatibilityCheck to the pipelines
Renaming a class or namespace is a break, I would stick to
Mlas previous.
Do client users have to reference this namespace explicitly, meaning why is it considered a breaking change?
I think long term we'd like the generated code to look more like the spec. Is there a way to patch/subclass the generated default name into a namespace for backwards compatibility. If not, yes.
maybe we should add https://github.com/Roave/BackwardCompatibilityCheck to the pipelines
Definitely. Open an issue so we don't forget?
I think @saimedhi isn't working on the fix. If you have time appreciate it, if not maybe I can take it up next. LMK!
One of the tests failed because closeCursor was renamed.
Note: Using configuration file /home/runner/work/opensearch-php/opensearch-php/phpstan.neon.dist.
Error: Call to an undefined method OpenSearch\Namespaces\SqlNamespace::closeCursor().
------ ----------------------------------------------------
Line tests/Namespaces/SqlNamespaceTest.php
------ ----------------------------------------------------
83 Call to an undefined method
OpenSearch\Namespaces\SqlNamespace::closeCursor().
------ ----------------------------------------------------
@saimedhi What's the right way to deal with the sql namespace that gets generated with different function names, like here where closeCursor got renamed to close? I'd like to define closeCursor as a deprecated one that calls close. Where do I put this code?
@shyim Take a look at this change and comments re: backwards-compatibility from @saimedhi above. Does this work for you or do we need to do something else with this PR?
One of the tests failed because
closeCursorwas renamed.Note: Using configuration file /home/runner/work/opensearch-php/opensearch-php/phpstan.neon.dist. Error: Call to an undefined method OpenSearch\Namespaces\SqlNamespace::closeCursor(). ------ ---------------------------------------------------- Line tests/Namespaces/SqlNamespaceTest.php ------ ---------------------------------------------------- 83 Call to an undefined method OpenSearch\Namespaces\SqlNamespace::closeCursor(). ------ ----------------------------------------------------@saimedhi What's the right way to deal with the sql namespace that gets generated with different function names, like here where
closeCursorgot renamed toclose? I'd like to definecloseCursoras a deprecated one that callsclose. Where do I put this code?
@dblock , It needs to be added here https://github.com/opensearch-project/opensearch-php/tree/main/util/EndpointProxies.
Please refer point in time APIs in above link. Thank you.
@saimedhi one more, in https://github.com/opensearch-project/opensearch-php/pull/213/files#diff-1e5c4748694dfd5e04e32ebaaaaf36245262522d929e9d9232d8afc2c32352b3L41 the API spec was changed to un-confuse metric and node_id. What's the best way to restore this behavior inside getUri?
@saimedhi one more, in https://github.com/opensearch-project/opensearch-php/pull/213/files#diff-1e5c4748694dfd5e04e32ebaaaaf36245262522d929e9d9232d8afc2c32352b3L41 the API spec was changed to un-confuse metric and node_id. What's the best way to restore this behavior inside
getUri?
@dblock, I see that it is handled in opensearch-py here.
Similarly it can be done in opensearch-php here.
I hope I rightly answered your question. Thanks.
@dblock it's fine for me
@saimedhi one more, in https://github.com/opensearch-project/opensearch-php/pull/213/files#diff-1e5c4748694dfd5e04e32ebaaaaf36245262522d929e9d9232d8afc2c32352b3L41 the API spec was changed to un-confuse metric and node_id. What's the best way to restore this behavior inside
getUri?@dblock, I see that it is handled in opensearch-py here.
Similarly it can be done in opensearch-php here.
I hope I rightly answered your question. Thanks.
Thanks. The best workaround I found is https://github.com/opensearch-project/opensearch-php/pull/221. Please review.
Codecov Report
Attention: Patch coverage is 6.67870% with 517 lines in your changes missing coverage. Please review.
Project coverage is 28.07%. Comparing base (
fc749ea) to head (27810f2). Report is 7 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #213 +/- ##
============================================
+ Coverage 22.01% 28.07% +6.06%
- Complexity 2260 2707 +447
============================================
Files 309 377 +68
Lines 9026 11056 +2030
============================================
+ Hits 1987 3104 +1117
- Misses 7039 7952 +913
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I extracted the SQL backwards-compatibility fixes from here into https://github.com/opensearch-project/opensearch-php/pull/222, once that's merged the cron will reset this PR and all tests should pass. @shyim @saimedhi