Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
FedericoNegri opened this issue Feb 22, 2024 · 0 comments
Open

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

FedericoNegri opened this issue Feb 22, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@FedericoNegri
Copy link
Contributor

Example script

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"))
@FedericoNegri FedericoNegri added the documentation Improvements or additions to documentation label Feb 22, 2024
@FedericoNegri FedericoNegri changed the title Add example to the use guide: how to list a job's files Add example to the user guide: how to list a job's files Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant