Skip to content
Merged
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
8 changes: 0 additions & 8 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ jobs:
run: |
python -m pip install --upgrade pip setuptools tox tox-gh-actions

- name: Check out rep-deployments
uses: actions/checkout@v3
with:
repository: ansys-internal/rep-deployments
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
submodules: true
path: rep-deployments

- uses: dawidd6/action-download-artifact@v2
with:
workflow: main.yaml
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ For building documentation, you can manually run:

.. code:: bash

python prepare_documentation.py
python archive_examples.py
python -m sphinx -b html doc/source build/sphinx/html

The recommended way of checking documentation integrity is using:
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/auth/api/auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AuthApi:
>>> from ansys.hps.client import Client
>>> from ansys.hps.client.auth import AuthApi, User
>>> cl = Client(
... rep_url="https://127.0.0.1:8443/rep/", username="repadmin", password="repadmin"
... url="https://127.0.0.1:8443/rep/", username="repadmin", password="repadmin"
... )
>>> auth_api = AuthApi(cl)
>>> users = auth_api.get_users(firstName="john", exact=False)
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(
rep_url = kwargs.get("rep_url", None)
if rep_url is not None:
url = rep_url
msg = "The 'rep_url'` input argument is deprecated, use 'url' instead."
msg = "The 'rep_url' input argument is deprecated, use 'url' instead."
warnings.warn(msg, DeprecationWarning)
log.warning(msg)

Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
>>> from ansys.hps.client import HPSError
>>> from ansys.hps.client.jms import Client
>>> try:
>>> client = Client(rep_url="https://127.0.0.1:8443/rep/",
>>> client = Client(url="https://127.0.0.1:8443/rep/",
username="repadmin",
password="wrong_psw")
>>> except HPSError as e:
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/jms/api/jms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JmsApi(object):
>>> from ansys.hps.client import Client
>>> from ansys.hps.client.jms import JmsApi, Project
>>> cl = Client(
... rep_url="https://127.0.0.1:8443/rep", username="repadmin", password="repadmin"
... url="https://127.0.0.1:8443/rep", username="repadmin", password="repadmin"
... )
>>> jms_api = JmsApi(cl)
>>> project = jms_api.create_project(Project(name="Example Project"))
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/jms/api/project_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ProjectApi:
>>> from ansys.hps.client import Client
>>> from ansys.hps.client.jms import JmsApi, Project, ProjectApi
>>> cl = Client(
... rep_url="https://127.0.0.1:8443/rep", username="repadmin", password="repadmin"
... url="https://127.0.0.1:8443/rep", username="repadmin", password="repadmin"
... )
>>> project = Project(name="Example Project")
>>> print(project)
Expand Down
11 changes: 11 additions & 0 deletions ansys/hps/client/jms/resource/task_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ class HpcResources(Object):
Parameters
----------
num_cores_per_node : int, optional
Number of cores per node.
num_gpus_per_node : int, optional
Number of GPUs per node.
exclusive : bool, optional
When set, a job can't share resources with other running jobs.
queue : str, optional
Name of job scheduler queue.

"""

Expand Down Expand Up @@ -46,12 +50,19 @@ class ResourceRequirements(Object):
Parameters
----------
platform : str, optional
Basic platform information: 'windows' or 'linux'.
memory : int, optional
Amount of RAM in bytes.
num_cores : float, optional
Number of cores.
disk_space : int, optional
Amount of disk space in bytes.
distributed : bool, optional
Enable distributed parallel processing.
custom : dict[str, int | float | str | bool], optional
Custom resource requirements.
hpc_resources : HpcResources, optional
HPC requirements

"""

Expand Down
43 changes: 32 additions & 11 deletions ansys/hps/client/jms/schema/task_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,44 @@ class HpcResourcesSchema(BaseSchema):
class Meta:
pass

num_cores_per_node = fields.Int(allow_none=True)
num_gpus_per_node = fields.Int(allow_none=True)
exclusive = fields.Bool(allow_none=True)
queue = fields.Str(allow_none=True)
num_cores_per_node = fields.Int(
allow_none=True, metadata={"description": "Number of cores per node."}
)
num_gpus_per_node = fields.Int(
allow_none=True, metadata={"description": "Number of GPUs per node."}
)
exclusive = fields.Bool(
allow_none=True,
metadata={"description": "When set, a job can't share resources with other running jobs."},
)
queue = fields.Str(allow_none=True, metadata={"description": "Name of job scheduler queue."})


class ResourceRequirementsSchema(BaseSchema):
class Meta(BaseSchema.Meta):
pass

platform = fields.String(allow_none=True)
memory = fields.Int(allow_none=True)
num_cores = fields.Float(allow_none=True)
disk_space = fields.Int(allow_none=True)
distributed = fields.Bool(allow_none=True)
custom = fields.Dict(allow_none=True, keys=fields.Str(), values=RestrictedValue())
hpc_resources = fields.Nested(HpcResourcesSchema, allow_none=True)
platform = fields.String(
allow_none=True,
metadata={"description": "Basic platform information: 'windows' or 'linux'."},
)
memory = fields.Int(allow_none=True, metadata={"description": "Amount of RAM in bytes."})
num_cores = fields.Float(allow_none=True, metadata={"description": "Number of cores."})
disk_space = fields.Int(
allow_none=True, metadata={"description": "Amount of disk space in bytes."}
)
distributed = fields.Bool(
allow_none=True, metadata={"description": "Enable distributed parallel processing."}
)
custom = fields.Dict(
allow_none=True,
keys=fields.Str(),
values=RestrictedValue(),
metadata={"description": "Custom resource requirements."},
)
hpc_resources = fields.Nested(
HpcResourcesSchema, allow_none=True, metadata={"description": "HPC requirements"}
)


class SuccessCriteriaSchema(BaseSchema):
Expand Down
2 changes: 1 addition & 1 deletion ansys/hps/client/rms/api/rms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_evaluator_configuration(
>>> from ansys.hps.client import Client
>>> from ansys.hps.client.jms import RmsApi, EvaluatorConfigurationUpdate
>>> cl = Client(
... rep_url="https://localhost:8443/rep", username="repuser", password="repuser"
... url="https://localhost:8443/rep", username="repuser", password="repuser"
... )
>>> rms_api = RmsApi(cl)
>>> query_params = {
Expand Down
10 changes: 7 additions & 3 deletions ansys/hps/client/rms/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: rms_openapi.json
# timestamp: 2023-12-22T09:38:15+00:00
# timestamp: 2024-01-15T16:13:17+00:00

from __future__ import annotations

Expand Down Expand Up @@ -206,8 +206,12 @@ class Node(BaseModel):

class NodeGroup(BaseModel):
node_names: List[str] = Field(..., title='Node Names')
total_memory_mb: Optional[int] = Field(..., description='Total memory', title='Total Memory Mb')
total_cores: Optional[int] = Field(..., description='Number of cores', title='Total Cores')
memory_per_node_mb: Optional[int] = Field(
..., description='Total Memory per node', title='Memory Per Node Mb'
)
cores_per_node: Optional[int] = Field(
..., description='Total cores per node', title='Cores Per Node'
)


class PlatformEnum(Enum):
Expand Down
79 changes: 79 additions & 0 deletions archive_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# ----------------------------------------------------------
# Copyright (C) 2019 by
# ANSYS Switzerland GmbH
# www.ansys.com
#
# Author(s): F.Negri
# ----------------------------------------------------------

import os
from zipfile import ZipFile


def archive_examples():
"""Create a zip archive for each listed example included in the examples folder."""

examples = {
"mapdl_motorbike_frame": [
"project_setup.py",
"project_query.py",
"exec_mapdl.py",
"motorbike_frame_results.txt",
"motorbike_frame.mac",
],
"mapdl_tyre_performance": [
"project_setup.py",
"tire_performance_simulation.mac",
"2d_tire_geometry.iges",
],
"mapdl_linked_analyses": [
"project_setup.py",
"prestress.dat",
"modal.dat",
"harmonic.dat",
],
"lsdyna_cylinder_plate": [
"lsdyna_job.py",
"cylinder_plate.k",
"postprocess.cfile",
],
"python_two_bar_truss_problem": [
"project_setup.py",
"exec_python.py",
"evaluate.py",
"input_parameters.json",
],
"fluent_2d_heat_exchanger": [
"project_setup.py",
"heat_exchanger.jou",
"heat_exchanger.cas.h5",
],
"fluent_nozzle": [
"project_setup.py",
"exec_fluent.py",
"solve.jou",
"nozzle.cas",
],
"cfx_static_mixer": [
"project_setup.py",
"exec_cfx.py",
"runInput.ccl",
"StaticMixer_001.cfx",
"StaticMixer_001.def",
],
}

os.makedirs("build", exist_ok=True)
for name, files in examples.items():
with ZipFile(os.path.join("build", f"{name}.zip"), "w") as zip_archive:
for file in files:
zip_archive.write(os.path.join("examples", name, file), file)

with ZipFile(os.path.join("build", f"pyhps_examples.zip"), "w") as zip_archive:
for name, files in examples.items():
for file in files:
zip_archive.write(os.path.join("examples", name, file), os.path.join(name, file))


if __name__ == "__main__":
archive_examples()
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _do_documentation(context):
target_directory = os.path.join(os.path.dirname(__file__), "build", "sphinx", "html")
doc_reqs = os.path.join(os.path.dirname(__file__), "requirements", "requirements_doc.txt")
subprocess.run(f"{context.python_binary} -m pip install -r {doc_reqs}", shell=True, check=True)
subprocess.run(f"{context.python_binary} prepare_documentation.py", shell=True, check=True)
subprocess.run(f"{context.python_binary} archive_examples.py", shell=True, check=True)
subprocess.run(
f"{context.python_binary} -m sphinx -b html {docs_directory} {target_directory}",
shell=True,
Expand Down
5 changes: 3 additions & 2 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ As long as PyHPS is a private PyAnsys package not published to PyPI yet, you can

.. code::

python -m pip install git+https://github.com/pyansys/pyhps
python -m pip install git+https://github.com/ansys-internal/pyhps

The following dependencies are automatically installed through ``pip`` (if not already available):

- cachetools_
- requests_
- marshmallow_
- marshmallow_oneofschema_
- python-keycloak_
- pydantic_

.. _requests: https://pypi.org/project/requests/
.. _marshmallow: https://pypi.org/project/marshmallow/
.. _marshmallow_oneofschema: https://pypi.org/project/marshmallow-oneofschema/
.. _cachetools: https://pypi.org/project/cachetools/
.. _python-keycloak: https://pypi.org/project/python-keycloak/
.. _pydantic: https://pypi.org/project/pydantic/
18 changes: 9 additions & 9 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
Quickstart
==========

This guide will walk you through the basics of interacting with a REP server. More elaborated examples are available in the :ref:`Examples <examples>` chapter,
This guide will walk you through the basics of interacting with Ansys HPC Platform Services. More elaborated examples are available in the :ref:`Examples <examples>` chapter,
while detailed documentation can be found in the :ref:`Code Documentation <api_reference>`.

To reproduce the code samples provided below, you will need:

- A running REP server, go to the `REP repository <https://github.com/ansys/rep>`_ for instructions.
- A running HPS installation, go to the `REP repository <https://github.com/ansys/rep>`_ for instructions.
- A Python shell with ``ansys-pyhps`` installed. If you haven't installed it yet, please refer to the :ref:`Installation <installation>` guide.


Connect to a REP Server
--------------------------
Connect to HPC Platform Services
--------------------------------

Let's start by connecting to a REP server running on the localhost with default username and password.
Let's start by connecting to an HPS deployment running on the localhost with default username and password.

.. code-block:: python

from ansys.hps.client import Client
from ansys.hps.client.jms import JmsApi, ProjectApi

client = Client(rep_url="https://localhost:8443/rep", username="repuser", password="repuser")
client = Client(url="https://localhost:8443/rep", username="repuser", password="repuser")

# check which JMS version the server is running
jms_api = JmsApi(client)
print(jms_api.get_api_info()['build']['external_version'])
print(jms_api.get_api_info()['build']['version'])

# get all projects
projects = jms_api.get_projects()
Expand Down Expand Up @@ -286,7 +286,7 @@ Admin users with the Keycloak "manage-users" role can create new users as well a
from ansys.hps.client import Client
from ansys.hps.client.auth import AuthApi, User

client = Client(rep_url="https://localhost:8443/rep/", username="repadmin", password="repadmin")
client = Client(url="https://localhost:8443/rep/", username="repadmin", password="repadmin")
auth_api = AuthApi(client)

# modify the default password of the repadmin user
Expand Down Expand Up @@ -321,7 +321,7 @@ For example, instantiating a client with invalid credentials will return a 401 C
from ansys.hps.client import Client, HPSError

try:
client = Client(rep_url="https://localhost:8443/rep/", username="repuser", password="wrong_psw")
client = Client(url="https://localhost:8443/rep/", username="repuser", password="wrong_psw")
except HPSError as e:
print(e)

Expand Down
2 changes: 1 addition & 1 deletion examples/cfx_static_mixer/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def create_project(client, name, num_jobs=20, version=__ansys_apps_version__):

try:
log.info("Connect to HPC Platform Services")
client = Client(rep_url=args.url, username=args.username, password=args.password)
client = Client(url=args.url, username=args.username, password=args.password)
log.info(f"HPS URL: {client.rep_url}")
proj = create_project(
client=client, name=args.name, num_jobs=args.num_jobs, version=args.ansys_version
Expand Down
2 changes: 1 addition & 1 deletion examples/fluent_2d_heat_exchanger/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def create_project(
logging.basicConfig(format="[%(asctime)s | %(levelname)s] %(message)s", level=logging.DEBUG)

log.debug("=== HPS connection")
client = Client(rep_url=args.url, username=args.username, password=args.password)
client = Client(url=args.url, username=args.username, password=args.password)

try:
log.info(f"HPS URL: {client.rep_url}")
Expand Down
2 changes: 1 addition & 1 deletion examples/fluent_nozzle/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def create_project(client, name, num_jobs=20, version=__ansys_apps_version__):

try:
log.info("Connect to HPC Platform Services")
client = Client(rep_url=args.url, username=args.username, password=args.password)
client = Client(url=args.url, username=args.username, password=args.password)
log.info(f"HPS URL: {client.rep_url}")
proj = create_project(
client=client, name=args.name, num_jobs=args.num_jobs, version=args.ansys_version
Expand Down
2 changes: 1 addition & 1 deletion examples/mapdl_linked_analyses/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def create_project(
logging.basicConfig(format="[%(asctime)s | %(levelname)s] %(message)s", level=logging.INFO)

log.debug("=== HPS connection")
client = Client(rep_url=args.url, username=args.username, password=args.password)
client = Client(url=args.url, username=args.username, password=args.password)

try:
create_project(
Expand Down
Loading