opensearch-php icon indicating copy to clipboard operation
opensearch-php copied to clipboard

Updated opensearch-php to reflect the latest OpenSearch API spec

Open opensearch-trigger-bot[bot] opened this issue 1 year ago • 8 comments

Updated opensearch-php to reflect the latest OpenSearch API spec Date: 2024-07-30

Shouldn't be merged. ML namespace needs to be patched in generator to prevent breaking changes.

saimedhi avatar Jul 14 '24 06:07 saimedhi

Let's block this PR to avoid merging accidentally.

@saimedhi are you fixing the ml part?

yes

saimedhi avatar Jul 14 '24 23:07 saimedhi

@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.

dblock avatar Jul 16 '24 19:07 dblock

@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_metric should not be added as a parameter, but the individual items with title should.

I'll take a look at this when I have a moment. Thank you :)

saimedhi avatar Jul 16 '24 20:07 saimedhi

We would need to keep the name MachineLearningNamespace until the next major otherwise it's a type break

shyim avatar Jul 17 '24 05:07 shyim

We would need to keep the name MachineLearningNamespace until 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.

saimedhi avatar Jul 17 '24 06:07 saimedhi

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

shyim avatar Jul 19 '24 06:07 shyim

Renaming a class or namespace is a break, I would stick to Ml as 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!

dblock avatar Jul 19 '24 13:07 dblock

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?

dblock avatar Aug 09 '24 20:08 dblock

@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?

dblock avatar Aug 09 '24 20:08 dblock

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?

@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 avatar Aug 09 '24 20:08 saimedhi

@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 avatar Aug 09 '24 21:08 dblock

@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.

saimedhi avatar Aug 09 '24 21:08 saimedhi

@dblock it's fine for me

shyim avatar Aug 09 '24 23:08 shyim

@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.

dblock avatar Aug 12 '24 12:08 dblock

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.

Files Patch % Lines
...c/OpenSearch/Namespaces/ObservabilityNamespace.php 0.00% 45 Missing :warning:
src/OpenSearch/Namespaces/QueryNamespace.php 0.00% 33 Missing :warning:
src/OpenSearch/Namespaces/PplNamespace.php 0.00% 26 Missing :warning:
src/OpenSearch/Namespaces/SqlNamespace.php 31.57% 26 Missing :warning:
...penSearch/Endpoints/Observability/UpdateObject.php 0.00% 25 Missing :warning:
...penSearch/Endpoints/Observability/DeleteObject.php 0.00% 20 Missing :warning:
...c/OpenSearch/Endpoints/Observability/GetObject.php 0.00% 20 Missing :warning:
...rc/OpenSearch/Endpoints/Query/DatasourceDelete.php 0.00% 20 Missing :warning:
.../OpenSearch/Endpoints/Query/DatasourceRetrieve.php 0.00% 20 Missing :warning:
src/OpenSearch/Endpoints/Ppl/Explain.php 0.00% 19 Missing :warning:
... and 22 more
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.

codecov[bot] avatar Aug 12 '24 14:08 codecov[bot]

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

dblock avatar Aug 12 '24 14:08 dblock