Skip to content

Commit 1821f16

Browse files
committed
andy edits
1 parent 733f527 commit 1821f16

File tree

11 files changed

+131
-37
lines changed

11 files changed

+131
-37
lines changed

doc/source/abstraction/data_transfer_and_representation.rst

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
Data Transfer and Representation
2-
================================
3-
When transferring data from a local application or remote service, you
4-
do not want to return raw JSON, gRPC classes, Python lists, or, even worse,
5-
strings. A best practice is to represent arrays as ``numpy.ndarray`` or
6-
``pandas.DataFrame`` objects.
1+
Data Transfer and Abstraction
2+
=============================
3+
Abstracted APIs should attempt to hide the implementation details of
4+
the remote or local API in a well organized data model. This data
5+
model should avoid returning raw JSON, gRPC messages, SWIG objects, or
6+
.NET objects. Rather, it preferable to return standard Python objects
7+
like lists, strings, dictionaries when useful, and NumPy arrays or
8+
pandas dataframes for more complex data.
79

8-
This example generates a simple mesh in MAPDL:
10+
For example, consider a simple mesh in MAPDL:
911

1012
.. code:: python
1113
@@ -20,7 +22,7 @@ command or to write it to disk using the ``CDWRITE`` command. Both
2022
methods are remarkably inefficient, requiring:
2123

2224
- Serializing the data to ASCII on the server
23-
- Transfering the data
25+
- Transferring the data
2426
- Deserializing the data within Python
2527
- Converting the data to an array
2628

@@ -63,6 +65,49 @@ within the MAPDL database.
6365
[0.75, 0.5 , 0.5 ]])
6466
6567
68+
REST vs RPC Data and Model Abstraction
69+
--------------------------------------
70+
Because of the nature of Ansys's products, our applications and
71+
services can either fit into the RPC interface where the API is
72+
centered around operations and commands, or the REST model which is
73+
centered around resources. Regardless of the the interface style,
74+
there are several items to consider.
75+
76+
77+
API Chattiness
78+
~~~~~~~~~~~~~~
79+
APIs must be efficient to avoid creating chatty I/O. Because many of
80+
Ansys's products fit well with the RPC API implementation, there is a
81+
temptation to design APIs that require constant communication with the
82+
remote or local service. However, just because RPC interfaces can,
83+
does not mean they should as it should be assumed that each RPC call
84+
takes significant time to execute.
85+
86+
One way to avoid this approach is to either serialize several
87+
"commands" for services that employ an internal "command pattern" for
88+
data exchange. Another approach is to encapsulate the data model
89+
entirely on the server and avoid data transfer whenever possible and
90+
expose only a limited number of RPC methods in the front-facing API.
91+
92+
Compatibility and Efficiency
93+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94+
APIs should be designed to be compatible with as many languages and
95+
platforms as possible. `gRPC`_ for RPC-like interfaces should be one
96+
of the first choices due to its compatibility with nearly all popular
97+
languages and its efficiency over REST in terms of speed, memory, and
98+
payload size.
99+
100+
Typically, data exchange over REST should be limited to short messages
101+
exchanged over JSON, whereas gRPC can handle large data transfer and
102+
even allows for bidirectional streaming.
103+
104+
In general, it is preferable to choose gRPC over REST due to the
105+
performance benefits of a binary compatible protocol. While REST
106+
carries a variety of benefits, for complex client/server interactions,
107+
it is best to have an interface that can efficiently exchange a wide
108+
variety of data formats and messages.
109+
110+
66111

67112
.. _gRPC: https://grpc.io/
68113
.. _pythoncom: http://timgolden.me.uk/pywin32-docs/pythoncom.html

doc/source/documentation/class_documentation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ parameters are automatically assigned to the class.
4040
Auto-Generated Documentation
4141
----------------------------
4242

43-
To automatically genereate class descriptions, use either the ``autoclass``
43+
To automatically generate class descriptions, use either the ``autoclass``
4444
or ``autosummary`` directive.
4545

