diff --git a/nomad/app/v1/routers/entries.py b/nomad/app/v1/routers/entries.py index e0fe16e64f2172d4669a7f131db536d0a9ea257b..d7c3c7bb864bdd1053e1d7e32ea92f16270a9fa1 100644 --- a/nomad/app/v1/routers/entries.py +++ b/nomad/app/v1/routers/entries.py @@ -1312,7 +1312,7 @@ async def post_entry_metadata_edit( return data # perform the change - mongo_update['metadata__last_edit_time'] = datetime.utcnow() + mongo_update['last_edit_time'] = datetime.utcnow() edit(data.query, user, mongo_update, True) # remove potentially empty old datasets diff --git a/nomad/datamodel/datamodel.py b/nomad/datamodel/datamodel.py index 940ff4279917a409eb4cc296d42993a22de0267c..ccf133d4361cd9918f9d96f5f9da7e59c81d9052 100644 --- a/nomad/datamodel/datamodel.py +++ b/nomad/datamodel/datamodel.py @@ -367,6 +367,9 @@ class EntryMetadata(metainfo.MSection): calc_id: The unique mainfile based calculation id. calc_hash: The raw file content based checksum/hash of this calculation. pid: The unique persistent id of this calculation. + external_db: The repository or external database where the original data resides. + external_id: A user provided external id. Usually the id for an entry in an external + database where the data was imported from. mainfile: The upload relative mainfile path. files: A list of all files, relative to upload. @@ -376,6 +379,7 @@ class EntryMetadata(metainfo.MSection): last_edit_time: The date and time the user metadata was last edited. nomad_version: A string that describes the version of the nomad software that was used to do the last successful processing. + nomad_commit: The NOMAD commit used for the last processing. comment: An arbitrary string with user provided information about the entry. references: A list of URLs for resources that are related to the entry. uploader: Id of the uploader of this entry. @@ -493,7 +497,7 @@ class EntryMetadata(metainfo.MSection): a_elasticsearch=Elasticsearch()) external_db = metainfo.Quantity( - type=metainfo.MEnum('EELSDB', 'Materials Project', 'AFLOW', 'OQMD'), categories=[MongoMetadata, UserProvidableMetadata], + type=metainfo.MEnum('EELSDB', 'Materials Project', 'AFLOW', 'OQMD'), categories=[MongoEntryMetadata, UserProvidableMetadata], description='The repository or external database where the original data resides', a_elasticsearch=Elasticsearch(material_entry_type)) @@ -582,7 +586,7 @@ class EntryMetadata(metainfo.MSection): a_elasticsearch=Elasticsearch()) last_edit_time = metainfo.Quantity( - type=metainfo.Datetime, categories=[MongoMetadata, OasisMetadata], + type=metainfo.Datetime, categories=[MongoEntryMetadata, OasisMetadata], description='The date and time the user metadata was last edited.') optimade = metainfo.SubSection( diff --git a/nomad/processing/data.py b/nomad/processing/data.py index c5b2aaf67a50bbab1ce7810ad3ad4cd83b7b6aa2..c9a38477dd86cf61b6437604e96ffe6ec4762a81 100644 --- a/nomad/processing/data.py +++ b/nomad/processing/data.py @@ -161,11 +161,13 @@ class Calc(Proc): calc_hash: the hash of the entry files entry_create_time: the date and time of the creation of the entry last_processing_time: the date and time of the last processing. + last_edit_time: the date and time the user metadata was last edited mainfile: the mainfile (including path in upload) that was used to create this calc parser_name: the name of the parser used to process this calc pid: the legacy NOMAD pid of the entry external_id: A user provided external id. Usually the id for an entry in an external database where the data was imported from. + external_db: the repository or external database where the original data resides nomad_version: The NOMAD version used for the last processing nomad_commit: The NOMAD commit used for the last processing @@ -176,10 +178,12 @@ class Calc(Proc): calc_hash = StringField() entry_create_time = DateTimeField(required=True) last_processing_time = DateTimeField() + last_edit_time = DateTimeField() mainfile = StringField() parser_name = StringField() pid = StringField() external_id = StringField() + external_db = StringField() nomad_version = StringField() nomad_commit = StringField() @@ -1540,7 +1544,7 @@ class Upload(Proc): ''' All successfully processed and outdated calculations. ''' return Calc.objects( upload_id=self.upload_id, process_status=ProcessStatus.SUCCESS, - metadata__nomad_version__ne=config.meta.version) + nomad_version__ne=config.meta.version) @property def calcs(self) -> Iterable[Calc]: diff --git a/tests/app/v1/routers/test_entries_edit.py b/tests/app/v1/routers/test_entries_edit.py index 03fb9764bcc5ee24de5ff37e4755dce68820f81a..37b921c67cebac7d77ee886f1ff0e7f393aa7b9d 100644 --- a/tests/app/v1/routers/test_entries_edit.py +++ b/tests/app/v1/routers/test_entries_edit.py @@ -109,9 +109,9 @@ class TestEditRepo(): for calc_id in args: calc = proc.Calc.objects(calc_id='test_entry_id_%d' % calc_id).first() assert calc is not None - metadata = calc.metadata if edited: - assert metadata.get('last_edit_time') is not None + assert calc.last_edit_time is not None + metadata = calc.mongo_metadata(calc.upload).m_to_dict() for key, value in kwargs.items(): if metadata.get(key) != value: return False