Skip to content
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

Add server tutorials to the main tutorials branch #1891

Open
wants to merge 3 commits into
base: doc/new-tutorials-section
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/source/user_guide/tutorials/dpf_server/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ This tutorial explains how to manipulate DPF client-server architecture
:margin: 2

.. grid-item-card:: Switch between local and remote server
:link: ref_tutorials
:link: user_guide_server_types
:link-type: ref
:text-align: center

This tutorial
explains how to manipulate DPF client-server architecture

.. toctree::
:maxdepth: 2
:hidden:

server_types.rst

Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,64 @@ using the :class:`InProcess <ansys.dpf.core.server_types.InProcessServer>` class

from ansys.dpf import core as dpf
local_server = dpf.start_local_server()
local_server
print(local_server)

.. rst-class:: sphx-glr-script-out

.. code-block:: none

<ansys.dpf.core.server_types.InProcessServer object at ...>
.. jupyter-execute::
:hide-code:

from ansys.dpf import core as dpf
local_server = dpf.start_local_server()
print(local_server)

This DPF Server can now be used to instantiate models, operators, and more.

.. code-block::

# instantiate an operator
local_operator = dpf.operators.results.displacement(server=local_server)

# instantiate a model
from ansys.dpf.core import examples
local_model = dpf.Model(examples.find_simple_bar(), server=local_server)


DPF Server through the network using gRPC
-----------------------------------------

The :class:`GrpcServer <ansys.dpf.core.server_types.GrpcServer>` class is used
to enable gRPC communication:
to enable gRPC communication:

.. code-block::

from ansys.dpf import core as dpf
grpc_server_config = dpf.AvailableServerConfigs.GrpcServer
grpc_server = dpf.start_local_server(config=grpc_server_config)
grpc_server
print(grpc_server)

.. rst-class:: sphx-glr-script-out

.. code-block:: none

<ansys.dpf.core.server_types.GrpcServer object at ...>
.. jupyter-execute::
:hide-code:

from ansys.dpf import core as dpf
grpc_server_config = dpf.AvailableServerConfigs.GrpcServer
grpc_server = dpf.start_local_server(config=grpc_server_config)
print(grpc_server)

You can obtain the server port and IP address:

.. code-block::

print(grpc_server)

.. rst-class:: sphx-glr-script-out

.. code-block:: none
.. jupyter-execute::
:hide-code:

DPF Server: {'server_ip': '127.0.0.1', 'server_port': 50052, 'server_process_id': 9999, 'server_version': '6.0', 'os': 'nt'}
print(grpc_server)

From another machine, you can connect remotely to this DPF Server and instantiate models, operators, and more:

Expand Down
Loading