diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d9d873a07..d7656595d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -75,11 +75,11 @@ jobs: - name: Start services run: | - docker-compose pull - LOCALHOST_ADDR=localhost docker-compose up -d keycloak + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev docker-compose pull + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev LOCALHOST_ADDR=localhost docker-compose up -d keycloak echo "Waiting a few sec ..." sleep 5 - LOCALHOST_ADDR=localhost docker-compose up -d + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev LOCALHOST_ADDR=localhost docker-compose up -d working-directory: ./rep-deployments/docker-compose - name: Test with tox diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1bef91f13..4cd7c9459 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -74,11 +74,11 @@ jobs: - name: Start services run: | - docker-compose pull - LOCALHOST_ADDR=localhost docker-compose up -d keycloak + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev docker-compose pull + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev LOCALHOST_ADDR=localhost docker-compose up -d keycloak echo "Waiting a few sec ..." sleep 5 - LOCALHOST_ADDR=localhost docker-compose up -d + FSGATEWAY_TAG=latest-dev JMS_TAG=latest-dev LOCALHOST_ADDR=localhost docker-compose up -d working-directory: ./rep-deployments/docker-compose - name: Test with tox diff --git a/ansys/rep/client/common/__init__.py b/ansys/rep/client/common/__init__.py index f145cb6d5..92e5ae263 100644 --- a/ansys/rep/client/common/__init__.py +++ b/ansys/rep/client/common/__init__.py @@ -1,3 +1,3 @@ from .base_resource import Object -from .base_schema import BaseSchema, ObjectSchema +from .base_schema import BaseSchema, ObjectSchema, ObjectSchemaWithModificationInfo from .restricted_value import RestrictedValue diff --git a/ansys/rep/client/common/base_schema.py b/ansys/rep/client/common/base_schema.py index e25876128..fbb518516 100644 --- a/ansys/rep/client/common/base_schema.py +++ b/ansys/rep/client/common/base_schema.py @@ -25,6 +25,41 @@ class ObjectSchema(BaseSchema): id = fields.String( allow_none=True, attribute="id", - description="Unique ID to access the resource, generated " - "internally by the server on creation.", + metadata={ + "description": "Unique ID to access the resource, generated " + "internally by the server on creation." + }, + ) + + +class ObjectSchemaWithModificationInfo(ObjectSchema): + + creation_time = fields.DateTime( + allow_none=True, + load_only=True, + metadata={ + "description": "The date and time the resource was created.", + }, + ) + modification_time = fields.DateTime( + allow_none=True, + load_only=True, + metadata={ + "description": "The date and time the resource was last modified.", + }, + ) + + created_by = fields.String( + allow_none=True, + load_only=True, + metadata={ + "description": "ID of the user who created the object.", + }, + ) + modified_by = fields.String( + allow_none=True, + load_only=True, + metadata={ + "description": "ID of the user who last modified the object.", + }, ) diff --git a/ansys/rep/client/jms/api/project_api.py b/ansys/rep/client/jms/api/project_api.py index cb984a8ba..1a68e629b 100644 --- a/ansys/rep/client/jms/api/project_api.py +++ b/ansys/rep/client/jms/api/project_api.py @@ -9,7 +9,7 @@ from ansys.rep.client.client import Client from ansys.rep.client.common import Object -from ansys.rep.client.exceptions import ClientError, REPError +from ansys.rep.client.exceptions import REPError from ansys.rep.client.jms.resource import ( Algorithm, File, @@ -566,7 +566,7 @@ def _download_file( ) -> str: if getattr(file, "hash", None) is None: - raise ClientError(f"No hash found. Failed to download file {file.name}") + log.warning(f"No hash found for file {file.name}.") Path(target_path).mkdir(parents=True, exist_ok=True) download_link = f"{project_api.fs_bucket_url}/{file.storage_id}" diff --git a/ansys/rep/client/jms/resource/algorithm.py b/ansys/rep/client/jms/resource/algorithm.py index 2b1fab686..c05924025 100644 --- a/ansys/rep/client/jms/resource/algorithm.py +++ b/ansys/rep/client/jms/resource/algorithm.py @@ -10,14 +10,18 @@ class Algorithm(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name of the algorithm. description : str, optional Description of the algorithm. - creation_time : datetime, optional - The date and time the algorithm was created. - modification_time : datetime, optional - The date and time the algorithm was last modified. data : str, optional Generic string field to hold arbitrary algorithm configuration data, e.g. as JSON dictionary. jobs : list[str] @@ -31,18 +35,22 @@ class Meta: def __init__(self, id=missing, - name=missing, - description=missing, creation_time=missing, modification_time=missing, + created_by=missing, + modified_by=missing, + name=missing, + description=missing, data=missing, jobs=missing ): self.id = id - self.name = name - self.description = description self.creation_time = creation_time self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by + self.name = name + self.description = description self.data = data self.jobs = jobs diff --git a/ansys/rep/client/jms/resource/file.py b/ansys/rep/client/jms/resource/file.py index f5ec40999..ceb1f3a47 100644 --- a/ansys/rep/client/jms/resource/file.py +++ b/ansys/rep/client/jms/resource/file.py @@ -25,6 +25,10 @@ class File(Object): The date and time the file resource was created. modification_time : datetime, optional The date and time the file resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. format : str, optional expiry_time : datetime, optional File expiration time. @@ -54,6 +58,8 @@ def __init__(self, src=None, hash=missing, creation_time=missing, modification_time=missing, + created_by=missing, + modified_by=missing, expiry_time=missing, format=missing, evaluation_path=missing, @@ -73,6 +79,8 @@ def __init__(self, src=None, self.hash = hash self.creation_time = creation_time self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.expiry_time = expiry_time self.format = format self.evaluation_path = evaluation_path diff --git a/ansys/rep/client/jms/resource/job.py b/ansys/rep/client/jms/resource/job.py index 47cc0feaf..6c0656f15 100644 --- a/ansys/rep/client/jms/resource/job.py +++ b/ansys/rep/client/jms/resource/job.py @@ -10,6 +10,14 @@ class Job(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name of the job. eval_status : str @@ -30,10 +38,6 @@ class Job(Object): Optional name/ID of the creator of this job. 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. host_ids : list, optional @@ -49,6 +53,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, eval_status=missing, job_definition_id=missing, @@ -59,13 +67,15 @@ def __init__(self, note=missing, creator=missing, executed_level=missing, - creation_time=missing, - modification_time=missing, elapsed_time=missing, host_ids=missing, file_ids=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.eval_status = eval_status self.job_definition_id = job_definition_id @@ -76,8 +86,6 @@ def __init__(self, self.note = note self.creator = creator self.executed_level = executed_level - self.creation_time = creation_time - self.modification_time = modification_time self.elapsed_time = elapsed_time self.host_ids = host_ids self.file_ids = file_ids diff --git a/ansys/rep/client/jms/resource/job_definition.py b/ansys/rep/client/jms/resource/job_definition.py index d06badd2b..0f1b2e483 100644 --- a/ansys/rep/client/jms/resource/job_definition.py +++ b/ansys/rep/client/jms/resource/job_definition.py @@ -10,15 +10,19 @@ class JobDefinition(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name of the job definition active : bool Defines whether this is the active job definition in the project where evaluators will evaluate pending jobs client_hash : str, optional - creation_time : datetime, optional - The date and time the job definition was created. - modification_time : datetime, optional - The date and time the job definition was last modified. parameter_definition_ids : list[str] parameter_mapping_ids : list[str] task_definition_ids : list[str] @@ -33,22 +37,26 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, active=missing, client_hash=missing, - creation_time=missing, - modification_time=missing, parameter_definition_ids=missing, parameter_mapping_ids=missing, task_definition_ids=missing, fitness_definition=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.active = active self.client_hash = client_hash - self.creation_time = creation_time - self.modification_time = modification_time self.parameter_definition_ids = parameter_definition_ids self.parameter_mapping_ids = parameter_mapping_ids self.task_definition_ids = task_definition_ids diff --git a/ansys/rep/client/jms/resource/parameter_definition.py b/ansys/rep/client/jms/resource/parameter_definition.py index 73a116979..3f06e97e1 100644 --- a/ansys/rep/client/jms/resource/parameter_definition.py +++ b/ansys/rep/client/jms/resource/parameter_definition.py @@ -34,6 +34,14 @@ class FloatParameterDefinition(ParameterDefinition): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name (ID) of the parameter. quantity_name : str, optional @@ -66,6 +74,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, quantity_name=missing, units=missing, @@ -80,6 +92,10 @@ def __init__(self, value_list=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.quantity_name = quantity_name self.units = units @@ -104,6 +120,14 @@ class IntParameterDefinition(ParameterDefinition): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name (ID) of the parameter. quantity_name : str, optional @@ -134,6 +158,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, quantity_name=missing, units=missing, @@ -147,6 +175,10 @@ def __init__(self, cyclic=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.quantity_name = quantity_name self.units = units @@ -170,6 +202,14 @@ class BoolParameterDefinition(ParameterDefinition): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name (ID) of the parameter. quantity_name : str, optional @@ -192,6 +232,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, quantity_name=missing, units=missing, @@ -201,6 +245,10 @@ def __init__(self, default=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.quantity_name = quantity_name self.units = units @@ -220,6 +268,14 @@ class StringParameterDefinition(ParameterDefinition): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name (ID) of the parameter. quantity_name : str, optional @@ -244,6 +300,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, quantity_name=missing, units=missing, @@ -254,6 +314,10 @@ def __init__(self, value_list=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.quantity_name = quantity_name self.units = units diff --git a/ansys/rep/client/jms/resource/parameter_mapping.py b/ansys/rep/client/jms/resource/parameter_mapping.py index b7dcae4d6..eccae7a25 100644 --- a/ansys/rep/client/jms/resource/parameter_mapping.py +++ b/ansys/rep/client/jms/resource/parameter_mapping.py @@ -10,6 +10,14 @@ class ParameterMapping(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. line : int, optional column : int, optional key_string : str, optional @@ -36,6 +44,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, line=missing, column=missing, key_string=missing, @@ -53,6 +65,10 @@ def __init__(self, file_id=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.line = line self.column = column self.key_string = key_string diff --git a/ansys/rep/client/jms/resource/selection.py b/ansys/rep/client/jms/resource/selection.py index dffef14f1..13eb91705 100644 --- a/ansys/rep/client/jms/resource/selection.py +++ b/ansys/rep/client/jms/resource/selection.py @@ -10,12 +10,16 @@ class JobSelection(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. - name : str - Name of the selection. creation_time : datetime, optional - The date and time the selection was created. + The date and time the resource was created. modification_time : datetime, optional - The date and time the selection was last modified. + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. + name : str + Name of the selection. algorithm_id : str, optional ID of the :class:`Algorithm` the selection belongs to (optional). jobs : list[str] @@ -29,16 +33,20 @@ class Meta: def __init__(self, id=missing, - name=missing, creation_time=missing, modification_time=missing, + created_by=missing, + modified_by=missing, + name=missing, algorithm_id=missing, jobs=missing ): self.id = id - self.name = name self.creation_time = creation_time self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by + self.name = name self.algorithm_id = algorithm_id self.jobs = jobs diff --git a/ansys/rep/client/jms/resource/task.py b/ansys/rep/client/jms/resource/task.py index 01ae4ec2a..00f1cff8b 100644 --- a/ansys/rep/client/jms/resource/task.py +++ b/ansys/rep/client/jms/resource/task.py @@ -10,10 +10,14 @@ class Task(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. - modification_time : datetime, optional - The date and time the task was last modified. creation_time : datetime, optional - The date and time the task was created. + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. pending_time : datetime, optional The date and time the task was set to pending. prolog_time : datetime, optional @@ -60,8 +64,10 @@ class Meta: def __init__(self, id=missing, - modification_time=missing, creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, pending_time=missing, prolog_time=missing, running_time=missing, @@ -83,8 +89,10 @@ def __init__(self, custom_data=missing ): self.id = id - self.modification_time = modification_time self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.pending_time = pending_time self.prolog_time = prolog_time self.running_time = running_time diff --git a/ansys/rep/client/jms/resource/task_definition.py b/ansys/rep/client/jms/resource/task_definition.py index 329f13eac..a475ef323 100644 --- a/ansys/rep/client/jms/resource/task_definition.py +++ b/ansys/rep/client/jms/resource/task_definition.py @@ -144,6 +144,14 @@ class TaskDefinition(Object): ---------- id : str, optional Unique ID to access the resource, generated internally by the server on creation. + creation_time : datetime, optional + The date and time the resource was created. + modification_time : datetime, optional + The date and time the resource was last modified. + created_by : str, optional + ID of the user who created the object. + modified_by : str, optional + ID of the user who last modified the object. name : str, optional Name. execution_command : str, optional @@ -184,6 +192,10 @@ class Meta: def __init__(self, id=missing, + creation_time=missing, + modification_time=missing, + created_by=missing, + modified_by=missing, name=missing, execution_command=missing, use_execution_script=missing, @@ -202,6 +214,10 @@ def __init__(self, resource_requirements=missing ): self.id = id + self.creation_time = creation_time + self.modification_time = modification_time + self.created_by = created_by + self.modified_by = modified_by self.name = name self.execution_command = execution_command self.use_execution_script = use_execution_script diff --git a/ansys/rep/client/jms/schema/algorithm.py b/ansys/rep/client/jms/schema/algorithm.py index 9fc95a6ca..726a996e1 100644 --- a/ansys/rep/client/jms/schema/algorithm.py +++ b/ansys/rep/client/jms/schema/algorithm.py @@ -8,27 +8,18 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReferenceList -class AlgorithmSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class AlgorithmSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(allow_none=True, description="Name of the algorithm.") description = fields.String(allow_none=True, description="Description of the algorithm.") - creation_time = fields.DateTime( - allow_none=True, load_only=True, description="The date and time the algorithm was created." - ) - modification_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the algorithm was last modified.", - ) - data = fields.String( allow_none=True, description="Generic string field to hold arbitrary algorithm configuration data," diff --git a/ansys/rep/client/jms/schema/file.py b/ansys/rep/client/jms/schema/file.py index 92660abf6..d1fce207b 100644 --- a/ansys/rep/client/jms/schema/file.py +++ b/ansys/rep/client/jms/schema/file.py @@ -8,13 +8,13 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReference -class FileSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class FileSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(description="Name of the file resource.") @@ -30,16 +30,6 @@ class Meta(ObjectSchema.Meta): size = fields.Int(allow_none=True) hash = fields.String(allow_none=True) - creation_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the file resource was created.", - ) - modification_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the file resource was last modified.", - ) expiry_time = fields.DateTime( allow_none=True, metadata={"description": "File expiration time."}, diff --git a/ansys/rep/client/jms/schema/job.py b/ansys/rep/client/jms/schema/job.py index fa5f280a7..49f8575b1 100644 --- a/ansys/rep/client/jms/schema/job.py +++ b/ansys/rep/client/jms/schema/job.py @@ -9,7 +9,7 @@ from marshmallow import fields from marshmallow.validate import OneOf -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReference, IdReferenceList @@ -25,8 +25,8 @@ ] -class JobSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class JobSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(allow_none=True, description="Name of the job.") @@ -69,16 +69,6 @@ class Meta(ObjectSchema.Meta): "task (-1 if none has been executed yet).", ) - creation_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the job was created.", - ) - modification_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the job was last modified.", - ) elapsed_time = fields.Float( load_only=True, description="Number of seconds it took the evaluator(s) to update the job.", diff --git a/ansys/rep/client/jms/schema/job_definition.py b/ansys/rep/client/jms/schema/job_definition.py index a8b087600..919eb474d 100644 --- a/ansys/rep/client/jms/schema/job_definition.py +++ b/ansys/rep/client/jms/schema/job_definition.py @@ -9,7 +9,7 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .fitness_definition import FitnessDefinitionSchema from .object_reference import IdReferenceList @@ -17,8 +17,8 @@ log = logging.getLogger(__name__) -class JobDefinitionSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class JobDefinitionSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(allow_none=True, description="Name of the job definition") @@ -27,16 +27,6 @@ class Meta(ObjectSchema.Meta): "project where evaluators will evaluate pending jobs" ) client_hash = fields.String(allow_none=True) - creation_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the job definition was created.", - ) - modification_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the job definition was last modified.", - ) parameter_definition_ids = IdReferenceList( referenced_class="ParameterDefinition", attribute="parameter_definition_ids", description="" diff --git a/ansys/rep/client/jms/schema/parameter_definition.py b/ansys/rep/client/jms/schema/parameter_definition.py index 8225a7365..989ec71fb 100644 --- a/ansys/rep/client/jms/schema/parameter_definition.py +++ b/ansys/rep/client/jms/schema/parameter_definition.py @@ -10,13 +10,13 @@ from marshmallow import fields from marshmallow_oneofschema import OneOfSchema -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo log = logging.getLogger(__name__) -class ParameterDefinitionBaseSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class ParameterDefinitionBaseSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(allow_none=True, description="Name (ID) of the parameter.") diff --git a/ansys/rep/client/jms/schema/parameter_mapping.py b/ansys/rep/client/jms/schema/parameter_mapping.py index 9f3161b10..db0ecbbbd 100644 --- a/ansys/rep/client/jms/schema/parameter_mapping.py +++ b/ansys/rep/client/jms/schema/parameter_mapping.py @@ -9,15 +9,15 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReference log = logging.getLogger(__name__) -class ParameterMappingSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class ParameterMappingSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass line = fields.Int(allow_none=True) diff --git a/ansys/rep/client/jms/schema/selection.py b/ansys/rep/client/jms/schema/selection.py index 46e7873b3..054170f4d 100644 --- a/ansys/rep/client/jms/schema/selection.py +++ b/ansys/rep/client/jms/schema/selection.py @@ -8,26 +8,17 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReference, IdReferenceList -class JobSelectionSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class JobSelectionSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(description="Name of the selection.") - creation_time = fields.DateTime( - allow_none=True, load_only=True, description="The date and time the selection was created." - ) - modification_time = fields.DateTime( - allow_none=True, - load_only=True, - description="The date and time the selection was last modified.", - ) - algorithm_id = IdReference( allow_none=True, attribute="algorithm_id", diff --git a/ansys/rep/client/jms/schema/task.py b/ansys/rep/client/jms/schema/task.py index 5dee59b01..c9d324c8a 100644 --- a/ansys/rep/client/jms/schema/task.py +++ b/ansys/rep/client/jms/schema/task.py @@ -8,22 +8,16 @@ from marshmallow import fields -from ansys.rep.client.common import ObjectSchema +from ansys.rep.client.common import ObjectSchemaWithModificationInfo from .object_reference import IdReference, IdReferenceList from .task_definition import TaskDefinitionSchema -class TaskSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class TaskSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass - modification_time = fields.DateTime( - allow_none=True, load_only=True, description="The date and time the task was last modified." - ) - creation_time = fields.DateTime( - allow_none=True, load_only=True, description="The date and time the task was created." - ) pending_time = fields.DateTime( allow_none=True, load_only=True, diff --git a/ansys/rep/client/jms/schema/task_definition.py b/ansys/rep/client/jms/schema/task_definition.py index f54ef1f07..48de5af6e 100644 --- a/ansys/rep/client/jms/schema/task_definition.py +++ b/ansys/rep/client/jms/schema/task_definition.py @@ -8,7 +8,7 @@ from marshmallow import fields -from ansys.rep.client.common import BaseSchema, ObjectSchema, RestrictedValue +from ansys.rep.client.common import BaseSchema, ObjectSchemaWithModificationInfo, RestrictedValue from .object_reference import IdReference, IdReferenceList @@ -77,8 +77,8 @@ class Meta(BaseSchema.Meta): ) -class TaskDefinitionSchema(ObjectSchema): - class Meta(ObjectSchema.Meta): +class TaskDefinitionSchema(ObjectSchemaWithModificationInfo): + class Meta(ObjectSchemaWithModificationInfo.Meta): pass name = fields.String(allow_none=True, description="Name.") diff --git a/tests/jms/test_algorithms.py b/tests/jms/test_algorithms.py index f31870104..2124b8b41 100644 --- a/tests/jms/test_algorithms.py +++ b/tests/jms/test_algorithms.py @@ -51,6 +51,11 @@ def test_algorithms(self): for sel in sels: self.assertEqual(len(sel.jobs), 5) self.assertEqual(sel.algorithm_id, None) + self.assertTrue(sel.created_by is not missing) + self.assertTrue(sel.creation_time is not missing) + self.assertTrue(sel.modified_by is not missing) + self.assertTrue(sel.modification_time is not missing) + self.assertEqual(sel.created_by, sel.modified_by) # Create an algorithm algo = Algorithm(name="new_algo") @@ -62,6 +67,11 @@ def test_algorithms(self): self.assertEqual(len(algo.jobs), 0) self.assertEqual(algo.data, None) self.assertEqual(algo.description, None) + self.assertTrue(algo.created_by is not missing) + self.assertTrue(algo.creation_time is not missing) + self.assertTrue(algo.modified_by is not missing) + self.assertTrue(algo.modification_time is not missing) + self.assertEqual(algo.created_by, algo.modified_by) # Link jobs to algorithm algo.jobs = [j.id for j in jobs] diff --git a/tests/jms/test_files.py b/tests/jms/test_files.py index 340a13448..9284e1121 100644 --- a/tests/jms/test_files.py +++ b/tests/jms/test_files.py @@ -51,6 +51,12 @@ def test_files(self): files.append(File(name="img", evaluation_path="file000.jpg", type="image/jpeg", hash=None)) files.append(File(name="out", evaluation_path="file.out", type="text/plain", hash=None)) files_created = project_api.create_files(files) + for file in files_created: + self.assertTrue(file.created_by is not missing) + self.assertTrue(file.creation_time is not missing) + self.assertTrue(file.modified_by is not missing) + self.assertTrue(file.modification_time is not missing) + self.assertEqual(file.created_by, file.modified_by) # Get files files_queried = project_api.get_files(content=True) diff --git a/tests/jms/test_job_definitions.py b/tests/jms/test_job_definitions.py index dc2ab6b63..bf9eefe38 100644 --- a/tests/jms/test_job_definitions.py +++ b/tests/jms/test_job_definitions.py @@ -1,8 +1,9 @@ import logging from examples.mapdl_motorbike_frame.project_setup import create_project +from marshmallow.utils import missing -from ansys.rep.client.jms import JmsApi, ProjectApi +from ansys.rep.client import AuthApi, JmsApi, ProjectApi from ansys.rep.client.jms.resource import ( JobDefinition, Project, @@ -48,6 +49,7 @@ def test_task_definition_fields(self): project = Project(name=proj_name, active=False, priority=10) project = jms_api.create_project(project) project_api = ProjectApi(client, project.id) + auth_api = AuthApi(self.client) task_def = TaskDefinition( name="Task.1", @@ -63,6 +65,10 @@ def test_task_definition_fields(self): self.assertEqual(task_def.store_output, True) self.assertEqual(task_def.resource_requirements.memory, 274877906944) self.assertEqual(task_def.resource_requirements.disk_space, 2199023255552) + self.assertTrue(task_def.modified_by is not missing) + self.assertTrue(task_def.created_by is not missing) + self.assertTrue(auth_api.get_user(id=task_def.created_by).username == self.username) + self.assertTrue(auth_api.get_user(id=task_def.modified_by).username == self.username) jms_api.delete_project(project) diff --git a/tests/jms/test_jobs.py b/tests/jms/test_jobs.py index ba591aac8..1c45616e4 100644 --- a/tests/jms/test_jobs.py +++ b/tests/jms/test_jobs.py @@ -13,7 +13,7 @@ from examples.mapdl_motorbike_frame.project_setup import create_project from marshmallow.utils import missing -from ansys.rep.client.jms import JmsApi, ProjectApi +from ansys.rep.client import AuthApi, JmsApi, ProjectApi from ansys.rep.client.jms.resource import Job, JobDefinition, Project from ansys.rep.client.jms.schema.job import JobSchema from tests.rep_test import REPTestCase @@ -105,13 +105,14 @@ def test_job_serialization(self): job_definition_id=2, host_ids=["uuid-4", "uuid-5"], values={"p1": "string_value", "p2": 8.9, "p3": True}, - creator="dcs-client", + creator="rep-client", elapsed_time=40.8, ) self.assertEqual(job.note, missing) self.assertEqual(job.priority, missing) self.assertEqual(job.elapsed_time, 40.8) + self.assertEqual(job.creator, "rep-client") schema = JobSchema() serialized_job = schema.dump(job) @@ -128,7 +129,7 @@ def test_job_serialization(self): def test_job_integration(self): client = self.client - proj_name = f"dcs_client_test_jobs_JobTest_{self.run_id}" + proj_name = f"test_jobs_JobTest_{self.run_id}" proj = Project(name=proj_name, active=True) jms_api = JmsApi(client) @@ -138,6 +139,9 @@ def test_job_integration(self): job_def = JobDefinition(name="New Config", active=True) job_def = project_api.create_job_definitions([job_def])[0] + self.assertTrue(job_def.modified_by is not missing) + self.assertTrue(job_def.created_by is not missing) + # test creating, update and delete with no jobs jobs = project_api.create_jobs([]) self.assertEqual(len(jobs), 0) @@ -160,14 +164,21 @@ def test_job_integration(self): self.assertEqual(job.note, None) self.assertEqual(job.fitness, None) self.assertTrue(job.executed_level is not None) + self.assertTrue(job.modified_by is not missing) + self.assertTrue(job.created_by is not missing) jobs = project_api.get_jobs() + auth_api = AuthApi(self.client) for job in jobs: # check that all fields are populated (i.e. request params include fields="all") self.assertEqual(job.creator, None) self.assertEqual(job.note, None) self.assertEqual(job.fitness, None) self.assertTrue(job.executed_level is not None) + self.assertTrue(job.modified_by is not missing) + self.assertTrue(job.created_by is not missing) + self.assertTrue(auth_api.get_user(id=job.created_by).username == self.username) + self.assertTrue(auth_api.get_user(id=job.modified_by).username == self.username) # fill some of them job.creator = "rep-client" job.note = f"test job{job.id} update" diff --git a/tests/jms/test_parameter_definitions.py b/tests/jms/test_parameter_definitions.py index 130b777c6..dd33af528 100644 --- a/tests/jms/test_parameter_definitions.py +++ b/tests/jms/test_parameter_definitions.py @@ -178,6 +178,13 @@ def test_parameter_definition_integration(self): ip = project_api.create_parameter_definitions([ip])[0] sp = project_api.create_parameter_definitions([sp])[0] + for pd in [ip, sp]: + self.assertTrue(pd.created_by is not missing) + self.assertTrue(pd.creation_time is not missing) + self.assertTrue(pd.modified_by is not missing) + self.assertTrue(pd.modification_time is not missing) + self.assertEqual(pd.created_by, pd.modified_by) + job_def = JobDefinition(name="New Config", active=True) job_def.parameter_definition_ids = [ip.id, sp.id] job_def = project_api.create_job_definitions([job_def])[0] diff --git a/tests/jms/test_tasks.py b/tests/jms/test_tasks.py index 79d5bcaf1..86877cc17 100644 --- a/tests/jms/test_tasks.py +++ b/tests/jms/test_tasks.py @@ -12,6 +12,7 @@ import uuid from examples.mapdl_motorbike_frame.project_setup import create_project +from marshmallow.utils import missing import pytest from ansys.rep.client.jms import JmsApi, ProjectApi @@ -110,6 +111,8 @@ def test_task_integration(self): for job in jobs: tasks = project_api.get_tasks(job_id=job.id) self.assertEqual(tasks[0].job_id, job.id) + self.assertTrue(tasks[0].created_by is not missing) + self.assertTrue(tasks[0].modified_by is not missing) def test_job_sync(self):