Commit 8857a5a8 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added a basic info endpoints that provides parser, normalizer, domain information.

parent 0bb29458
......@@ -29,7 +29,7 @@ There is a separate documentation for the API endpoints from a client perspectiv
.. automodule:: nomad.api.admin
from .app import app
from . import auth, admin, upload, repo, archive, raw
from . import info, auth, admin, upload, repo, archive, raw
# Copyright 2018 Markus Scheidgen
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an"AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
API endpoint that deliver backend configuration details.
from flask_restplus import Resource, fields
from nomad import parsing, normalizing, datamodel
from .app import api
ns = api.namespace('info', description='Access to nomad configuration details.')
domain_quantity_model = api.model('DomainQuantity', {
'name': fields.String,
'description': fields.String,
'multi': fields.Boolean,
'order_default': fields.Boolean
domain_model = api.model('Domain', {
'name': fields.String,
'quantities': fields.List(fields.Nested(model=domain_quantity_model)),
'aggregations_names': fields.List(fields.String),
'metrics_names': fields.List(fields.String)
info_model = api.model('Info', {
'parsers': fields.List(fields.String),
'normalizers': fields.List(fields.String),
'domain': fields.Nested(model=domain_model)
class InfoResource(Resource):
@api.marshal_with(info_model, skip_none=True, code=200, description='Info send')
def get(self):
""" Return information about the nomad backend and its configuration. """
return {
'parsers': [key for key in parsing.parser_dict.keys()],
'normalizers': [normalizer.__name__ for normalizer in normalizing.normalizers],
'domain': datamodel.Domain.instance
}, 200
......@@ -259,7 +259,7 @@ class Domain:
def metrics_names(self) -> Iterable[str]:
""" Just the names of all metrics. """
return self.metrics.keys()
return list(self.metrics.keys())
def aggregations(self) -> Dict[str, int]:
......@@ -272,3 +272,8 @@ class Domain:
for quantity in self.quantities
if quantity.aggregations > 0
def aggregations_names(self) -> Iterable[str]:
""" Just the names of all metrics. """
return list(self.aggregations.keys())
......@@ -31,14 +31,14 @@ There is one ABC for all normalizer:
from typing import List, Any
from typing import List, Any, Iterable, Type
from .normalizer import Normalizer
from .system import SystemNormalizer
from .fhiaims import FhiAimsBaseNormalizer
normalizers: List[Any] = [
normalizers: Iterable[Type[Normalizer]] = [
......@@ -54,8 +54,13 @@ def get_upload_with_metadata(upload: dict) -> UploadWithMetadata:
for calc in upload['calcs']['results']])
class TestAdmin:
class TestInfo:
def test_info(self, client):
rv = client.get('/info/')
assert rv.status_code == 200
class TestAdmin:
def test_reset(self, client, admin_user_auth, expandable_postgres, monkeypatch):
monkeypatch.setattr('', False)
Supports Markdown
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