Skip to content

Commit 2087acd

Browse files
PipKatklmcadams
andauthored
Overall doc edit for public release (#278)
Co-authored-by: Kerry McAdams <58492561+klmcadams@users.noreply.github.com> Co-authored-by: Kerry McAdams <kerry.mcadams@ansys.com>
1 parent 57b7a31 commit 2087acd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1225
-987
lines changed

README.rst

Lines changed: 57 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -31,159 +31,60 @@ PyHPS
3131
:alt: Black
3232

3333

34-
A Python client library for the Ansys HPC Platform Services.
35-
36-
How to install
37-
--------------
38-
39-
In order to install PyHPS, make sure you
40-
have the latest version of `pip`_. To do so, run:
41-
42-
.. code:: bash
43-
44-
python -m pip install -U pip
45-
46-
Then, as long as PyHPS is a private pyAnsys module not published to pypi yet, you can execute:
47-
48-
.. code:: bash
49-
50-
python -m pip install git+https://github.com/pyansys/pyhps
51-
52-
.. TODO: Enable this once pyhps is published: python -m pip install ansys-pyhps
53-
54-
Contribute
55-
----------
56-
57-
Before contributing to the project, ensure that you are thoroughly
58-
familiar with the `PyAnsys Developer's guide`_. You will
59-
need to follow these steps:
60-
61-
#. Clone this repository:
62-
63-
.. code:: bash
64-
65-
git clone https://github.com/pyansys/pyhps
66-
cd pyhps
67-
68-
#. Create a new Python environment and activate it:
69-
70-
.. code:: bash
71-
72-
# Create a virtual environment
73-
python -m venv .venv
74-
75-
# Activate it in a POSIX system
76-
source .venv/bin/activate
77-
78-
# Activate it in Windows CMD environment
79-
.venv\Scripts\activate.bat
80-
81-
# Activate it in Windows Powershell
82-
.venv\Scripts\Activate.ps1
83-
84-
#. Make sure you have the latest required build system and doc, testing, and CI tools:
85-
86-
.. code:: bash
87-
88-
python -m pip install -U pip setuptools tox
89-
python -m pip install -r requirements/requirements_build.txt
90-
python -m pip install -r requirements/requirements_doc.txt
91-
python -m pip install -r requirements/requirements_tests.txt
92-
93-
94-
#. Install the project in editable mode:
95-
96-
.. code:: bash
97-
98-
python -m pip install --editable .
99-
100-
How to testing
101-
--------------
102-
103-
This project takes advantage of `tox`_. This tool allows to automate common
104-
development tasks (similar to Makefile) but it is oriented towards Python
105-
development.
106-
107-
Using tox
108-
^^^^^^^^^
109-
110-
As Makefile has rules, `tox`_ has environments. In fact, the tool creates its
111-
own virtual environment so anything being tested is isolated from the project in
112-
order to guarantee project's integrity. The following environments commands are provided:
113-
114-
- **tox -e style**: will check for coding style quality.
115-
- **tox -e py**: checks for unit tests.
116-
- **tox -e py-coverage**: checks for unit testing and code coverage.
117-
- **tox -e doc**: checks for documentation building process.
118-
119-
120-
Raw testing
121-
^^^^^^^^^^^
122-
123-
If required, you can always call the style commands (`black`_, `isort`_,
124-
`flake8`_...) or unit testing ones (`pytest`_) from the command line. However,
125-
this does not guarantee that your project is being tested in an isolated
126-
environment, which is the reason why tools like `tox`_ exist.
127-
128-
129-
A note on pre-commit
130-
^^^^^^^^^^^^^^^^^^^^
131-
132-
The style checks take advantage of `pre-commit`_. Developers are not forced but
133-
encouraged to install this tool via:
134-
135-
.. code:: bash
136-
137-
python -m pip install pre-commit && pre-commit install
138-
139-
140-
Documentation
141-
-------------
142-
143-
For building documentation, you can manually run:
144-
145-
.. code:: bash
146-
147-
python archive_examples.py
148-
python -m sphinx -b html doc/source build/sphinx/html
149-
150-
The recommended way of checking documentation integrity is using:
151-
152-
.. code:: bash
153-
154-
tox -e doc && your_browser_name .tox/doc_out/index.html
155-
156-
157-
Distributing
158-
------------
159-
160-
If you would like to create either source or wheel files, start by installing
161-
the building requirements and then executing the build module:
162-
163-
.. code:: bash
164-
165-
python -m pip install -r requirements/requirements_build.txt
166-
python -m build
167-
python -m twine check dist/*
168-
169-
How to generate/update RMS models
170-
---------------------------------
171-
172-
173-
To generate RMS Pydantic models, first download the RMS openapi spec and save it as `rms_openapi.json` at the root of the repository.
174-
Then, run the datamodel generator:
175-
176-
.. code:: bash
177-
178-
datamodel-codegen --input .\rms_openapi.json --input-file-type openapi --output ansys/hps/client/rms/models.py --output-model-type pydantic_v2.BaseModel
179-
180-
.. LINKS AND REFERENCES
181-
.. _black: https://github.com/psf/black
182-
.. _flake8: https://flake8.pycqa.org/en/latest/
183-
.. _isort: https://github.com/PyCQA/isort
184-
.. _pip: https://pypi.org/project/pip/
185-
.. _pre-commit: https://pre-commit.com/
186-
.. _PyAnsys Developer's guide: https://dev.docs.pyansys.com/
187-
.. _pytest: https://docs.pytest.org/en/stable/
188-
.. _Sphinx: https://www.sphinx-doc.org/en/master/
189-
.. _tox: https://tox.wiki/
34+
PyHPS is a Python client library for Ansys HPC Platform Services (HPS), which is
35+
a set of technology components designed to help you manage the execution of simulations
36+
while making use of your full range of computing assets.
37+
38+
PyHPS brings Ansys HPS to your Python app. Wrapping around Ansys HPS REST APIs, PyHPS
39+
allows you to:
40+
41+
* Create projects and modify existing ones.
42+
* Monitor and manage jobs.
43+
* Run your own design exploration algorithms.
44+
* Retrieve simulation results.
45+
46+
Documentation and issues
47+
------------------------
48+
49+
Documentation for the latest stable release of PyHPS is hosted at
50+
`PyHPS documentation <https://rep.docs.pyansys.com/dev/>`_.
51+
52+
In the upper right corner of the documentation's title bar, there is an option
53+
for switching from viewing the documentation for the latest stable release
54+
to viewing the documentation for the development version or previously
55+
released versions.
56+
57+
The PyHPS documentation contains these sections:
58+
59+
- `Getting started <https://rep.docs.pyansys.com/dev/getting_started/index.html>`_: Explains
60+
how to install PyHPS in user mode.
61+
- `User guide <https://rep.docs.pyansys.com/dev/user_guide/index.html>`_: Describes the basics
62+
of how to use PyHPS to interact with Ansys HPS.
63+
- `Examples <https://rep.docs.pyansys.com/dev/examples/index.html>`_: Provides examples of how
64+
to interact with a Remote Execution Platform (REP) server in Python using PyHPS.
65+
- `API reference <https://rep.docs.pyansys.com/dev/api/index.html>`_: Describes PyHPS functions,
66+
classes, methods, and their parameters and return values so that you can understand how to
67+
interact with them programmatically
68+
- `Contribute <https://rep.docs.pyansys.com/dev/contribute.html>_`: Provides information on
69+
how to install PyHPS in developer mode and make contributions to the codebase.
70+
71+
On the `PyHPS Issues <https://github.com/ansys-internal/pyhps/issues>` page, you can
72+
create issues to report bugs and request new features. On the
73+
`PyHPS Discussions <https://github.com/ansys-internal/pyhps/discussions>`_ page or the
74+
`Discussions <https://discuss.ansys.com/>`_ page on the Ansys Developer portal,
75+
you can post questions, share ideas, and get community feedback.
76+
77+
To reach the project support team, email `pyansys.core@ansys.com <pyansys.core@ansys.com>`_.
78+
79+
License
80+
-------
81+
82+
PyHPS is licensed under the MIT license.
83+
84+
PyHPS makes no commercial claim over Ansys whatsoever. This library extends the
85+
functionality of Ansys HPC Platform Services by adding a Python interface to it
86+
without changing the core behavior or license of the original software. The use
87+
of PyHPS requires a legally licensed local copy of AEDT.
88+
89+
To get a copy of AEDT, see the `Ansys HPC Platform Services Guide <https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/hpcplat/v000/en/rep_ug/rep_ug.html>`_`
90+
in the Ansys Help.

ansys/hps/client/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
__url__ = "https://github.com/ansys-internal/pyhps"
2828

2929
# this is only a convenience to default the version
30-
# of Ansys simulation applications in pyhps examples
30+
# of Ansys simulation applications in PyHPS examples
3131
__ansys_apps_version__ = "2024 R1"

ansys/hps/client/auth/api/auth_api.py

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@
3030

3131

3232
class AuthApi:
33-
"""A python interface to the Authorization Service API.
33+
"""Provides the Python interface to the Authorization Service API.
3434
35-
Admin users with the Keycloak "manage-users" role can create new
36-
users as well as modify or delete existing ones. Other users are only allowed
35+
Admin users with the Keycloak "manage-users" role can create
36+
users as well as modify or delete existing users. Non-admin users are only allowed
3737
to query the list of existing users.
3838
3939
Parameters
4040
----------
4141
client : Client
42-
An HPS client object.
42+
HPS client object.
4343
4444
Examples
4545
--------
4646
47-
Get users whose first name contains "john":
47+
Get users whose first name contains ``john``.
4848
4949
>>> from ansys.hps.client import Client
5050
>>> from ansys.hps.client.auth import AuthApi, User
@@ -54,7 +54,7 @@ class AuthApi:
5454
>>> auth_api = AuthApi(cl)
5555
>>> users = auth_api.get_users(firstName="john", exact=False)
5656
57-
Create a new user:
57+
Create a user:
5858
5959
>>> new_user = User(
6060
... username="new_user",
@@ -72,44 +72,43 @@ def __init__(self, client):
7272

7373
@property
7474
def url(self):
75-
"""Returns the API url"""
75+
"""API URL."""
7676
return f"{self.client.url}/auth/"
7777

7878
@property
7979
def keycloak_admin_client(self) -> KeycloakAdmin:
80-
"""Returns an authenticated client for the Keycloak Admin API"""
80+
"""Authenticated client for the Keycloak Admin API."""
8181
return _admin_client(self.client)
8282

8383
def get_users(self, as_objects=True, **query_params) -> List[User]:
84-
"""Return users, filtered according to query parameters
84+
"""Get users, filtered according to query parameters.
8585
8686
Examples of query parameters are:
87-
- `username`
88-
- `firstName`
89-
- `lastName`
90-
- `exact`
87+
- ``username``
88+
- ``firstName``
89+
- ``lastName``
90+
- ``exact``
9191
92-
Pagination is also supported using the `first` and `max` parameters.
92+
Pagination is also supported using the ``first`` and ``max`` parameters.
9393
94-
For the complete list of supported query parameters, please
95-
refer to the Keycloak API documentation.
94+
For a list of supported query parameters, see the Keycloak API documentation.
9695
"""
9796
return get_users(self.keycloak_admin_client, as_objects=as_objects, **query_params)
9897

9998
def get_user(self, id: str) -> User:
100-
"""Returns the user representation for a given user id."""
99+
"""Get the user representation for a given user ID."""
101100
return get_user(self.keycloak_admin_client, id)
102101

103102
def get_user_groups(self, id: str) -> List[str]:
104-
"""Get name of groups the user belongs to"""
103+
"""Get the groups that the user belongs to."""
105104
return [g["name"] for g in self.keycloak_admin_client.get_user_groups(id)]
106105

107106
def get_user_realm_roles(self, id: str) -> List[str]:
108-
"""Get name of realm roles for a user"""
107+
"""Get the realm roles for the user."""
109108
return [r["name"] for r in self.keycloak_admin_client.get_realm_roles_of_user(id)]
110109

111110
def user_is_admin(self, id: str) -> bool:
112-
"""Check whether the user is system admin"""
111+
"""Determine if the user is a system administrator."""
113112

114113
from ansys.hps.client.jms import JmsApi
115114

@@ -131,28 +130,36 @@ def user_is_admin(self, id: str) -> bool:
131130
return False
132131

133132
def create_user(self, user: User, as_objects=True) -> User:
134-
"""Create a new user.
135-
136-
Args:
137-
user (:class:`ansys.hps.client.auth.User`): A User object. Defaults to None.
138-
as_objects (bool, optional): Defaults to True.
133+
"""Create a user.
134+
135+
Parameters
136+
----------
137+
user : :class:`ansys.hps.client.auth.User`
138+
User object. The default is ``None``.
139+
as_objects : bool, optional
140+
The default is ``True``.
139141
"""
140142
return create_user(self.keycloak_admin_client, user, as_objects=as_objects)
141143

142144
def update_user(self, user: User, as_objects=True) -> User:
143145
"""Modify an existing user.
144146
145-
Args:
146-
user (:class:`ansys.hps.client.auth.User`): A User object. Defaults to None.
147-
as_objects (bool, optional): Defaults to True.
147+
Parameters
148+
----------
149+
user : :class:`ansys.hps.client.auth.User`
150+
User object. The default is ``None``.
151+
as_objects : bool, optional
152+
The default is ``True``.
148153
"""
149154
return update_user(self.keycloak_admin_client, user, as_objects=as_objects)
150155

151156
def delete_user(self, user: User) -> None:
152157
"""Delete an existing user.
153158
154-
Args:
155-
user (:class:`ansys.hps.client.auth.User`): A User object. Defaults to None.
159+
Parameters
160+
----------
161+
user : :class:`ansys.hps.client.auth.User`
162+
User object. The default is ``None``.
156163
"""
157164
return self.keycloak_admin_client.delete_user(user.id)
158165

0 commit comments

Comments
 (0)