feat: REST settings services - #5298
Conversation
Up to standards ✅🟢 Issues
|
|
@mayankansys, in general you could just re-use our existing tests by just parameterizing them. You can avoid any kind of duplication via the adapters, etc. The tests should be the existing ones just by parameterizing them so as to avoid duplication. A few of the extra tests that you have written like over-writing named objects, etc. can be kept but similarly parameterize them for grpc as well. Thank you. |
| # Helpers for transport-parametrized tests (gRPC vs REST) | ||
| # ============================================================================ | ||
|
|
||
|
|
There was a problem hiding this comment.
The settings API can be tested through either REST or gRPC interchangeably. Therefore, given any such API test, one can pass in any solver session object (or its settings attribute).
If you need all the following complications, please explain. Thanks.
| pytest.skip( | ||
| "enable_beta_features()/get_fluent_version() are not applicable to REST transport" | ||
| ) | ||
|
|
There was a problem hiding this comment.
I prefer to simply define what is to be tested fully from the top without any internal conditional skipping. That provides a clean, well defined view of what is and is not covered.
This simple example gets the basic idea across by defining what is to be run from the top and contains no conditionals. It lets the code decide what happens.
# define a test function that only works with gRPC backend:
def do_test_some_solver_features(solver): # ...
# define the test only for gRPC:
def test_some_solver_features(grpc_solver_session):
do_test_some_solver_features(grpc_solver_session)
# that inflates the test code so we can just do it in one go:
def test_some_solver_features(grpc_solver_session): # ...
# @pytest.mark is also possible above but unnecessary
# define a test function that works with either backend:
def do_test_some_other_solver_features(solver): # ...
# define both tests:
# gRPC:
def test_some_other_solver_features(grpc_solver_session):
do_test_some_other_solver_features(grpc_solver_session)
# http:
def test_some_other_solver_features(http_solver_session):
do_test_some_other_solver_features(http_solver_session)
# again, that inflates the test code so we can make use of parametrised fixture selection:
@pytest_fixture(params=...)
def solver_session(...)
return { ...
# run the test with either backend, gRPC or http:
def test_some_other_solver_features(solver_session): # ...
There was a problem hiding this comment.
Thanks @seanpearsonuk, This is exactly what we should so.
Co-authored-by: mayankansys <233041173+mayankansys@users.noreply.github.com>
…deselect rest tests by default Co-authored-by: mayankansys <233041173+mayankansys@users.noreply.github.com>
5492a9c to
d15301f
Compare
…into feat/REST_settings
Context
PyFluent previously supported communication with Fluent solvers exclusively through gRPC-based transport, which requires additional infrastructure and dependencies. There was a need to demonstrate that PyFluent can run seamlessly over both REST and gRPC, allowing users to choose their preferred transport mechanism.
Change Summary
This PR introduces comprehensive REST/HTTP transport support to PyFluent with the following key additions:
New RestSettings class — A settings service wrapper that implements the AbstractSettings interface by delegating all operations to a FluentRestClient instance. Includes schema normalization to convert REST's native hyphenated Scheme keys (e.g., object-type, user-creatable?) to underscore format matching gRPC conventions.
New HttpSolver class — A standalone, lightweight solver session that communicates exclusively over REST, completely independent of gRPC infrastructure. Settings classes are built at runtime from get_static_info() with no need for pre-generated modules.
Factory method — Convenience classmethod to create an HttpSolver instance from a URL and authentication token, making REST-based sessions accessible through the standard Solver interface.
Comprehensive tests — Unit and integration tests covering REST settings wildcard detection, static-info key normalization, nested schema recursion, and end-to-end REST-based workflows.
Rationale
Impact