4646
For simple classes, you can use the ``autoclass`` directive::

doc/source/documentation/coding_style.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ beyond `PEP8 <https://www.python.org/dev/peps/pep-0008/>`__.
99

1010
For example, `Stack Overflow Answer <https://stackoverflow.com/questions/2536307>`_
1111
outlines deprecation best practices and a `Deprecation library <https://deprecation.readthedocs.io/>`_
12-
aready exists. However, there is no official guidance regarding deprecating features
12+
already exists. However, there is no official guidance regarding deprecating features
1313
in an API within Python. This page seeks to clarify this issue and others.
1414

1515
Aside from the following PyAnsys-specific directives, the best coding practice is to

doc/source/documentation/docstrings.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ documentation style. To use `numpydoc`_ add the following to your
1515
1616
Minimum Requirements
1717
--------------------
18-
PyAnsys libary docstrings contain at a minimum the following
18+
PyAnsys library docstrings contain at a minimum the following
1919
`numpydoc`_ sections:
2020

2121
* `Short description <https://numpydoc.readthedocs.io/en/latest/format.html#short-summary>`_.
@@ -25,7 +25,7 @@ PyAnsys libary docstrings contain at a minimum the following
2525
* `Examples <https://numpydoc.readthedocs.io/en/latest/format.html#examples>`_
2626

2727
These sections should follow the numpydoc standards. To avoid
28-
inconsistencies between PyAnsys libaries, adhere to the following
28+
inconsistencies between PyAnsys libraries, adhere to the following
2929
additional standards:
3030

3131

@@ -38,7 +38,7 @@ Always specify the type, and whenever necessary, provide the full class name::
3838
my_obj : :class:`ansys.<product>.<library>.FooClass`
3939
Description of FooClass.
4040
some_int : int
41-
Some interger value.
41+
Some integer value.
4242

4343
.. note::
4444
These parameter descriptions have punctuation.

doc/source/documentation/index.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _api_documentation:
2+
13
API Documentation
24
#################
35
Good documentation drives library adoption and usage and is the
@@ -9,16 +11,16 @@ documentation or examples they are presented with.
911
Good API documentation provides the following:
1012

1113
* Increased adoption and improved experience for the developers using
12-
the API or libary.
14+
the API or library.
1315
* Reduction in the time spent on-boarding new users (both contributors
1416
and users of the project).
15-
* Better maintainance of the codebase. The time spent reading the
17+
* Better maintenance of the code base. The time spent reading the
1618
source is often orders of magnitude greater than the time spent
1719
writing it. Well documented code (both in user-facing docstrings
18-
and developer comments) pays dividends in code maintaince.
20+
and developer comments) pays dividends in code maintenance.
1921
* Reduces the amount of time spent understanding the features API.
2022

21-
The documentation for a PyAnsys libary should contain the following
23+
The documentation for a PyAnsys library should contain the following
2224

2325
* Module, class, method, and function documentation strings. See
2426
:ref:`docstrings`.

doc/source/images/diagram.png

-87 Bytes
Loading

doc/source/library_description/index.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ This figure shows the general pattern that each PyAnsys library should follow:
2222
.. image:: ../images/diagram.png
2323
:alt: Overview Diagram
2424

25-
The Ansys product or service exposes an interface that is locally accessible
26-
(in the case of .NET using `pythoncom`_, `SWIG`_, or `C extensions`_) or a
27-
service that is both locally and remotely accessible (`REST`_ or `gRPC`_).
28-
This interface is referred to as the API (Application Programming Interface).
29-
While this API can be directly accessed, this often results in unreadable
30-
and unmaintainable code that forces users to rewrite setup boilerplate and
31-
other methods from scratch.
25+
The Ansys product or service exposes an interface that is locally
26+
accessible (for example, .NET using `pythoncom`_, `SWIG`_, or `C
27+
extensions`_) or a service that is both locally and remotely
28+
accessible (`REST`_ or `gRPC`_). This interface is referred to as the
29+
API (Application Programming Interface). While this API can be
30+
directly accessed, this often results in unreadable and unmaintainable
31+
code that forces users to rewrite setup boilerplate and other methods
32+
from scratch. Therefore, the best practice is to create a Python layer
33+
that maps the raw API into a carefully designed, object oriented data
34+
model and API.
3235

