Skip to content

Commit

Permalink
fix payload for surface_pp_input
Browse files Browse the repository at this point in the history
  • Loading branch information
yias committed Sep 23, 2024
1 parent 43cfc3d commit 5f4d6cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/ansys/simai/core/data/model_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,13 @@ def _to_payload(self):
if self.global_coefficients is not None:
gcs = [asdict(gc) for gc in self.global_coefficients]

surface_pp_input_fld = self.pp_input.surface or []
surface_pp_input_fld = []
if self.pp_input.surface is not None:
surface_pp_input_fld = [
fd
for fd in sample_metadata.get("surface").get("fields")
if fd.get("name") in self.pp_input.surface
]

flds = {
"surface": surface_fld,
Expand Down
7 changes: 5 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def test_post_process_input(simai_client):
model_conf_dict["fields"]["surface_pp_input"] = [
{
"keys": None,
"name": pp_input.surface,
"name": "TurbulentViscosity",
"unit": None,
"format": "value",
"location": "cell",
Expand All @@ -575,7 +575,10 @@ def test_post_process_input(simai_client):
build_model: Model = simai_client.models.build(config_with_pp_input)

assert config_with_pp_input.pp_input.surface == pp_input.surface
assert config_with_pp_input._to_payload()["fields"]["surface_pp_input"] == pp_input.surface
assert (
config_with_pp_input._to_payload()["fields"]["surface_pp_input"]
== model_conf_dict["fields"]["surface_pp_input"]
)
assert build_model.configuration.pp_input.surface == pp_input.surface
assert (
build_model.fields["configuration"]["fields"]["surface_pp_input"]
Expand Down

0 comments on commit 5f4d6cd

Please sign in to comment.