diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 5a76caec8..4aa5b69e5 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -78,7 +78,7 @@ jobs: - name: Test with tox run: tox -e ${{ matrix.cfg.toxenv }}-noeval-coverage env: - REP_TEST_URL: https://repkube.westeurope.cloudapp.azure.com/rep + REP_TEST_URL: https://repkube.westeurope.cloudapp.azure.com/dev/rep REP_TEST_USERNAME: repadmin REP_TEST_PASSWORD: repadmin @@ -106,7 +106,7 @@ jobs: - name: Test with tox run: tox -e py37-witheval env: - REP_TEST_URL: https://repkube.westeurope.cloudapp.azure.com/rep + REP_TEST_URL: https://repkube.westeurope.cloudapp.azure.com/dev/rep REP_TEST_USERNAME: repadmin REP_TEST_PASSWORD: repadmin diff --git a/ansys/rep/client/auth/resource/user.py b/ansys/rep/client/auth/resource/user.py index c11895bbf..ca92894d1 100644 --- a/ansys/rep/client/auth/resource/user.py +++ b/ansys/rep/client/auth/resource/user.py @@ -1,5 +1,4 @@ -# autogenerated code based on UserSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.user import UserSchema diff --git a/ansys/rep/client/jms/__init__.py b/ansys/rep/client/jms/__init__.py index 90dd09c40..ad0ed904b 100644 --- a/ansys/rep/client/jms/__init__.py +++ b/ansys/rep/client/jms/__init__.py @@ -30,4 +30,8 @@ Task, TaskDefinition, TaskDefinitionTemplate, + TemplateInputFile, + TemplateOutputFile, + TemplateProperty, + TemplateResourceRequirements, ) diff --git a/ansys/rep/client/jms/resource/__init__.py b/ansys/rep/client/jms/resource/__init__.py index 5b6f44714..51142427f 100644 --- a/ansys/rep/client/jms/resource/__init__.py +++ b/ansys/rep/client/jms/resource/__init__.py @@ -11,22 +11,15 @@ from .evaluator import Evaluator from .file import File from .fitness_definition import FitnessDefinition, FitnessTermDefinition -from .float_parameter_definition import FloatParameterDefinition -from .int_parameter_definition import IntParameterDefinition from .job import Job from .job_definition import JobDefinition from .license_context import LicenseContext -from .licensing import Licensing from .operation import Operation -from .parameter_definition import ParameterDefinition +from .parameter_definition import ParameterDefinition, FloatParameterDefinition, IntParameterDefinition, StringParameterDefinition from .parameter_mapping import ParameterMapping from .project import Project from .project_permission import ProjectPermission -from .resource_requirements import ResourceRequirements from .selection import JobSelection -from .software import Software -from .string_parameter_definition import StringParameterDefinition -from .success_criteria import SuccessCriteria from .task import Task -from .task_definition import TaskDefinition -from .task_definition_template import TaskDefinitionTemplate +from .task_definition import Licensing, SuccessCriteria, Software, ResourceRequirements, TaskDefinition +from .task_definition_template import TaskDefinitionTemplate, TemplateInputFile, TemplateOutputFile, TemplateResourceRequirements, TemplateProperty \ No newline at end of file diff --git a/ansys/rep/client/jms/resource/algorithm.py b/ansys/rep/client/jms/resource/algorithm.py index d9d631a32..512857bb2 100644 --- a/ansys/rep/client/jms/resource/algorithm.py +++ b/ansys/rep/client/jms/resource/algorithm.py @@ -1,5 +1,4 @@ -# autogenerated code based on AlgorithmSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.algorithm import AlgorithmSchema diff --git a/ansys/rep/client/jms/resource/bool_parameter_definition.py b/ansys/rep/client/jms/resource/bool_parameter_definition.py index 868e51349..5c93d2426 100644 --- a/ansys/rep/client/jms/resource/bool_parameter_definition.py +++ b/ansys/rep/client/jms/resource/bool_parameter_definition.py @@ -1,5 +1,4 @@ -# autogenerated code based on BoolParameterDefinitionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.jms.resource.parameter_definition import ParameterDefinition from ..schema.parameter_definition import BoolParameterDefinitionSchema diff --git a/ansys/rep/client/jms/resource/evaluator.py b/ansys/rep/client/jms/resource/evaluator.py index b1f3eb3df..9495fca96 100644 --- a/ansys/rep/client/jms/resource/evaluator.py +++ b/ansys/rep/client/jms/resource/evaluator.py @@ -1,5 +1,4 @@ -# autogenerated code based on EvaluatorSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.evaluator import EvaluatorSchema diff --git a/ansys/rep/client/jms/resource/float_parameter_definition.py b/ansys/rep/client/jms/resource/float_parameter_definition.py deleted file mode 100644 index 8c683ffbc..000000000 --- a/ansys/rep/client/jms/resource/float_parameter_definition.py +++ /dev/null @@ -1,61 +0,0 @@ -# autogenerated code based on FloatParameterDefinitionSchema - -from marshmallow.utils import missing -from ansys.rep.client.jms.resource.parameter_definition import ParameterDefinition -from ..schema.parameter_definition import FloatParameterDefinitionSchema - -class FloatParameterDefinition(ParameterDefinition): - """FloatParameterDefinition resource. - - Parameters - ---------- - id : str, optional - Unique ID to access the resource, generated internally by the server on creation. - name : str, optional - Name (ID) of the parameter. - quantity_name : str, optional - Name of the quantity the parameter represents, e.g. Length. - units : str, optional - Units for the parameter. - display_text : str, optional - Text to display as the parameter name. - mode : str - Indicates whether it's an input or output parameter. Filled server side. - type : str - default : float, optional - Default parameter value. - lower_limit : float, optional - Lower bound for the parameter value. - upper_limit : float, optional - Upper bound for the parameter value. - step : float, optional - If provided, allowable values are given by: AllowableValue = lower_limit + n * step, where n is an integer and AllowableValue <= upper_limit. - cyclic : bool, optional - Indicates if the parameter is cyclic. - value_list : list, optional - A list of allowed values, alternative to providing upper and lower limits. - - """ - - class Meta: - schema = FloatParameterDefinitionSchema - rest_name = "parameter_definitions" - - def __init__(self, **kwargs): - self.id = missing - self.name = missing - self.quantity_name = missing - self.units = missing - self.display_text = missing - self.mode = missing - self.type = missing - self.default = missing - self.lower_limit = missing - self.upper_limit = missing - self.step = missing - self.cyclic = missing - self.value_list = missing - - super().__init__(**kwargs) - -FloatParameterDefinitionSchema.Meta.object_class = FloatParameterDefinition diff --git a/ansys/rep/client/jms/resource/int_parameter_definition.py b/ansys/rep/client/jms/resource/int_parameter_definition.py deleted file mode 100644 index fa0ce2124..000000000 --- a/ansys/rep/client/jms/resource/int_parameter_definition.py +++ /dev/null @@ -1,58 +0,0 @@ -# autogenerated code based on IntParameterDefinitionSchema - -from marshmallow.utils import missing -from ansys.rep.client.jms.resource.parameter_definition import ParameterDefinition -from ..schema.parameter_definition import IntParameterDefinitionSchema - -class IntParameterDefinition(ParameterDefinition): - """IntParameterDefinition resource. - - Parameters - ---------- - id : str, optional - Unique ID to access the resource, generated internally by the server on creation. - name : str, optional - Name (ID) of the parameter. - quantity_name : str, optional - Name of the quantity the parameter represents, e.g. Length. - units : str, optional - Units for the parameter. - display_text : str, optional - Text to display as the parameter name. - mode : str - Indicates whether it's an input or output parameter. Filled server side. - type : str - default : int, optional - Default parameter value. - lower_limit : int, optional - Lower bound for the parameter value. - upper_limit : int, optional - Upper bound for the parameter value. - step : int, optional - Equal to 1 by default. - cyclic : bool, optional - Indicates if the parameter is cyclic. - - """ - - class Meta: - schema = IntParameterDefinitionSchema - rest_name = "parameter_definitions" - - def __init__(self, **kwargs): - self.id = missing - self.name = missing - self.quantity_name = missing - self.units = missing - self.display_text = missing - self.mode = missing - self.type = missing - self.default = missing - self.lower_limit = missing - self.upper_limit = missing - self.step = missing - self.cyclic = missing - - super().__init__(**kwargs) - -IntParameterDefinitionSchema.Meta.object_class = IntParameterDefinition diff --git a/ansys/rep/client/jms/resource/job.py b/ansys/rep/client/jms/resource/job.py index 6063e3944..9649552d0 100644 --- a/ansys/rep/client/jms/resource/job.py +++ b/ansys/rep/client/jms/resource/job.py @@ -1,5 +1,4 @@ -# autogenerated code based on JobSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.job import JobSchema @@ -29,16 +28,16 @@ class Job(Object): Optional note for this job. creator : str, optional Optional name/ID of the creator of this job. - executed_task_definition_level : int, optional - Execution level of the last executed process step (-1 if none has been executed yet). + executed_level : int, optional + Execution level of the last executed task (-1 if none has been executed yet). creation_time : datetime, optional The date and time the job was created. modification_time : datetime, optional The date and time the job was last modified. elapsed_time : float Number of seconds it took the evaluator(s) to update the job. - evaluators : list, optional - List of IDs of the evaluators that updated the job. + host_ids : list, optional + List of Host IDs of the evaluators that updated the job. file_ids : list[str] List of IDs of all files of this job. @@ -59,11 +58,11 @@ def __init__(self, **kwargs): self.fitness_term_values = missing self.note = missing self.creator = missing - self.executed_task_definition_level = missing + self.executed_level = missing self.creation_time = missing self.modification_time = missing self.elapsed_time = missing - self.evaluators = missing + self.host_ids = missing self.file_ids = missing super().__init__(**kwargs) diff --git a/ansys/rep/client/jms/resource/job_definition.py b/ansys/rep/client/jms/resource/job_definition.py index 19e493477..ab61d4599 100644 --- a/ansys/rep/client/jms/resource/job_definition.py +++ b/ansys/rep/client/jms/resource/job_definition.py @@ -1,5 +1,4 @@ -# autogenerated code based on JobDefinitionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.job_definition import JobDefinitionSchema @@ -22,7 +21,7 @@ class JobDefinition(Object): parameter_definition_ids : list[str] parameter_mapping_ids : list[str] task_definition_ids : list[str] - fitness_definition : object, optional + fitness_definition : FitnessDefinitionBase, optional A :class:`FitnessDefinition` object. """ diff --git a/ansys/rep/client/jms/resource/license_context.py b/ansys/rep/client/jms/resource/license_context.py index b0ad5d499..341402dd2 100644 --- a/ansys/rep/client/jms/resource/license_context.py +++ b/ansys/rep/client/jms/resource/license_context.py @@ -1,5 +1,4 @@ -# autogenerated code based on LicenseContextSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.license_context import LicenseContextSchema diff --git a/ansys/rep/client/jms/resource/licensing.py b/ansys/rep/client/jms/resource/licensing.py deleted file mode 100644 index ce91ad20f..000000000 --- a/ansys/rep/client/jms/resource/licensing.py +++ /dev/null @@ -1,26 +0,0 @@ -# autogenerated code based on LicensingSchema - -from marshmallow.utils import missing -from ansys.rep.client.common import Object -from ..schema.task_definition import LicensingSchema - -class Licensing(Object): - """Licensing resource. - - Parameters - ---------- - enable_shared_licensing : bool, optional - Whether to enable shared licensing contexts for Ansys simulations - - """ - - class Meta: - schema = LicensingSchema - rest_name = "None" - - def __init__(self, **kwargs): - self.enable_shared_licensing = missing - - super().__init__(**kwargs) - -LicensingSchema.Meta.object_class = Licensing diff --git a/ansys/rep/client/jms/resource/operation.py b/ansys/rep/client/jms/resource/operation.py index f611e1bc9..6681d3982 100644 --- a/ansys/rep/client/jms/resource/operation.py +++ b/ansys/rep/client/jms/resource/operation.py @@ -1,5 +1,4 @@ -# autogenerated code based on OperationSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.operation import OperationSchema diff --git a/ansys/rep/client/jms/resource/parameter_definition.py b/ansys/rep/client/jms/resource/parameter_definition.py index dd7ef9f29..8b8112ec6 100644 --- a/ansys/rep/client/jms/resource/parameter_definition.py +++ b/ansys/rep/client/jms/resource/parameter_definition.py @@ -1,8 +1,11 @@ -# autogenerated code based on ParameterDefinitionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.parameter_definition import ParameterDefinitionSchema +from ..schema.parameter_definition import FloatParameterDefinitionSchema +from ..schema.parameter_definition import IntParameterDefinitionSchema +from ..schema.parameter_definition import BoolParameterDefinitionSchema +from ..schema.parameter_definition import StringParameterDefinitionSchema class ParameterDefinition(Object): """ParameterDefinition resource. @@ -21,3 +24,197 @@ def __init__(self, **kwargs): super().__init__(**kwargs) ParameterDefinitionSchema.Meta.object_class = ParameterDefinition + +class FloatParameterDefinition(ParameterDefinition): + """FloatParameterDefinition resource. + + Parameters + ---------- + id : str, optional + Unique ID to access the resource, generated internally by the server on creation. + name : str, optional + Name (ID) of the parameter. + quantity_name : str, optional + Name of the quantity the parameter represents, e.g. Length. + units : str, optional + Units for the parameter. + display_text : str, optional + Text to display as the parameter name. + mode : str + Indicates whether it's an input or output parameter. Filled server side. + type : str + default : float, optional + Default parameter value. + lower_limit : float, optional + Lower bound for the parameter value. + upper_limit : float, optional + Upper bound for the parameter value. + step : float, optional + If provided, allowable values are given by: AllowableValue = lower_limit + n * step, where n is an integer and AllowableValue <= upper_limit. + cyclic : bool, optional + Indicates if the parameter is cyclic. + value_list : list, optional + A list of allowed values, alternative to providing upper and lower limits. + + """ + + class Meta: + schema = FloatParameterDefinitionSchema + rest_name = "parameter_definitions" + + def __init__(self, **kwargs): + self.id = missing + self.name = missing + self.quantity_name = missing + self.units = missing + self.display_text = missing + self.mode = missing + self.type = missing + self.default = missing + self.lower_limit = missing + self.upper_limit = missing + self.step = missing + self.cyclic = missing + self.value_list = missing + + super().__init__(**kwargs) + +FloatParameterDefinitionSchema.Meta.object_class = FloatParameterDefinition + +class IntParameterDefinition(ParameterDefinition): + """IntParameterDefinition resource. + + Parameters + ---------- + id : str, optional + Unique ID to access the resource, generated internally by the server on creation. + name : str, optional + Name (ID) of the parameter. + quantity_name : str, optional + Name of the quantity the parameter represents, e.g. Length. + units : str, optional + Units for the parameter. + display_text : str, optional + Text to display as the parameter name. + mode : str + Indicates whether it's an input or output parameter. Filled server side. + type : str + default : int, optional + Default parameter value. + lower_limit : int, optional + Lower bound for the parameter value. + upper_limit : int, optional + Upper bound for the parameter value. + step : int, optional + Equal to 1 by default. + cyclic : bool, optional + Indicates if the parameter is cyclic. + + """ + + class Meta: + schema = IntParameterDefinitionSchema + rest_name = "parameter_definitions" + + def __init__(self, **kwargs): + self.id = missing + self.name = missing + self.quantity_name = missing + self.units = missing + self.display_text = missing + self.mode = missing + self.type = missing + self.default = missing + self.lower_limit = missing + self.upper_limit = missing + self.step = missing + self.cyclic = missing + + super().__init__(**kwargs) + +IntParameterDefinitionSchema.Meta.object_class = IntParameterDefinition + +class BoolParameterDefinition(ParameterDefinition): + """BoolParameterDefinition resource. + + Parameters + ---------- + id : str, optional + Unique ID to access the resource, generated internally by the server on creation. + name : str, optional + Name (ID) of the parameter. + quantity_name : str, optional + Name of the quantity the parameter represents, e.g. Length. + units : str, optional + Units for the parameter. + display_text : str, optional + Text to display as the parameter name. + mode : str + Indicates whether it's an input or output parameter. Filled server side. + type : str + default : bool, optional + Default parameter value. + + """ + + class Meta: + schema = BoolParameterDefinitionSchema + rest_name = "parameter_definitions" + + def __init__(self, **kwargs): + self.id = missing + self.name = missing + self.quantity_name = missing + self.units = missing + self.display_text = missing + self.mode = missing + self.type = missing + self.default = missing + + super().__init__(**kwargs) + +BoolParameterDefinitionSchema.Meta.object_class = BoolParameterDefinition + +class StringParameterDefinition(ParameterDefinition): + """StringParameterDefinition resource. + + Parameters + ---------- + id : str, optional + Unique ID to access the resource, generated internally by the server on creation. + name : str, optional + Name (ID) of the parameter. + quantity_name : str, optional + Name of the quantity the parameter represents, e.g. Length. + units : str, optional + Units for the parameter. + display_text : str, optional + Text to display as the parameter name. + mode : str + Indicates whether it's an input or output parameter. Filled server side. + type : str + default : str, optional + Default parameter value. + value_list : list, optional + A list of allowed values. + + """ + + class Meta: + schema = StringParameterDefinitionSchema + rest_name = "parameter_definitions" + + def __init__(self, **kwargs): + self.id = missing + self.name = missing + self.quantity_name = missing + self.units = missing + self.display_text = missing + self.mode = missing + self.type = missing + self.default = missing + self.value_list = missing + + super().__init__(**kwargs) + +StringParameterDefinitionSchema.Meta.object_class = StringParameterDefinition diff --git a/ansys/rep/client/jms/resource/parameter_mapping.py b/ansys/rep/client/jms/resource/parameter_mapping.py index f941b5124..2c45225ce 100644 --- a/ansys/rep/client/jms/resource/parameter_mapping.py +++ b/ansys/rep/client/jms/resource/parameter_mapping.py @@ -1,5 +1,4 @@ -# autogenerated code based on ParameterMappingSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.parameter_mapping import ParameterMappingSchema diff --git a/ansys/rep/client/jms/resource/project.py b/ansys/rep/client/jms/resource/project.py index ddaf6f4f9..7cee191ba 100644 --- a/ansys/rep/client/jms/resource/project.py +++ b/ansys/rep/client/jms/resource/project.py @@ -1,5 +1,4 @@ -# autogenerated code based on ProjectSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.project import ProjectSchema diff --git a/ansys/rep/client/jms/resource/project_permission.py b/ansys/rep/client/jms/resource/project_permission.py index 8bcb246f8..7d559d407 100644 --- a/ansys/rep/client/jms/resource/project_permission.py +++ b/ansys/rep/client/jms/resource/project_permission.py @@ -1,5 +1,4 @@ -# autogenerated code based on ProjectPermissionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.project_permission import ProjectPermissionSchema diff --git a/ansys/rep/client/jms/resource/resource_requirements.py b/ansys/rep/client/jms/resource/resource_requirements.py deleted file mode 100644 index d5ef2997c..000000000 --- a/ansys/rep/client/jms/resource/resource_requirements.py +++ /dev/null @@ -1,33 +0,0 @@ -# autogenerated code based on ResourceRequirementsSchema - -from marshmallow.utils import missing -from ansys.rep.client.common import Object -from ..schema.task_definition import ResourceRequirementsSchema - -class ResourceRequirements(Object): - """ResourceRequirements resource. - - Parameters - ---------- - platform : str, optional - memory : int, optional - cpu_core_usage : float, optional - disk_space : int, optional - custom : dict, optional - - """ - - class Meta: - schema = ResourceRequirementsSchema - rest_name = "None" - - def __init__(self, **kwargs): - self.platform = missing - self.memory = missing - self.cpu_core_usage = missing - self.disk_space = missing - self.custom = missing - - super().__init__(**kwargs) - -ResourceRequirementsSchema.Meta.object_class = ResourceRequirements diff --git a/ansys/rep/client/jms/resource/selection.py b/ansys/rep/client/jms/resource/selection.py index 36fdf9f2a..f088d890c 100644 --- a/ansys/rep/client/jms/resource/selection.py +++ b/ansys/rep/client/jms/resource/selection.py @@ -1,5 +1,4 @@ -# autogenerated code based on JobSelectionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.selection import JobSelectionSchema diff --git a/ansys/rep/client/jms/resource/software.py b/ansys/rep/client/jms/resource/software.py deleted file mode 100644 index a08abf898..000000000 --- a/ansys/rep/client/jms/resource/software.py +++ /dev/null @@ -1,29 +0,0 @@ -# autogenerated code based on SoftwareSchema - -from marshmallow.utils import missing -from ansys.rep.client.common import Object -from ..schema.task_definition import SoftwareSchema - -class Software(Object): - """Software resource. - - Parameters - ---------- - name : str - Application's name. - version : str, optional - Application's version. - - """ - - class Meta: - schema = SoftwareSchema - rest_name = "None" - - def __init__(self, **kwargs): - self.name = missing - self.version = missing - - super().__init__(**kwargs) - -SoftwareSchema.Meta.object_class = Software diff --git a/ansys/rep/client/jms/resource/string_parameter_definition.py b/ansys/rep/client/jms/resource/string_parameter_definition.py deleted file mode 100644 index d5778c202..000000000 --- a/ansys/rep/client/jms/resource/string_parameter_definition.py +++ /dev/null @@ -1,49 +0,0 @@ -# autogenerated code based on StringParameterDefinitionSchema - -from marshmallow.utils import missing -from ansys.rep.client.jms.resource.parameter_definition import ParameterDefinition -from ..schema.parameter_definition import StringParameterDefinitionSchema - -class StringParameterDefinition(ParameterDefinition): - """StringParameterDefinition resource. - - Parameters - ---------- - id : str, optional - Unique ID to access the resource, generated internally by the server on creation. - name : str, optional - Name (ID) of the parameter. - quantity_name : str, optional - Name of the quantity the parameter represents, e.g. Length. - units : str, optional - Units for the parameter. - display_text : str, optional - Text to display as the parameter name. - mode : str - Indicates whether it's an input or output parameter. Filled server side. - type : str - default : str, optional - Default parameter value. - value_list : list, optional - A list of allowed values. - - """ - - class Meta: - schema = StringParameterDefinitionSchema - rest_name = "parameter_definitions" - - def __init__(self, **kwargs): - self.id = missing - self.name = missing - self.quantity_name = missing - self.units = missing - self.display_text = missing - self.mode = missing - self.type = missing - self.default = missing - self.value_list = missing - - super().__init__(**kwargs) - -StringParameterDefinitionSchema.Meta.object_class = StringParameterDefinition diff --git a/ansys/rep/client/jms/resource/success_criteria.py b/ansys/rep/client/jms/resource/success_criteria.py deleted file mode 100644 index a7151db21..000000000 --- a/ansys/rep/client/jms/resource/success_criteria.py +++ /dev/null @@ -1,41 +0,0 @@ -# autogenerated code based on SuccessCriteriaSchema - -from marshmallow.utils import missing -from ansys.rep.client.common import Object -from ..schema.task_definition import SuccessCriteriaSchema - -class SuccessCriteria(Object): - """SuccessCriteria resource. - - Parameters - ---------- - return_code : int, optional - The process exit code that must be returned by the executed command. - expressions : list, optional - A list of expressions to be evaluated. - required_output_file_ids : list[str], optional - List of IDs of required output files. - require_all_output_files : bool, optional - Flag to require all output files. - required_output_parameter_ids : list[str], optional - List of names of required output parameters. - require_all_output_parameters : bool, optional - Flag to require all output parameters. - - """ - - class Meta: - schema = SuccessCriteriaSchema - rest_name = "None" - - def __init__(self, **kwargs): - self.return_code = missing - self.expressions = missing - self.required_output_file_ids = missing - self.require_all_output_files = missing - self.required_output_parameter_ids = missing - self.require_all_output_parameters = missing - - super().__init__(**kwargs) - -SuccessCriteriaSchema.Meta.object_class = SuccessCriteria diff --git a/ansys/rep/client/jms/resource/task.py b/ansys/rep/client/jms/resource/task.py index b76e76a04..d61471b95 100644 --- a/ansys/rep/client/jms/resource/task.py +++ b/ansys/rep/client/jms/resource/task.py @@ -1,5 +1,4 @@ -# autogenerated code based on TaskSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object from ..schema.task import TaskSchema @@ -31,11 +30,11 @@ class Task(Object): Number of seconds it took the evaluator to execute the task. task_definition_id : str ID of the :class:`TaskDefinition` the task is linked to. - task_definition_snapshot : object, optional + task_definition_snapshot : TaskDefinition, optional Snapshot of :class:`TaskDefinition` created when task status changes to prolog, before evaluation. job_id : str ID of the :class:`Job` the task is linked to. - evaluator_id : str, optional + host_id : str, optional UUID of the :class:`Evaluator` that updated the task. input_file_ids : list[str] List of IDs of input files of task. @@ -45,6 +44,8 @@ class Task(Object): List of IDs of inherited files of task. owned_file_ids : list[str] List of IDs of owned files of task. + license_context_id : str, optional + ID of license context in use """ @@ -66,11 +67,12 @@ def __init__(self, **kwargs): self.task_definition_id = missing self.task_definition_snapshot = missing self.job_id = missing - self.evaluator_id = missing + self.host_id = missing self.input_file_ids = missing self.output_file_ids = missing self.inherited_file_ids = missing self.owned_file_ids = missing + self.license_context_id = missing super().__init__(**kwargs) diff --git a/ansys/rep/client/jms/resource/task_definition.py b/ansys/rep/client/jms/resource/task_definition.py index e891caa73..a35c3b2a0 100644 --- a/ansys/rep/client/jms/resource/task_definition.py +++ b/ansys/rep/client/jms/resource/task_definition.py @@ -1,9 +1,121 @@ -# autogenerated code based on TaskDefinitionSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object +from ..schema.task_definition import ResourceRequirementsSchema +from ..schema.task_definition import SoftwareSchema +from ..schema.task_definition import SuccessCriteriaSchema +from ..schema.task_definition import LicensingSchema from ..schema.task_definition import TaskDefinitionSchema +class ResourceRequirements(Object): + """ResourceRequirements resource. + + Parameters + ---------- + platform : str, optional + memory : int, optional + cpu_core_usage : float, optional + disk_space : int, optional + custom : dict, optional + + """ + + class Meta: + schema = ResourceRequirementsSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.platform = missing + self.memory = missing + self.cpu_core_usage = missing + self.disk_space = missing + self.custom = missing + + super().__init__(**kwargs) + +ResourceRequirementsSchema.Meta.object_class = ResourceRequirements + +class Software(Object): + """Software resource. + + Parameters + ---------- + name : str + Application's name. + version : str, optional + Application's version. + + """ + + class Meta: + schema = SoftwareSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.name = missing + self.version = missing + + super().__init__(**kwargs) + +SoftwareSchema.Meta.object_class = Software + +class SuccessCriteria(Object): + """SuccessCriteria resource. + + Parameters + ---------- + return_code : int, optional + The process exit code that must be returned by the executed command. + expressions : list, optional + A list of expressions to be evaluated. + required_output_file_ids : list[str], optional + List of IDs of required output files. + require_all_output_files : bool, optional + Flag to require all output files. + required_output_parameter_ids : list[str], optional + List of names of required output parameters. + require_all_output_parameters : bool, optional + Flag to require all output parameters. + + """ + + class Meta: + schema = SuccessCriteriaSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.return_code = missing + self.expressions = missing + self.required_output_file_ids = missing + self.require_all_output_files = missing + self.required_output_parameter_ids = missing + self.require_all_output_parameters = missing + + super().__init__(**kwargs) + +SuccessCriteriaSchema.Meta.object_class = SuccessCriteria + +class Licensing(Object): + """Licensing resource. + + Parameters + ---------- + enable_shared_licensing : bool, optional + Whether to enable shared licensing contexts for Ansys simulations + + """ + + class Meta: + schema = LicensingSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.enable_shared_licensing = missing + + super().__init__(**kwargs) + +LicensingSchema.Meta.object_class = Licensing + class TaskDefinition(Object): """TaskDefinition resource. @@ -35,12 +147,12 @@ class TaskDefinition(Object): List of IDs of input files. output_file_ids : list[str] List of IDs of output files. - success_criteria : object, optional - licensing : object, optional + success_criteria : SuccessCriteria, optional + licensing : Licensing, optional A :class:`Licensing` object. - software_requirements : object, optional + software_requirements : Software, optional A list of :class:`Software` objects. - resource_requirements : object, optional + resource_requirements : ResourceRequirements, optional A :class:`ResourceRequirements` object. """ diff --git a/ansys/rep/client/jms/resource/task_definition_template.py b/ansys/rep/client/jms/resource/task_definition_template.py index 3a4be1664..f8c3e3fe9 100644 --- a/ansys/rep/client/jms/resource/task_definition_template.py +++ b/ansys/rep/client/jms/resource/task_definition_template.py @@ -1,9 +1,142 @@ -# autogenerated code based on TaskDefinitionTemplateSchema - +# autogenerated code from marshmallow.utils import missing from ansys.rep.client.common import Object +from ..schema.task_definition_template import TemplatePropertySchema +from ..schema.task_definition_template import TemplateResourceRequirementsSchema +from ..schema.task_definition_template import TemplateInputFileSchema +from ..schema.task_definition_template import TemplateOutputFileSchema from ..schema.task_definition_template import TaskDefinitionTemplateSchema +class TemplateProperty(Object): + """TemplateProperty resource. + + Parameters + ---------- + default : any, optional + Default value. + description : str, optional + Description of the property's purpose. + type : str, optional + Type of the property: either int, float, bool or string. + value_list : any, optional + List of possible values for this property. + + """ + + class Meta: + schema = TemplatePropertySchema + rest_name = "None" + + def __init__(self, **kwargs): + self.default = missing + self.description = missing + self.type = missing + self.value_list = missing + + super().__init__(**kwargs) + +TemplatePropertySchema.Meta.object_class = TemplateProperty + +class TemplateResourceRequirements(Object): + """TemplateResourceRequirements resource. + + Parameters + ---------- + platform : TemplateProperty, optional + memory : TemplateProperty, optional + cpu_core_usage : TemplateProperty, optional + disk_space : TemplateProperty, optional + custom : dict, optional + + """ + + class Meta: + schema = TemplateResourceRequirementsSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.platform = missing + self.memory = missing + self.cpu_core_usage = missing + self.disk_space = missing + self.custom = missing + + super().__init__(**kwargs) + +TemplateResourceRequirementsSchema.Meta.object_class = TemplateResourceRequirements + +class TemplateInputFile(Object): + """TemplateInputFile resource. + + Parameters + ---------- + name : str + Name of the file. + type : str, optional + MIME type of the file, ie. text/plain. + evaluation_path : str, optional + Path under which the file is expected to be found during evaluation. + description : str + Description of the file's purpose. + required : bool + Is the file required by the task + + """ + + class Meta: + schema = TemplateInputFileSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.name = missing + self.type = missing + self.evaluation_path = missing + self.description = missing + self.required = missing + + super().__init__(**kwargs) + +TemplateInputFileSchema.Meta.object_class = TemplateInputFile + +class TemplateOutputFile(Object): + """TemplateOutputFile resource. + + Parameters + ---------- + name : str + Name of the file. + type : str, optional + MIME type of the file, ie. text/plain. + evaluation_path : str, optional + Path under which the file is expected to be found during evaluation. + description : str + Description of the file's purpose. + required : bool + Is the file required by the task + monitor : bool, optional + Should the file's contents be live monitored. + collect : bool, optional + Should files be collected per job. + + """ + + class Meta: + schema = TemplateOutputFileSchema + rest_name = "None" + + def __init__(self, **kwargs): + self.name = missing + self.type = missing + self.evaluation_path = missing + self.description = missing + self.required = missing + self.monitor = missing + self.collect = missing + + super().__init__(**kwargs) + +TemplateOutputFileSchema.Meta.object_class = TemplateOutputFile + class TaskDefinitionTemplate(Object): """TaskDefinitionTemplate resource. @@ -12,27 +145,33 @@ class TaskDefinitionTemplate(Object): id : str, optional Unique ID to access the resource, generated internally by the server on creation. modification_time : datetime, optional - Last time the object was modified, in UTC + Last time the object was modified, in UTC. creation_time : datetime, optional - Time when the object was created, in UTC + Time when the object was created, in UTC. name : str Name of the template version : str, optional - version of the template - software_requirements : object, optional - resource_requirements : object, optional + Version of the template + description : str, optional + Description of the template + software_requirements : Software, optional + A list of required software. + resource_requirements : TemplateResourceRequirements, optional + Includes hardware requirements such as number of cores, memory and disk space. execution_context : dict, optional - Additional arguments to pass to the executing command + Additional arguments to pass to the executing command. environment : dict, optional - Environment variables to set for the executed process + Environment variables to set for the executed process. execution_command : str, optional Command to execute (command or execution script is required). use_execution_script : bool, optional Whether to run task with the execution command or the execution script. execution_script_storage_id : str, optional Storage ID of the script to execute (command or execution script is required). - input_files : object, optional - output_files : object, optional + input_files : TemplateInputFile, optional + List of predefined input files. + output_files : TemplateOutputFile, optional + List of predefined output files. """ @@ -46,6 +185,7 @@ def __init__(self, **kwargs): self.creation_time = missing self.name = missing self.version = missing + self.description = missing self.software_requirements = missing self.resource_requirements = missing self.execution_context = missing diff --git a/ansys/rep/client/jms/schema/job.py b/ansys/rep/client/jms/schema/job.py index ba235cac4..fa5f280a7 100644 --- a/ansys/rep/client/jms/schema/job.py +++ b/ansys/rep/client/jms/schema/job.py @@ -62,10 +62,11 @@ class Meta(ObjectSchema.Meta): creator = fields.String( allow_none=True, description="Optional name/ID of the creator of this job." ) - executed_task_definition_level = fields.Integer( + + executed_level = fields.Integer( allow_none=True, description="Execution level of the last executed " - "process step (-1 if none has been executed yet).", + "task (-1 if none has been executed yet).", ) creation_time = fields.DateTime( @@ -83,10 +84,10 @@ class Meta(ObjectSchema.Meta): description="Number of seconds it took the evaluator(s) to update the job.", ) - evaluators = fields.List( + host_ids = fields.List( fields.String(allow_none=True), allow_none=True, - description="List of IDs of the evaluators that updated the job.", + description="List of Host IDs of the evaluators that updated the job.", ) file_ids = IdReferenceList( referenced_class="File", diff --git a/ansys/rep/client/jms/schema/task.py b/ansys/rep/client/jms/schema/task.py index e818b4f31..a48f5630c 100644 --- a/ansys/rep/client/jms/schema/task.py +++ b/ansys/rep/client/jms/schema/task.py @@ -73,7 +73,7 @@ class Meta(ObjectSchema.Meta): description="ID of the :class:`Job` the task is linked to.", ) - evaluator_id = fields.String( + host_id = fields.String( allow_none=True, description="UUID of the :class:`Evaluator` that updated the task.", ) @@ -99,3 +99,8 @@ class Meta(ObjectSchema.Meta): attribute="owned_file_ids", description="List of IDs of owned files of task.", ) + + license_context_id = fields.String( + allow_none=True, + metadata={"description": "ID of license context in use"}, + ) diff --git a/ansys/rep/client/jms/schema/task_definition_template.py b/ansys/rep/client/jms/schema/task_definition_template.py index 58a10c890..b08475f4d 100644 --- a/ansys/rep/client/jms/schema/task_definition_template.py +++ b/ansys/rep/client/jms/schema/task_definition_template.py @@ -6,12 +6,76 @@ # Author(s): F. Negri # ---------------------------------------------------------- -from marshmallow import fields +from marshmallow import fields, validate -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import BaseSchema, ObjectSchema -from .file import FileSchema -from .task_definition import ResourceRequirementsSchema, SoftwareSchema +from .task_definition import SoftwareSchema + + +class TemplatePropertySchema(BaseSchema): + class Meta(BaseSchema.Meta): + pass + + default = fields.Raw(allow_none=True, metadata={"description": "Default value."}) + description = fields.String( + allow_none=True, metadata={"description": "Description of the property's purpose."} + ) + type = fields.String( + allow_none=True, + validate=validate.OneOf(["int", "float", "bool", "string"]), + metadata={"description": "Type of the property: either int, float, bool or string."}, + ) + value_list = fields.Raw( + allow_none=True, + many=True, + default=[], + metadata={"description": "List of possible values for this property."}, + ) + + +class TemplateResourceRequirementsSchema(BaseSchema): + class Meta(BaseSchema.Meta): + pass + + platform = fields.Nested(TemplatePropertySchema, allow_none=True) + memory = fields.Nested(TemplatePropertySchema, allow_none=True) + cpu_core_usage = fields.Nested(TemplatePropertySchema, allow_none=True) + disk_space = fields.Nested(TemplatePropertySchema, allow_none=True) + custom = fields.Dict( + keys=fields.String, values=fields.Nested(TemplatePropertySchema), allow_none=True + ) + + +class TemplateFileSchema(BaseSchema): + class Meta(BaseSchema.Meta): + pass + + name = fields.String(description="Name of the file.") + type = fields.String( + allow_none=True, metadata={"description": "MIME type of the file, ie. text/plain."} + ) + evaluation_path = fields.String( + allow_none=True, + metadata={ + "description": "Path under which the file is expected to be found during evaluation." + }, + ) + description = fields.String(metadata={"description": "Description of the file's purpose."}) + required = fields.Bool(metadata={"description": "Is the file required by the task"}) + + +class TemplateInputFileSchema(TemplateFileSchema): + pass + + +class TemplateOutputFileSchema(TemplateFileSchema): + monitor = fields.Bool( + allow_none=True, metadata={"description": "Should the file's contents be live monitored."} + ) + collect = fields.Bool( + allow_none=True, metadata={"description": "Should files be collected per job."} + ) class TaskDefinitionTemplateSchema(ObjectSchema): @@ -19,23 +83,42 @@ class Meta(ObjectSchema.Meta): pass modification_time = fields.DateTime( - allow_none=True, load_only=True, description="Last time the object was modified, in UTC" + allow_none=True, load_only=True, description="Last time the object was modified, in UTC." ) creation_time = fields.DateTime( - allow_none=True, load_only=True, description="Time when the object was created, in UTC" + allow_none=True, load_only=True, description="Time when the object was created, in UTC." ) name = fields.String(description="Name of the template") - version = fields.String(description="version of the template", allow_none=True) + version = fields.String(description="Version of the template", allow_none=True) + description = fields.String(description="Description of the template", allow_none=True) - software_requirements = fields.Nested(SoftwareSchema, many=True, allow_none=True) - resource_requirements = fields.Nested(ResourceRequirementsSchema, allow_none=True) + software_requirements = fields.Nested( + SoftwareSchema, + many=True, + allow_none=True, + metadata={"description": "A list of required software."}, + ) + resource_requirements = fields.Nested( + TemplateResourceRequirementsSchema, + allow_none=True, + metadata={ + "description": "Includes hardware requirements such as number of cores," + " memory and disk space." + }, + ) execution_context = fields.Dict( - allow_none=True, description="Additional arguments to pass to the executing command" + keys=fields.String, + values=fields.Nested(TemplatePropertySchema), + allow_none=True, + description="Additional arguments to pass to the executing command.", ) environment = fields.Dict( - allow_none=True, description="Environment variables to set for the executed process" + keys=fields.String, + values=fields.Nested(TemplatePropertySchema), + allow_none=True, + description="Environment variables to set for the executed process.", ) execution_command = fields.String( @@ -51,5 +134,15 @@ class Meta(ObjectSchema.Meta): "(command or execution script is required).", ) - input_files = fields.Nested(FileSchema, many=True, allow_none=True) - output_files = fields.Nested(FileSchema, many=True, allow_none=True) + input_files = fields.Nested( + TemplateInputFileSchema, + many=True, + allow_none=True, + metadata={"description": "List of predefined input files."}, + ) + output_files = fields.Nested( + TemplateOutputFileSchema, + many=True, + allow_none=True, + metadata={"description": "List of predefined output files."}, + ) diff --git a/doc/source/api/jms.rst b/doc/source/api/jms.rst index b75033bce..664a01a60 100644 --- a/doc/source/api/jms.rst +++ b/doc/source/api/jms.rst @@ -131,5 +131,17 @@ Evaluator Task Definition Template ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. autoclass:: ansys.rep.client.jms.TemplateProperty + :members: + +.. autoclass:: ansys.rep.client.jms.TemplateResourceRequirements + :members: + +.. autoclass:: ansys.rep.client.jms.TemplateInputFile + :members: + +.. autoclass:: ansys.rep.client.jms.TemplateOutputFile + :members: + .. autoclass:: ansys.rep.client.jms.TaskDefinitionTemplate :members: \ No newline at end of file diff --git a/generate_resources.py b/generate_resources.py index ddd0dde1f..4ade65f6a 100644 --- a/generate_resources.py +++ b/generate_resources.py @@ -117,7 +117,7 @@ "rest_name": None, "additional_fields": [], "class": "ResourceRequirements", - "resource_filename": "resource_requirements", + "resource_filename": "task_definition", }, { "schema": "SoftwareSchema", @@ -125,7 +125,7 @@ "rest_name": None, "additional_fields": [], "class": "Software", - "resource_filename": "software", + "resource_filename": "task_definition", }, { "schema": "SuccessCriteriaSchema", @@ -133,7 +133,7 @@ "rest_name": None, "additional_fields": [], "class": "SuccessCriteria", - "resource_filename": "success_criteria", + "resource_filename": "task_definition", }, { "schema": "LicensingSchema", @@ -141,7 +141,15 @@ "rest_name": None, "additional_fields": [], "class": "Licensing", - "resource_filename": "licensing", + "resource_filename": "task_definition", + }, + { + "schema": "TaskDefinitionSchema", + "schema_filename": "task_definition", + "rest_name": "task_definitions", + "additional_fields": [], + "class": "TaskDefinition", + "resource_filename": "task_definition", }, { "schema": "JobSelectionSchema", @@ -152,20 +160,44 @@ "resource_filename": "selection", }, { - "schema": "TaskDefinitionTemplateSchema", + "schema": "TemplatePropertySchema", "schema_filename": "task_definition_template", - "rest_name": "task_definition_templates", + "rest_name": None, "additional_fields": [], - "class": "TaskDefinitionTemplate", + "class": "TemplateProperty", "resource_filename": "task_definition_template", }, { - "schema": "TaskDefinitionSchema", - "schema_filename": "task_definition", - "rest_name": "task_definitions", + "schema": "TemplateResourceRequirementsSchema", + "schema_filename": "task_definition_template", + "rest_name": None, "additional_fields": [], - "class": "TaskDefinition", - "resource_filename": "task_definition", + "class": "TemplateResourceRequirements", + "resource_filename": "task_definition_template", + }, + { + "schema": "TemplateInputFileSchema", + "schema_filename": "task_definition_template", + "rest_name": None, + "additional_fields": [], + "class": "TemplateInputFile", + "resource_filename": "task_definition_template", + }, + { + "schema": "TemplateOutputFileSchema", + "schema_filename": "task_definition_template", + "rest_name": None, + "additional_fields": [], + "class": "TemplateOutputFile", + "resource_filename": "task_definition_template", + }, + { + "schema": "TaskDefinitionTemplateSchema", + "schema_filename": "task_definition_template", + "rest_name": "task_definition_templates", + "additional_fields": [], + "class": "TaskDefinitionTemplate", + "resource_filename": "task_definition_template", }, { "schema": "TaskSchema", @@ -190,7 +222,7 @@ "additional_fields": [], "base_class": "ParameterDefinition", "class": "FloatParameterDefinition", - "resource_filename": "float_parameter_definition", + "resource_filename": "parameter_definition", }, { "schema": "IntParameterDefinitionSchema", @@ -199,7 +231,7 @@ "additional_fields": [], "base_class": "ParameterDefinition", "class": "IntParameterDefinition", - "resource_filename": "int_parameter_definition", + "resource_filename": "parameter_definition", }, { "schema": "BoolParameterDefinitionSchema", @@ -208,7 +240,7 @@ "additional_fields": [], "base_class": "ParameterDefinition", "class": "BoolParameterDefinition", - "resource_filename": "bool_parameter_definition", + "resource_filename": "parameter_definition", }, { "schema": "StringParameterDefinitionSchema", @@ -217,7 +249,7 @@ "additional_fields": [], "base_class": "ParameterDefinition", "class": "StringParameterDefinition", - "resource_filename": "string_parameter_definition", + "resource_filename": "parameter_definition", }, ] @@ -248,7 +280,7 @@ } -def declared_fields(schema): +def declared_fields(schema, resources): """ Helper function to retrieve the fields that will be defined as class members for an object """ @@ -265,6 +297,12 @@ def declared_fields(schema): field_doc = f"{field}" if v.__class__ == marshmallow.fields.Constant: field_type = type(v.constant).__name__ + elif v.__class__ == marshmallow.fields.Nested: + field_type_schema = v.nested.__name__ + field_type = next( + (r["class"] for r in resources if r["schema"] == field_type_schema), + "object", + ) else: field_type = FIELD_MAPPING.get(v.__class__, None) if field_type: @@ -281,19 +319,20 @@ def declared_fields(schema): return fields, fields_doc -def get_generated_code(resource, base_class, fields, field_docs): +def get_resource_imports(resource, base_class): - base_class_import = ( - f"from {base_class['path']}.{base_class['filename']} import {base_class['name']}" - ) + imports = [ + "from marshmallow.utils import missing", + "from ansys.rep.client.common import Object", + # f"from {base_class['path']}.{base_class['filename']} import {base_class['name']}", + f"from ..schema.{resource['schema_filename']} import {resource['schema']}", + ] + return imports - code = f'''# autogenerated code based on {resource["schema"]} -from marshmallow.utils import missing -{base_class_import} -from ..schema.{resource['schema_filename']} import {resource['schema']} +def get_resource_code(resource, base_class, fields, field_docs): -class {resource['class']}({base_class["name"]}): + code = f'''class {resource['class']}({base_class["name"]}): """{resource['class']} resource. Parameters @@ -316,7 +355,8 @@ def __init__(self, **kwargs): def process_resources(subpackage, resources, base_class_path="ansys.rep.client"): - targe_folder = os.path.join("ansys", "rep", "client", subpackage, "resource") + target_folder = os.path.join("ansys", "rep", "client", subpackage, "resource") + resources_code = {} for resource in resources: print(f"Processing resource {resource['class']}") @@ -327,7 +367,7 @@ def process_resources(subpackage, resources, base_class_path="ansys.rep.client") resource_class = getattr(module, resource["schema"]) # query schema field names and doc - fields, field_docs = declared_fields(resource_class) + fields, field_docs = declared_fields(resource_class, resources) fields_str = "" for k in fields: @@ -351,12 +391,26 @@ def process_resources(subpackage, resources, base_class_path="ansys.rep.client") ) # we're ready to put the pieces together - code = get_generated_code(resource, base_class, fields_str, field_docs_str) + file_name = resource["resource_filename"] + if not file_name in resources_code: + resources_code[file_name] = {"imports": [], "code": []} + + resources_code[file_name]["imports"].extend(get_resource_imports(resource, base_class)) + resources_code[file_name]["code"].append( + get_resource_code(resource, base_class, fields_str, field_docs_str) + ) - # dump generated code to file - file_path = os.path.join(targe_folder, f"{resource['resource_filename']}.py") + # dump generated code to files + for file, content in resources_code.items(): + file_path = os.path.join(target_folder, f"{file}.py") + print(f"=== file={file}, file_path={file_path}") + unique_imports = list(dict.fromkeys(content["imports"])) + code = content["code"] with open(file_path, "w") as file: - file.write(code) + file.write("# autogenerated code\n") + file.write("\n".join(unique_imports)) + file.write("\n\n") + file.write("\n".join(code)) def run(): diff --git a/tests/jms/test_jobs.py b/tests/jms/test_jobs.py index e81afb8f3..5eb4be080 100644 --- a/tests/jms/test_jobs.py +++ b/tests/jms/test_jobs.py @@ -37,7 +37,7 @@ def test_job_deserialization(self): "fitness_term_values": {"fit_term1": 1.5}, "note": "hello", "creator": "Creator.1", - "executed_task_definition_level": 0, + "executed_level": 0, "values": { "tube1_radius": 12.509928919324276, "tube1_thickness": 0.588977941435834, @@ -56,7 +56,7 @@ def test_job_deserialization(self): "tube3": "2", }, "elapsed_time": 14.922003, - "evaluators": ["9be2d91a-abb1-3b68-bc36-d23a990a9792"], + "host_ids": ["9be2d91a-abb1-3b68-bc36-d23a990a9792"], "file_ids": [ "02q3QVM1RJMzSKccWZ5gUT", "02q3QKzo7389RU5tGfDhPj", @@ -79,14 +79,14 @@ def test_job_deserialization(self): self.assertEqual(job.note, "hello") self.assertEqual(job.creator, "Creator.1") - self.assertEqual(job.executed_task_definition_level, 0) + self.assertEqual(job.executed_level, 0) self.assertEqual(len(job.values), 15) self.assertAlmostEqual(job.values["tube1_radius"], 12.509928919324276) self.assertAlmostEqual(job.values["mapdl_elapsed_time"], 3.0) self.assertEqual(job.values["tube1"], "1") self.assertAlmostEqual(job.elapsed_time, 14.922003) - self.assertEqual(job.evaluators, ["9be2d91a-abb1-3b68-bc36-d23a990a9792"]) + self.assertEqual(job.host_ids, ["9be2d91a-abb1-3b68-bc36-d23a990a9792"]) self.assertEqual( job.file_ids, [ @@ -104,7 +104,7 @@ def test_job_serialization(self): job = Job( name="dp0", job_definition_id=2, - evaluators=["uuid-4", "uuid-5"], + host_ids=["uuid-4", "uuid-5"], values={"p1": "string_value", "p2": 8.9, "p3": True}, creator="dcs-client", elapsed_time=40.8, @@ -123,8 +123,8 @@ def test_job_serialization(self): self.assertEqual(serialized_job["values"]["p3"], True) self.assertFalse("fitness" in serialized_job.keys()) self.assertFalse("files" in serialized_job.keys()) - self.assertEqual(len(serialized_job["evaluators"]), 2) - self.assertEqual(serialized_job["evaluators"][1], "uuid-5") + self.assertEqual(len(serialized_job["host_ids"]), 2) + self.assertEqual(serialized_job["host_ids"][1], "uuid-5") def test_job_integration(self): @@ -160,7 +160,7 @@ def test_job_integration(self): self.assertEqual(job.creator, None) self.assertEqual(job.note, None) self.assertEqual(job.fitness, None) - self.assertTrue(job.executed_task_definition_level is not None) + self.assertTrue(job.executed_level is not None) jobs = project_api.get_jobs() for job in jobs: @@ -168,7 +168,7 @@ def test_job_integration(self): self.assertEqual(job.creator, None) self.assertEqual(job.note, None) self.assertEqual(job.fitness, None) - self.assertTrue(job.executed_task_definition_level is not None) + self.assertTrue(job.executed_level is not None) # fill some of them job.creator = "rep-client" job.note = f"test job{job.id} update" @@ -180,7 +180,7 @@ def test_job_integration(self): self.assertTrue(job.note is not None) self.assertTrue(job.job_definition_id, 1) self.assertEqual(job.fitness, None) - self.assertTrue(job.executed_task_definition_level is not None) + self.assertTrue(job.executed_level is not None) jobs = project_api.get_jobs(limit=2, fields=["id", "creator", "note"]) diff --git a/tests/jms/test_task_definition_templates.py b/tests/jms/test_task_definition_templates.py index eeb5ec9c4..c3df6aeb7 100644 --- a/tests/jms/test_task_definition_templates.py +++ b/tests/jms/test_task_definition_templates.py @@ -14,7 +14,7 @@ from marshmallow.utils import missing from ansys.rep.client.jms import JmsApi -from ansys.rep.client.jms.resource.task_definition_template import TaskDefinitionTemplate +from ansys.rep.client.jms.resource import TaskDefinitionTemplate from ansys.rep.client.jms.schema.task_definition_template import TaskDefinitionTemplateSchema from tests.rep_test import REPTestCase @@ -41,7 +41,6 @@ def test_template_deserialization(self): "output_files": [ { "name": "out", - "obj_type": "File", "evaluation_path": "solve.out", "type": "text/plain", "collect": True, @@ -49,13 +48,21 @@ def test_template_deserialization(self): }, { "name": "cnd", - "obj_type": "File", "evaluation_path": "file.cnd", "type": "application/octet-stream", "collect": True, "monitor": False, }, ], + "execution_context": { + "parallel_processing_type": { + "default": "DMP", + "type": "string", + "description": "Available parallel processing types.", + "display_name": "Parallel Processing Type", + "value_list": ["DMP", "SMP", "Hybrid"], + }, + }, } template = TaskDefinitionTemplateSchema().load(json_data) @@ -63,16 +70,23 @@ def test_template_deserialization(self): self.assertEqual(template.__class__.__name__, "TaskDefinitionTemplate") self.assertEqual(template.modification_time, missing) self.assertEqual(template.name, json_data["name"]) + self.assertEqual(template.execution_context["parallel_processing_type"].default, "DMP") + self.assertEqual(len(template.execution_context["parallel_processing_type"].value_list), 3) + self.assertTrue( + "Hybrid" in template.execution_context["parallel_processing_type"].value_list + ) self.assertEqual(len(template.output_files), 2) + self.assertEqual(template.output_files[0].name, "out") + self.assertEqual(template.output_files[1].type, "application/octet-stream") json_data["software_requirements"][0]["version"] = "2022 R2" json_data["execution_command"] = "my command line" - json_data["execution_context"] = {"my_new_field": "value"} + json_data["execution_context"] = {"my_new_field": {"default": "value", "type": "string"}} template = TaskDefinitionTemplateSchema().load(json_data) self.assertEqual(template.software_requirements[0].version, "2022 R2") self.assertEqual(template.execution_command, "my command line") - self.assertEqual(template.execution_context["my_new_field"], "value") + self.assertEqual(template.execution_context["my_new_field"].default, "value") def test_template_integration(self): diff --git a/tests/jms/test_tasks.py b/tests/jms/test_tasks.py index e6a147e32..cd418a78c 100644 --- a/tests/jms/test_tasks.py +++ b/tests/jms/test_tasks.py @@ -39,7 +39,7 @@ def test_task_deserialization(self): "elapsed_time": 20.733581, "task_definition_id": "02q3zCLSZjRkJhCzjVjyYn", "job_id": "02q3zCLScqou7nbJBXFEfw", - "evaluator_id": "9be2d91a-abb1-3b68-bc36-d23a990a9792", + "host_id": "9be2d91a-abb1-3b68-bc36-d23a990a9792", "license_context_id": None, "input_file_ids": ["02q3zEBtQFm0UcdNSLPvC9"], "output_file_ids": [ @@ -68,7 +68,7 @@ def test_task_deserialization(self): self.assertAlmostEqual(task.elapsed_time, 20.733581) self.assertEqual(task.task_definition_id, "02q3zCLSZjRkJhCzjVjyYn") self.assertEqual(task.job_id, "02q3zCLScqou7nbJBXFEfw") - self.assertEqual(task.evaluator_id, "9be2d91a-abb1-3b68-bc36-d23a990a9792") + self.assertEqual(task.host_id, "9be2d91a-abb1-3b68-bc36-d23a990a9792") # self.assertEqual( task.uuid, "f6775a29-d98b-4048-a14d-ea86669e55d0") # self.assertEqual( task.license_context_id, None) self.assertEqual(task.input_file_ids, ["02q3zEBtQFm0UcdNSLPvC9"])