3336
.. toctree::
3437
:hidden:
@@ -42,6 +45,7 @@ other methods from scratch.
4245
readme_file
4346
setup_file
4447
doc_directory
48+
license
4549

4650
.. _gRPC: https://grpc.io/
4751
.. _pythoncom: http://timgolden.me.uk/pywin32-docs/pythoncom.html
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _license_file:
2+
3+
License File
4+
############
5+
PyAnsys projects are expected to have this exact license included in
6+
the root directory of their project.
7+
8+
.. include:: ../../LICENSE

doc/source/library_description/setup_file.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _setup_file:
2+
13
Setup File
24
##########
35
The setup file for a PyAnsys library package, ``setup.py``, should contain

doc/source/overview/administration.rst

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,48 @@ libraries requires that the relevant Ansys products are licensed
66
either directly or indirectly, you can distribute your custom-made
77
applications and workflows internally or externally.
88

9+
910
Licensing and Approval
1011
======================
11-
To allow for commerical use, a PyAnsys library must use the MIT
12-
license. Because this license falls in the BSD-style license
13-
class, you do not have to provide any source code when releasing
14-
new software. To make your PyAnsys library suitable for commercial
15-
use, you need only to include the original MIT license in the
16-
reused code.
12+
To allow for commercial use, a PyAnsys library must use the MIT
13+
license. Because this license falls in the BSD-style license class,
14+
PyAnsys libraries can be used as a shared library with no
15+
restrictions. This follows the pattern of including a PyAnsys as a
16+
dependency in ``install_requires`` in the ``setup.py``.
17+
18+
Should you choose to copy and include any PyAnsys project source uses,
19+
all you have to do to to make your library suitable for commercial
20+
use, is to a copy of the original PyAnsys MIT license in the reused
21+
code.
1722

1823
To view this license, see the `LICENSE` file in the root directory
1924
of this repository. This file must be included in the root
2025
directory of the repository for every PyAnsys library.
2126

27+
2228
Project Approval
2329
================
24-
Exposing new Ansys technologies through the PyAnsys project is
25-
subject to an internal review and decision process. Reach out
26-
to Stephane Marguerin and Alexander Kaszynski for any requests.
30+
Exposing new Ansys technologies through the PyAnsys project is subject
31+
to an internal review and decision process. Please reach out to
32+
Stephane Marguerin or Alexander Kaszynski for any requests.
33+
2734

28-
Repository Management
29-
=====================
30-
(To Be Developed)
35+
Repository Management and Standards
36+
===================================
37+
Each PyAnsys repository should at the minimum be administrated by a
38+
single individual with "Admin" permissions over the repository. This
39+
enables them to override any blocking pull requests or to change the
40+
settings for that repository (e.g. GitHub pages, repository
41+
description, managing branch protections).
3142

43+
Each repository is expected to follow a minimum set of standards:
3244

45+
- Minimum code standards following PEP8 and described in <REF Code
46+
Guidelines Section>
47+
- CI/CD using GitHub actions or Azure Devops enforcing coding standards.
48+
- Publicly hosted documentation detailing API with examples. See
49+
:ref:`api_documentation`.
50+
- Unit testing with at least 80% test coverage.
51+
- Infrastructure in place to deploy the library as a package on `PyPi
52+
<https://pypi.org/>`_
53+
- Proper license file and author (see :ref:`setup_file` and `ref:`license_file`)

0 commit comments

Comments
 (0)