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

sort sorts input parameter values by string of value instead of by value #408

Open
2 tasks done
ansAFinney opened this issue May 28, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@ansAFinney
Copy link

ansAFinney commented May 28, 2024

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

during SAF development I encountered a problem with sorting in which jobs sorted by a float input parameter end up being sorted by the text value of the input parameter and not the actual float value

📝 Steps to reproduce

simply run the following script:

from pathlib import Path
from ansys.hps.client import Client, ProjectApi, JmsApi
from ansys.hps.client.jms import (  # pyright: ignore[reportMissingTypeStubs]
         File,
        FloatParameterDefinition,
        JmsApi,
        Job,
        JobDefinition,
        ParameterMapping,
        Project,
        ProjectApi,
        TaskDefinition,
    )
from ansys.hps.client.jms.resource.parameter_definition import ParameterDefinition  # type: ignore

cl = Client(url="https://localhost:8443/hps", username="repadmin", password="repadmin")

jms_api = JmsApi(cl)
project_name = "TEST"
project_specification = Project(name=project_name, priority=1, active=True)
project = jms_api.create_project(project_specification)
id_string = str(project.id)  # type: ignore
project_api = ProjectApi(cl, id_string)

file = File(name="input_file", evaluation_path="input.txt", type="text/plain", src=(Path(__file__).parent / "input.txt").as_posix())
file = project_api.create_files([file])[0]
parameter = FloatParameterDefinition(name="x")
parameter = project_api.create_parameter_definitions([parameter])[0]
parameter_mapping = ParameterMapping(key_string="x", tokenizer="=", parameter_definition_id=parameter.id, file_id=file.id)
parameter_mapping = project_api.create_parameter_mappings([parameter_mapping])[0]
task_def = TaskDefinition(name="TEST", input_file_ids=[file.id], execution_level=0)
taskdef = project_api.create_task_definitions([task_def])[0]
job_def = JobDefinition(name="JobDef", task_definition_ids=[taskdef.id], parameter_definition_ids=[parameter.id], parameter_mapping_ids=[parameter_mapping.id])
job_def = project_api.create_job_definitions([job_def])[0]
jobs = [Job(name=f"Job.{index}", values={"x" : index * 2.0}, eval_status="pending", job_definition_id=job_def.id) for index in range (0, 20)]
project_api.create_jobs(jobs=jobs)

jobs = project_api.get_jobs(sort=["values.x"])

for job in jobs:
    print(f"result={job.values.get('x')}")

I see

result=0.0
result=10.0
result=12.0
result=14.0
result=16.0
result=18.0
result=2.0
result=20.0
result=22.0
result=24.0
result=26.0
result=28.0
result=30.0
result=32.0
result=34.0
result=36.0
result=38.0
result=4.0
result=6.0
result=8.0

input.txt is an empty file that is in the same directory as the script

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

I am not using any products for this case.

HPS is running docker compose in WSL with the client running on Windows

image

🐍 Which Python version are you using?

3.10

📦 Installed packages

annotated-types==0.6.0
ansys-hps-client==0.8.0
backoff==2.2.1
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.6
# Editable install with no version control (mapdl-tyre-performance==0.1.0)
-e c:\ansysdev\mapdl_tyre_performance
marshmallow==3.21.1
marshmallow-oneofschema==3.1.1
packaging==24.0
pydantic==2.6.4
pydantic_core==2.16.3
PyJWT==2.8.0
requests==2.31.0
typing_extensions==4.10.0
urllib3==1.26.18
@ansAFinney ansAFinney added the bug Something isn't working label May 28, 2024
@FedericoNegri
Copy link
Contributor

@ansAFinney thanks for reporting. I could reproduce it, also in the web ui. It's a server bug, will update this issue once it gets resolved. (it also explains #407)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants