From 64e9adfd74e0784fee2a01d6af5a839c903503be Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Tue, 22 Apr 2025 14:33:55 -0400 Subject: [PATCH 1/8] Add app versions list --- src/ansys/hps/client/jms/resource/task_definition.py | 9 +++++++-- src/ansys/hps/client/jms/schema/task_definition.py | 7 ++++++- tests/jms/test_task_definition_templates.py | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ansys/hps/client/jms/resource/task_definition.py b/src/ansys/hps/client/jms/resource/task_definition.py index 2080f16e3..64096fc83 100644 --- a/src/ansys/hps/client/jms/resource/task_definition.py +++ b/src/ansys/hps/client/jms/resource/task_definition.py @@ -160,7 +160,9 @@ class Software(Object): name : str Name of the app. version : str, optional - Version of the app. + Default version of the app. + versions : list, optional + Other versions of the app. """ @@ -168,9 +170,12 @@ class Meta: schema = SoftwareSchema rest_name = "None" - def __init__(self, name: str = missing, version: str = missing, **kwargs): + def __init__( + self, name: str = missing, version: str = missing, versions: list = missing, **kwargs + ): self.name = name self.version = version + self.versions = versions self.obj_type = self.__class__.__name__ diff --git a/src/ansys/hps/client/jms/schema/task_definition.py b/src/ansys/hps/client/jms/schema/task_definition.py index 7a66d6205..b7702162f 100644 --- a/src/ansys/hps/client/jms/schema/task_definition.py +++ b/src/ansys/hps/client/jms/schema/task_definition.py @@ -33,7 +33,12 @@ class Meta(BaseSchema.Meta): pass name = fields.String(metadata={"description": "Name of the app."}) - version = fields.String(allow_none=True, metadata={"description": "Version of the app."}) + version = fields.String( + allow_none=True, metadata={"description": "Default version of the app."} + ) + versions = fields.List( + fields.String(), allow_none=True, metadata={"description": "Other versions of the app."} + ) class HpcResourcesSchema(BaseSchema): diff --git a/tests/jms/test_task_definition_templates.py b/tests/jms/test_task_definition_templates.py index 568945e2b..8b38716ac 100644 --- a/tests/jms/test_task_definition_templates.py +++ b/tests/jms/test_task_definition_templates.py @@ -113,11 +113,13 @@ def test_template_deserialization(): assert not template.resource_requirements.hpc_resources.custom_orchestration_options["bval"] json_data["software_requirements"][0]["version"] = "2022 R2" + json_data["software_requirements"][0]["versions"] = ["2023 R2", "2024 R2"] json_data["execution_command"] = "my command line" json_data["execution_context"] = {"my_new_field": {"default": "value", "type": "string"}} template = TaskDefinitionTemplateSchema().load(json_data) assert template.software_requirements[0].version == "2022 R2" + assert template.software_requirements[0].versions == ["2023 R2", "2024 R2"] assert template.execution_command == "my command line" assert template.execution_context["my_new_field"].default == "value" @@ -164,6 +166,7 @@ def test_template_integration(client): # Modify template template.software_requirements[0].version = "2.0.1" + template.software_requirements[0].versions = ["2025 R1", "2025 R2"] template.resource_requirements = TemplateResourceRequirements( hpc_resources=HpcResources(num_gpus_per_node=2) ) @@ -171,6 +174,7 @@ def test_template_integration(client): assert len(templates) == 1 template = templates[0] assert template.software_requirements[0].version == "2.0.1" + assert template.software_requirements[0].versions == ["2025 R1", "2025 R2"] assert template.name == template_name assert template.resource_requirements.hpc_resources.num_gpus_per_node == 2 From 6ab314be270c19eca6fd77b07e94eefc8834d299 Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Thu, 24 Apr 2025 09:25:42 -0400 Subject: [PATCH 2/8] Split out AvailableSoftwareSchema for only template usage --- generate_resources.py | 8 ++++ .../client/jms/resource/task_definition.py | 9 +---- .../jms/resource/task_definition_template.py | 38 +++++++++++++++++-- .../hps/client/jms/schema/task_definition.py | 7 +--- .../jms/schema/task_definition_template.py | 17 ++++++++- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/generate_resources.py b/generate_resources.py index da8eb167d..420982858 100644 --- a/generate_resources.py +++ b/generate_resources.py @@ -197,6 +197,14 @@ "class": "JobSelection", "resource_filename": "selection", }, + { + "schema": "AvailableSoftwareSchema", + "schema_filename": "task_definition_template", + "rest_name": None, + "additional_fields": [], + "class": "AvailableSoftware", + "resource_filename": "task_definition_template", + }, { "schema": "TemplatePropertySchema", "schema_filename": "task_definition_template", diff --git a/src/ansys/hps/client/jms/resource/task_definition.py b/src/ansys/hps/client/jms/resource/task_definition.py index 64096fc83..2080f16e3 100644 --- a/src/ansys/hps/client/jms/resource/task_definition.py +++ b/src/ansys/hps/client/jms/resource/task_definition.py @@ -160,9 +160,7 @@ class Software(Object): name : str Name of the app. version : str, optional - Default version of the app. - versions : list, optional - Other versions of the app. + Version of the app. """ @@ -170,12 +168,9 @@ class Meta: schema = SoftwareSchema rest_name = "None" - def __init__( - self, name: str = missing, version: str = missing, versions: list = missing, **kwargs - ): + def __init__(self, name: str = missing, version: str = missing, **kwargs): self.name = name self.version = version - self.versions = versions self.obj_type = self.__class__.__name__ diff --git a/src/ansys/hps/client/jms/resource/task_definition_template.py b/src/ansys/hps/client/jms/resource/task_definition_template.py index a5e85544f..7f2621a3c 100644 --- a/src/ansys/hps/client/jms/resource/task_definition_template.py +++ b/src/ansys/hps/client/jms/resource/task_definition_template.py @@ -33,13 +33,45 @@ from ansys.hps.client.common import Object from ..schema.task_definition_template import ( + AvailableSoftwareSchema, TaskDefinitionTemplateSchema, TemplateInputFileSchema, TemplateOutputFileSchema, TemplatePropertySchema, TemplateResourceRequirementsSchema, ) -from .task_definition import HpcResources, Software, WorkerContext +from .task_definition import HpcResources, WorkerContext + + +class AvailableSoftware(Object): + """Provides the available software resource. + + Parameters + ---------- + name : str + Name of the app. + version : str, optional + Default version of the app. + versions : list, optional + Other versions of the app. + + """ + + class Meta: + schema = AvailableSoftwareSchema + rest_name = "None" + + def __init__( + self, name: str = missing, version: str = missing, versions: list = missing, **kwargs + ): + self.name = name + self.version = version + self.versions = versions + + self.obj_type = self.__class__.__name__ + + +AvailableSoftwareSchema.Meta.object_class = AvailableSoftware class TemplateProperty(Object): @@ -242,7 +274,7 @@ class TaskDefinitionTemplate(Object): Version of the template. description : str, optional Description of the template. - software_requirements : list[Software], optional + software_requirements : list[AvailableSoftware], optional List of required software. resource_requirements : TemplateResourceRequirements, optional Hardware requirements such as the number of cores, memory, and disk space. @@ -279,7 +311,7 @@ def __init__( name: str = missing, version: str = missing, description: str = missing, - software_requirements: list[Software] = missing, + software_requirements: list[AvailableSoftware] = missing, resource_requirements: TemplateResourceRequirements = missing, worker_context: WorkerContext = missing, execution_context: dict[str, TemplateProperty] = missing, diff --git a/src/ansys/hps/client/jms/schema/task_definition.py b/src/ansys/hps/client/jms/schema/task_definition.py index b7702162f..7a66d6205 100644 --- a/src/ansys/hps/client/jms/schema/task_definition.py +++ b/src/ansys/hps/client/jms/schema/task_definition.py @@ -33,12 +33,7 @@ class Meta(BaseSchema.Meta): pass name = fields.String(metadata={"description": "Name of the app."}) - version = fields.String( - allow_none=True, metadata={"description": "Default version of the app."} - ) - versions = fields.List( - fields.String(), allow_none=True, metadata={"description": "Other versions of the app."} - ) + version = fields.String(allow_none=True, metadata={"description": "Version of the app."}) class HpcResourcesSchema(BaseSchema): diff --git a/src/ansys/hps/client/jms/schema/task_definition_template.py b/src/ansys/hps/client/jms/schema/task_definition_template.py index baf49436a..e28b86eff 100644 --- a/src/ansys/hps/client/jms/schema/task_definition_template.py +++ b/src/ansys/hps/client/jms/schema/task_definition_template.py @@ -25,7 +25,20 @@ from ansys.hps.client.common import BaseSchema, ObjectSchema -from .task_definition import HpcResourcesSchema, SoftwareSchema, WorkerContextSchema +from .task_definition import HpcResourcesSchema, WorkerContextSchema + + +class AvailableSoftwareSchema(BaseSchema): + class Meta(BaseSchema.Meta): + pass + + name = fields.String(metadata={"description": "Name of the app."}) + version = fields.String( + allow_none=True, metadata={"description": "Default version of the app."} + ) + versions = fields.List( + fields.String(), allow_none=True, metadata={"description": "Other versions of the app."} + ) class TemplatePropertySchema(BaseSchema): @@ -126,7 +139,7 @@ class Meta(ObjectSchema.Meta): ) software_requirements = fields.Nested( - SoftwareSchema, + AvailableSoftwareSchema, many=True, allow_none=True, metadata={"description": "List of required software."}, From 8d7f183b88834833ffc69e03a8666495691b3999 Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Mon, 28 Apr 2025 09:57:56 -0400 Subject: [PATCH 3/8] software version property was remove in lieu of versions prop --- tests/jms/test_task_definition_templates.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/jms/test_task_definition_templates.py b/tests/jms/test_task_definition_templates.py index 8b38716ac..f4eb7e129 100644 --- a/tests/jms/test_task_definition_templates.py +++ b/tests/jms/test_task_definition_templates.py @@ -112,13 +112,11 @@ def test_template_deserialization(): ) assert not template.resource_requirements.hpc_resources.custom_orchestration_options["bval"] - json_data["software_requirements"][0]["version"] = "2022 R2" json_data["software_requirements"][0]["versions"] = ["2023 R2", "2024 R2"] json_data["execution_command"] = "my command line" json_data["execution_context"] = {"my_new_field": {"default": "value", "type": "string"}} template = TaskDefinitionTemplateSchema().load(json_data) - assert template.software_requirements[0].version == "2022 R2" assert template.software_requirements[0].versions == ["2023 R2", "2024 R2"] assert template.execution_command == "my command line" assert template.execution_context["my_new_field"].default == "value" @@ -165,7 +163,6 @@ def test_template_integration(client): assert template.name == template_name # Modify template - template.software_requirements[0].version = "2.0.1" template.software_requirements[0].versions = ["2025 R1", "2025 R2"] template.resource_requirements = TemplateResourceRequirements( hpc_resources=HpcResources(num_gpus_per_node=2) @@ -173,7 +170,6 @@ def test_template_integration(client): templates = jms_api.update_task_definition_templates([template]) assert len(templates) == 1 template = templates[0] - assert template.software_requirements[0].version == "2.0.1" assert template.software_requirements[0].versions == ["2025 R1", "2025 R2"] assert template.name == template_name assert template.resource_requirements.hpc_resources.num_gpus_per_node == 2 @@ -195,8 +191,8 @@ def test_template_integration(client): assert original_template.version == new_template.version assert original_template.version == new_template.version assert ( - original_template.software_requirements[0].version - == original_template.software_requirements[0].version + original_template.software_requirements[0].versions + == original_template.software_requirements[0].versions ) jms_api.delete_task_definition_templates([new_template]) From e897b9fd01731735b722c89871413a88ff42a73e Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Tue, 29 Apr 2025 13:15:50 -0400 Subject: [PATCH 4/8] removed version from tests and forgot the schema --- src/ansys/hps/client/jms/schema/task_definition_template.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ansys/hps/client/jms/schema/task_definition_template.py b/src/ansys/hps/client/jms/schema/task_definition_template.py index e28b86eff..53fb417c5 100644 --- a/src/ansys/hps/client/jms/schema/task_definition_template.py +++ b/src/ansys/hps/client/jms/schema/task_definition_template.py @@ -33,9 +33,6 @@ class Meta(BaseSchema.Meta): pass name = fields.String(metadata={"description": "Name of the app."}) - version = fields.String( - allow_none=True, metadata={"description": "Default version of the app."} - ) versions = fields.List( fields.String(), allow_none=True, metadata={"description": "Other versions of the app."} ) From 4d1e77e690ccf6168f328a47bb95a18518bb1755 Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Thu, 1 May 2025 13:37:19 -0400 Subject: [PATCH 5/8] fix test --- tests/jms/test_task_definition_templates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/jms/test_task_definition_templates.py b/tests/jms/test_task_definition_templates.py index f4eb7e129..51c2a1918 100644 --- a/tests/jms/test_task_definition_templates.py +++ b/tests/jms/test_task_definition_templates.py @@ -52,7 +52,7 @@ def test_template_deserialization(): "software_requirements": [ { "name": "Ansys Mechanical APDL", - "version": "21.1", + "versions": ["21.1"], } ], "input_files": [], @@ -142,7 +142,7 @@ def test_template_integration(client): if templates: assert "software_requirements" in templates[0].keys() assert "name" in templates[0]["software_requirements"][0].keys() - assert "version" in templates[0]["software_requirements"][0].keys() + assert "versions" in templates[0]["software_requirements"][0].keys() templates = jms_api.get_task_definition_templates(fields=["name"]) if templates: From 108e558895f7803011398361aa4e2178645402fe Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Thu, 1 May 2025 13:40:20 -0400 Subject: [PATCH 6/8] regen resource. version prop was removed --- .../hps/client/jms/resource/task_definition_template.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ansys/hps/client/jms/resource/task_definition_template.py b/src/ansys/hps/client/jms/resource/task_definition_template.py index 7f2621a3c..4114aceb6 100644 --- a/src/ansys/hps/client/jms/resource/task_definition_template.py +++ b/src/ansys/hps/client/jms/resource/task_definition_template.py @@ -50,8 +50,6 @@ class AvailableSoftware(Object): ---------- name : str Name of the app. - version : str, optional - Default version of the app. versions : list, optional Other versions of the app. @@ -61,11 +59,8 @@ class Meta: schema = AvailableSoftwareSchema rest_name = "None" - def __init__( - self, name: str = missing, version: str = missing, versions: list = missing, **kwargs - ): + def __init__(self, name: str = missing, versions: list = missing, **kwargs): self.name = name - self.version = version self.versions = versions self.obj_type = self.__class__.__name__ From f8109f67a0aada641d3920c40c51fe2deda08736 Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Thu, 1 May 2025 13:42:25 -0400 Subject: [PATCH 7/8] fix description --- src/ansys/hps/client/jms/schema/task_definition_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/hps/client/jms/schema/task_definition_template.py b/src/ansys/hps/client/jms/schema/task_definition_template.py index 53fb417c5..bfa0f06b7 100644 --- a/src/ansys/hps/client/jms/schema/task_definition_template.py +++ b/src/ansys/hps/client/jms/schema/task_definition_template.py @@ -34,7 +34,7 @@ class Meta(BaseSchema.Meta): name = fields.String(metadata={"description": "Name of the app."}) versions = fields.List( - fields.String(), allow_none=True, metadata={"description": "Other versions of the app."} + fields.String(), allow_none=True, metadata={"description": "Available versions of the app."} ) From e01d03e1e4de326dac4b1c348b45e056954fcb21 Mon Sep 17 00:00:00 2001 From: Dave Logie Date: Thu, 1 May 2025 13:47:41 -0400 Subject: [PATCH 8/8] rename AvailableSoftware to TemplateSoftware --- generate_resources.py | 4 ++-- .../jms/resource/task_definition_template.py | 16 ++++++++-------- .../jms/schema/task_definition_template.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/generate_resources.py b/generate_resources.py index 420982858..bf3179cce 100644 --- a/generate_resources.py +++ b/generate_resources.py @@ -198,11 +198,11 @@ "resource_filename": "selection", }, { - "schema": "AvailableSoftwareSchema", + "schema": "TemplateSoftwareSchema", "schema_filename": "task_definition_template", "rest_name": None, "additional_fields": [], - "class": "AvailableSoftware", + "class": "TemplateSoftware", "resource_filename": "task_definition_template", }, { diff --git a/src/ansys/hps/client/jms/resource/task_definition_template.py b/src/ansys/hps/client/jms/resource/task_definition_template.py index 4114aceb6..6b21854be 100644 --- a/src/ansys/hps/client/jms/resource/task_definition_template.py +++ b/src/ansys/hps/client/jms/resource/task_definition_template.py @@ -33,30 +33,30 @@ from ansys.hps.client.common import Object from ..schema.task_definition_template import ( - AvailableSoftwareSchema, TaskDefinitionTemplateSchema, TemplateInputFileSchema, TemplateOutputFileSchema, TemplatePropertySchema, TemplateResourceRequirementsSchema, + TemplateSoftwareSchema, ) from .task_definition import HpcResources, WorkerContext -class AvailableSoftware(Object): - """Provides the available software resource. +class TemplateSoftware(Object): + """Provides the template software resource. Parameters ---------- name : str Name of the app. versions : list, optional - Other versions of the app. + Versions of the app. """ class Meta: - schema = AvailableSoftwareSchema + schema = TemplateSoftwareSchema rest_name = "None" def __init__(self, name: str = missing, versions: list = missing, **kwargs): @@ -66,7 +66,7 @@ def __init__(self, name: str = missing, versions: list = missing, **kwargs): self.obj_type = self.__class__.__name__ -AvailableSoftwareSchema.Meta.object_class = AvailableSoftware +TemplateSoftwareSchema.Meta.object_class = TemplateSoftware class TemplateProperty(Object): @@ -269,7 +269,7 @@ class TaskDefinitionTemplate(Object): Version of the template. description : str, optional Description of the template. - software_requirements : list[AvailableSoftware], optional + software_requirements : list[TemplateSoftware], optional List of required software. resource_requirements : TemplateResourceRequirements, optional Hardware requirements such as the number of cores, memory, and disk space. @@ -306,7 +306,7 @@ def __init__( name: str = missing, version: str = missing, description: str = missing, - software_requirements: list[AvailableSoftware] = missing, + software_requirements: list[TemplateSoftware] = missing, resource_requirements: TemplateResourceRequirements = missing, worker_context: WorkerContext = missing, execution_context: dict[str, TemplateProperty] = missing, diff --git a/src/ansys/hps/client/jms/schema/task_definition_template.py b/src/ansys/hps/client/jms/schema/task_definition_template.py index bfa0f06b7..9eaa3cc9b 100644 --- a/src/ansys/hps/client/jms/schema/task_definition_template.py +++ b/src/ansys/hps/client/jms/schema/task_definition_template.py @@ -28,13 +28,13 @@ from .task_definition import HpcResourcesSchema, WorkerContextSchema -class AvailableSoftwareSchema(BaseSchema): +class TemplateSoftwareSchema(BaseSchema): class Meta(BaseSchema.Meta): pass name = fields.String(metadata={"description": "Name of the app."}) versions = fields.List( - fields.String(), allow_none=True, metadata={"description": "Available versions of the app."} + fields.String(), allow_none=True, metadata={"description": "Versions of the app."} ) @@ -136,7 +136,7 @@ class Meta(ObjectSchema.Meta): ) software_requirements = fields.Nested( - AvailableSoftwareSchema, + TemplateSoftwareSchema, many=True, allow_none=True, metadata={"description": "List of required software."},