Skip to content

Commit

Permalink
Doc fix (#203)
Browse files Browse the repository at this point in the history
* Update sr_python_walkthrough.rst

* Update sr_python_walkthrough.rst

* Update sr_cpp_walkthrough.rst

* Update sr_python_walkthrough.rst

* Update sr_cpp_walkthrough.rst

* Update sr_cpp_walkthrough.rst

* Update sr_python_walkthrough.rst

* Update sr_cpp_walkthrough.rst

* Update sr_python_walkthrough.rst
  • Loading branch information
amandarichardsonn authored Jun 21, 2022
1 parent 9845fb3 commit 6c96157
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
23 changes: 12 additions & 11 deletions doc/sr_cpp_walkthrough.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ C++
***


In this section, examples are presented using the SmartRedis C++
API to interact with the RedisAI tensor, model, and script
data types. Additionally, an example of utilizing the
SmartRedis ``DataSet`` API is also provided.
This section presents examples that use the SmartRedis C++ API to
interact with the RedisAI tensor, model, and script data types.
Additionally, this section demonstrates an example of utilizing
the SmartRedis ``DataSet`` API.



Expand All @@ -16,8 +16,8 @@ SmartRedis ``DataSet`` API is also provided.


.. note::
The C++ API examples are written
to connect to a clustered database or clustered SmartSim Orchestrator.
The C++ API examples are written to connect to a clustered database
or clustered SmartSim Orchestrator.
Update the ``Client`` constructor ``cluster`` flag to `false`
to connect to a single shard (single compute host) database.

Expand All @@ -27,7 +27,7 @@ SmartRedis ``DataSet`` API is also provided.
Tensors
=======

The following example shows how to send a receive a tensor using the
The following example shows how to send and receive a tensor using the
SmartRedis C++ client API.

.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_put_get_3D.cpp
Expand All @@ -42,7 +42,7 @@ For further information about datasets, please refer to the :ref:`Dataset
section of the Data Structures documentation page <data_structures_dataset>`.

The code below shows how to store and retrieve tensors and metadata
which belong to a ``DataSet``.
that belong to a ``DataSet``.

.. literalinclude:: ../smartredis/examples/serial/cpp/smartredis_dataset.cpp
:linenos:
Expand All @@ -54,7 +54,7 @@ which belong to a ``DataSet``.
Models
======

The following example shows how to store, and use a DL model
The following example shows how to store and use a DL model
in the database with the C++ Client. The model is stored as a file
in the ``../../../common/mnist_data/`` path relative to the
compiled executable. Note that this example also sets and
Expand All @@ -69,8 +69,9 @@ executes a preprocessing script.
Scripts
=======

The example in :ref:`SR CPP Models` shows how to store, and use a PyTorch script
in the database with the C++ Client. The script is stored a file
The example in :ref:`SR CPP Models` shows how to store and use
a PyTorch script in the database with the C++ Client.
The script is stored as a file
in the ``../../../common/mnist_data/`` path relative to the
compiled executable. Note that this example also sets and
executes a PyTorch model.
Expand Down
36 changes: 16 additions & 20 deletions doc/sr_python_walkthrough.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
Python
******

This section will detail the SmartRedis Python client and how to
use it within SmartSim applications and RedisAI in general.
This section details the SmartRedis Python client to demonstrate its general use within SmartSim applications and RedisAI.


.. note::
The Python API examples are written to connect to a
database at ``127.0.0.1:6379``. When running this example,
ensure that the address and port of your Redis instance are used.
The following Python API examples connect to a
database at the address:port ``127.0.0.1:6379``. When replicating the following example,
ensure that you use the address:port of your local Redis instance.



Tensors
=======

The Python client has the ability to send and receive tensors from
the Redis database. The tensors are stored in the Redis database
as RedisAI data structures. Additionally, Python client API
The Python client can send and receive tensors from the Redis database,
where they are stored as RedisAI data structures. Additionally, Python client API
functions involving tensor data are compatible with Numpy arrays
and do not require any other data types.
and do not require other data types.

.. literalinclude:: ../smartredis/examples/serial/python/example_put_get_tensor.py
:language: python
Expand All @@ -36,7 +34,7 @@ The Python client can store and retrieve tensors and metadata in datasets.
For further information about datasets, please refer to the :ref:`Dataset
section of the Data Structures documentation page <data_structures_dataset>`.

The code below shows how to store and retrieve tensors which belong to a ``DataSet``.
The code below shows how to store and retrieve tensors that belong to a ``DataSet``.

.. literalinclude:: ../smartredis/examples/serial/python/example_put_get_dataset.py
:language: python
Expand All @@ -48,15 +46,15 @@ Models

The SmartRedis clients allow users to set and use a PyTorch, ONNX, TensorFlow,
or TensorFlow Lite model in the database. Models can be sent to the database directly
from memory or from a file. The code below illustrates how a
from memory or a file. The code below illustrates how a
jit-traced PyTorch model can be used with the Python client library.

.. literalinclude:: ../smartredis/examples/serial/python/example_model_torch.py
:language: python
:linenos:
:lines: 26-71

Models can also be set from a file, as in the code below.
Users can set models from a file, as shown in the code below.

.. literalinclude:: ../smartredis/examples/serial/python/example_model_file_torch.py
:language: python
Expand All @@ -67,27 +65,25 @@ Scripts
=======

Scripts are a way to store python-executable code in the database. The Python
client can send scripts to the dataset from a file, or directly from memory.
client can send scripts to the dataset from a file or directly from memory.

As an example, the code below illustrates how a function can be defined and sent
to the database on the fly, without storing it in an intermediate file.
The code below illustrates how to avoid storing a function in an intermediate file.
With this technique, we can define and send a function to the database on the fly.

.. literalinclude:: ../smartredis/examples/serial/python/example_script.py
:language: python
:linenos:
:lines: 26-66

The code below shows how to set a script from a file. Running the
script set from file uses the same API calls as the example shown
above.
The code below shows how to set a script from a file. Running the script set from
the file uses the same API calls as in the example shown above.

.. literalinclude:: ../smartredis/examples/serial/python/example_script_file.py
:language: python
:linenos:
:lines: 26-41

The content of the script file has to be written
in Python. For the example above, the file ``data_processing_script.txt``
This file must be a valid Python script. For the example above, the file ``data_processing_script.txt``
looks like this:

.. literalinclude:: ../smartredis/examples/serial/python/data_processing_script.txt
Expand Down

0 comments on commit 6c96157

Please sign in to comment.