ansys / ansys/pyhps

Add example to the user guide: how to list a job's files

Open
#343 1 comment 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
5
Forks
1
Avg merge
1d 21h
Merged PRs (30d)
9

Description

Example script

```python
import humanize
from tabulate import tabulate

from ansys.hps.client import Client, ProjectApi

project_id = "02vna3Aap8ZEkykK0j52Uj"
job_id = "02vna3DVqDW2CgQrRe3X34"
cl = Client(
url="https://localhost:8443/hps",
username="repuser",
password="repuser",
verify=False
)

project_api = ProjectApi(cl, project_id)

job = project_api.get_jobs(id=[job_id], fields=["id", "file_ids"])[0]
query_params = {"id": job.file_ids, "hash.ne": "null"}
files = project_api.get_files(**query_params)

table_data = [['Name', 'Path', 'Size', 'Last Modified']]
table_data.extend(
[[
f.name,
f.evaluation_path,
humanize.naturalsize(f.size),
humanize.naturaltime(f.modification_time)
] for f in files]
)
print(tabulate(table_data, headers="firstrow"))
```

Contributor guide

Open the contributing guide

Research direction

Locate the user guide entry point and add the supplied Python example for listing a job's files. Check that the example is formatted as a readable guide section and that it clearly demonstrates retrieving the job's file IDs, querying files, and printing their names, paths, sizes, and modification times.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.