Add example to the user guide: how to query cluster info
- Dominant language
- Python
- Stars
- 5
- Forks
- 1
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Example script
```python
import datetime
from ansys.hps.client import Client, RmsApi
import logging
logging.basicConfig(format="%(message)s", level=logging.INFO)
client = Client(url="...", username="...", password="...")
rms_api = RmsApi(client)
since_datetime = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=7)
query_params = {
"last_modified.gt": since_datetime,
"limit": 10,
"sort": "-last_modified",
}
print(80 * "=")
evaluators = rms_api.get_evaluators(**query_params)
print(f"Found {len(evaluators)} evaluators")
for evaluator in evaluators:
print(50 * "=")
print(f"Name: {evaluator.name}")
print(f"CRS id: {evaluator.compute_resource_set_id}")
print(f"Last modified: {evaluator.last_modified}")
config = rms_api.get_evaluator_configuration(evaluator.id)
print(f"Num cores: {config.resources.num_cores}")
print(f"List of available apps:")
for app in config.applications:
print(f" * {app.name} - {app.version}")
print(80 * "=")
# query compute resource sets
compute_resource_sets = rms_api.get_compute_resource_sets()
print(f"Found {len(compute_resource_sets)} compute resource sets")
for crs in compute_resource_sets:
print(60 * "=")
print(f"Name: {crs.name}")
print(f"Last modified: {crs.last_modified}")
print("\nList of available apps:")
for app in crs.available_applications:
print(f" * {app.name} - {app.version}")
cluster_info = rms_api.get_cluster_info(crs.id)
print("Queues info:")
for queue in cluster_info.queues:
print(f" * Queue name: {queue.name}")
print(" Nodes specs:")
for node_group in queue.node_groups:
print(
f" - {len(node_group.node_names)} nodes "
f"with {node_group.cores_per_node} core "
f"and {node_group.memory_per_node_mb/1024:.0f} GB of memory each"
)
print(80 * "=")
```
Contributor guide
Research direction
Locate the user guide section covering cluster or compute-resource queries, then review the supplied Python example and its use of RmsApi.get_cluster_info. Add the example in the appropriate guide location, ensuring it explains the displayed evaluator, application, queue, node, core, and memory information; done means the guide contains the example clearly and consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100