Commit 3a21531a authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Merge branch 'v0.8.4' into encyclopedia-api

parents 9d74877c 36e681e3
Pipeline #79335 passed with stages
in 30 minutes and 2 seconds
......@@ -22,6 +22,7 @@ from typing import cast, Dict, List, Union, Any, Set, Iterable, Tuple
import numpy as np
from pint.errors import UndefinedUnitError
import os.path
import importlib
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl, InfoKindEnv
......@@ -105,6 +106,22 @@ class LegacyMetainfoEnvironment(Environment):
the environment.
'''
@staticmethod
def from_legacy_package_path(path):
metainfo_package_name = os.path.basename(path)
package = metainfo_package_name
if package.endswith('.nomadmetainfo.json'):
package = package[:-19]
if package.endswith('.json'):
package = package[:-5]
python_package_name, _ = python_package_mapping(package)
python_package_name = '.'.join(python_package_name.split('.')[:-1])
python_module = importlib.import_module(python_package_name)
metainfo = getattr(python_module, 'm_env')
return metainfo
legacy_package_name = Quantity(type=str)
def __init__(self, *args, **kwargs):
......
......@@ -31,7 +31,7 @@ import pytz
import docstring_parser
import jmespath
from nomad.units import ureg
from nomad.units import ureg as units
m_package: 'Package' = None
......@@ -133,7 +133,7 @@ class SectionProxy(MProxy):
def m_proxy_resolve(self):
if self.m_proxy_section and not self.m_proxy_resolved:
root = self.m_proxy_section
while root is not None and not isinstance(root, Package):
while root.m_parent is not None and not isinstance(root, Package):
root = root.m_parent
if isinstance(root, Package):
......@@ -221,7 +221,7 @@ class _Dimension(DataType):
class _Unit(DataType):
def set_normalize(self, section, quantity_def: 'Quantity', value):
if isinstance(value, str):
value = ureg.parse_units(value)
value = units.parse_units(value)
elif not isinstance(value, pint.unit._Unit):
raise TypeError('Units must be given as str or pint Unit instances.')
......@@ -232,7 +232,7 @@ class _Unit(DataType):
return value.__str__()
def deserialize(self, section, quantity_def: 'Quantity', value):
return ureg.parse_units(value)
return units.parse_units(value)
class _Callable(DataType):
......@@ -344,7 +344,7 @@ class Reference(DataType):
def set_normalize(self, section: 'MSection', quantity_def: 'Quantity', value: Any) -> Any:
if isinstance(self.target_section_def, MProxy):
proxy = self.target_section_def
proxy.m_proxy_section = section
proxy.m_proxy_section = section.m_def
proxy.m_proxy_quantity = quantity_def
self.target_section_def = proxy.m_proxy_resolve()
......
......@@ -34,6 +34,7 @@ class Normalizer(metaclass=ABCMeta):
def __init__(self, backend: Backend) -> None:
self._backend = backend
self.entry_archive = backend.entry_archive
try:
self.section_run = backend.entry_archive.section_run[0]
except (AttributeError, IndexError):
......
......@@ -1076,7 +1076,7 @@ class Upload(Proc):
'',
'your data %suploaded at %s has completed processing.' % (
'"%s" ' % self.name if self.name else '', self.upload_time.isoformat()), # pylint: disable=no-member
'You can review your data on your upload page: %s' % config.gui_url(),
'You can review your data on your upload page: %s' % config.gui_url(page='uploads'),
'',
'If you encounter any issues with your upload, please let us know and reply to this email.',
'',
......
......@@ -23,7 +23,7 @@ from elasticsearch.exceptions import NotFoundError
from datetime import datetime
import json
from nomad import config, datamodel, infrastructure, datamodel, utils
from nomad import config, datamodel, infrastructure, utils
from nomad.metainfo.search_extension import search_quantities, metrics, order_default_quantities
......
......@@ -11,6 +11,10 @@ data:
nomad.yaml: |
meta:
release: "{{ .Release.Name }}"
service: "{{ .Values.meta.service }}"
homepage: "{{ .Values.meta.homepage }}"
source_url: "{{ .Values.meta.source_url }}"
maintainer_email: "{{ .Values.meta.maintainer_email }}"
reprocess_unmatched: {{ .Values.reprocess_unmatched }}
fs:
tmp: "{{ .Values.volumes.tmp }}"
......
......@@ -5,6 +5,12 @@ version:
usesBetaData: false
officialUrl: "https://nomad-lab.eu/prod/rae/gui"
meta:
service: "app"
homepage: "https://nomad-lab.eu"
source_url: "https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR"
maintainer_email: "markus.scheidgen@physik.hu-berlin.de"
## Everything concerning the container images to be used
image:
## The kubernetes docker-registry secret that can be used to access the registry
......
......@@ -20,7 +20,7 @@ import datetime
from nomad.metainfo.metainfo import (
MSection, MCategory, Section, Quantity, SubSection, Definition, Package, DeriveError,
MetainfoError, Environment, MResource, Datetime, Annotation, SectionAnnotation,
DefinitionAnnotation, Reference, MProxy, derived)
DefinitionAnnotation, Reference, MProxy, derived, SectionProxy)
from nomad.metainfo.example import Run, VaspRun, System, SystemHash, Parsing, SCC, m_package as example_package
from nomad import utils
from nomad.units import ureg
......@@ -585,6 +585,24 @@ class TestM1:
obj = ReferencingSection.m_from_dict(obj.m_to_dict(with_meta=True))
assert obj.proxy.name == 'test_value'
def test_ref_with_section_proxy(self):
package = Package(name='test_package')
class OtherSection(MSection):
name = Quantity(type=str)
class ReferencingSection(MSection):
reference = Quantity(type=Reference(SectionProxy('OtherSection')))
package.m_add_sub_section(Package.section_definitions, OtherSection.m_def)
package.m_add_sub_section(Package.section_definitions, ReferencingSection.m_def)
referencing = ReferencingSection()
reference = OtherSection()
referencing.reference = reference
assert referencing.reference == reference
def test_copy(self):
run = Run()
run.m_create(Parsing).parser_name = 'test'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment