Commit e6eceab7 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Minor optimade fixed. Refactored api->app.

parent 6a83a6ee
......@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import Markdown from './Markdown'
import { kibanaBase, apiBase, debug } from '../config'
import { kibanaBase, appBase, optimadeBase, apiBase, debug } from '../config'
import { compose } from 'recompose'
import { withApi } from './api'
import { withDomain } from './domains'
......@@ -39,18 +39,25 @@ class About extends React.Component {
system](https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR/issues).
### Developer Documentation
You find in depth developer documentation [here](${apiBase}/docs/index.html).
It contains a general introduction to NOMAD, the underlying architecture,
The [in-depth developer documentation](${appBase}/docs/index.html)
contains a general introduction to NOMAD, the underlying architecture,
is (meta)data, and processing. You will also find some information on how to use
the NOMAD ReST API. It contains information about how to develop NOMAD, how to
operate it, how to contribute parser, and much more.
operate it, how to contribute parsers, and much more.
### ReST API
NOMAD services can also be accessed programmatically via NOMAD's
ReST API. The API is described via [swagger](https://swagger.io/), therefore
you can use your favorite swagger client library (e.g.
[bravado](https://github.com/Yelp/bravado) for Python).
Here is [our API's swagger UI](${apiBase}/) as reference documentation.
### ReST APIs
NOMAD services can also be accessed programmatically via ReST APIs.
There is the proprietary NOMAD API and an implementation of the
[OPTiMaDe API (0.10.0)](https://github.com/Materials-Consortia/OPTiMaDe/tree/master)
standardized by the [OPTiMaDe consortium](https://www.optimade.org/)
Both APIs are described via [swagger](https://swagger.io/) (also known as OpenAPI spec.),
therefore you can use your favorite swagger client library
(e.g. [bravado](https://github.com/Yelp/bravado) for Python).
There are also web-based GUIs that allow to explore the APIs and their documentation:
- [NOMAD API](${apiBase}/)
- [OPTiMaDe API](${optimadeBase}/)
### Source code
The source-code for this new version of NOMAD (dubbed *nomad@FAIRDI*) is maintained
......
......@@ -21,7 +21,7 @@ import { ErrorSnacks, withErrors } from './errors'
import EntryPage from './entry/EntryPage'
import About from './About'
import LoginLogout from './LoginLogout'
import { genTheme, repoTheme, archiveTheme, appBase } from '../config'
import { genTheme, repoTheme, archiveTheme, guiBase } from '../config'
import { DomainProvider, withDomain } from './domains'
import {help as metainfoHelp, default as MetaInfoBrowser} from './metaInfoBrowser/MetaInfoBrowser'
import packageJson from '../../package.json'
......@@ -41,8 +41,6 @@ export class VersionMismatch extends Error {
const drawerWidth = 200
class NavigationUnstyled extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
......@@ -185,7 +183,7 @@ class NavigationUnstyled extends React.Component {
}
componentDidMount() {
fetch(`${appBase}/meta.json`)
fetch(`${guiBase}/meta.json`)
.then((response) => response.json())
.then((meta) => {
if (meta.version !== packageJson.version) {
......
......@@ -5,7 +5,7 @@ import { FormControl, FormControlLabel, Checkbox, FormGroup, FormLabel, Tooltip
import { compose } from 'recompose'
import { withErrors } from '../errors'
import { withApi, DisableOnLoading } from '../api'
import { appBase } from '../../config'
import { guiBase } from '../../config'
import Search from './Search'
import qs from 'qs'
......@@ -44,7 +44,7 @@ The results table gives you a quick overview of all entries that fit your search
You can click entries to see more details, download data, see the archive, etc.
The *raw files* tab, will show you all files that belong to the entry and offers a download
on individual, or all files. The *archive* tab, shows you the parsed data as a tree
data structure. This view is connected to NOMAD's [meta-info](${appBase}/metainfo), which acts a schema for
data structure. This view is connected to NOMAD's [meta-info](${guiBase}/metainfo), which acts a schema for
all parsed data. The *log* tab, will show you a log of the entry's processing.
`
......
......@@ -6,8 +6,10 @@ import secondary from '@material-ui/core/colors/blueGrey'
import { createMuiTheme } from '@material-ui/core'
window.nomadEnv = window.nomadEnv || {}
export const apiBase = window.nomadEnv.apiBase
export const appBase = process.env.PUBLIC_URL
export const appBase = window.nomadEnv.apiBase.replace(/\/$/, '')
export const apiBase = `${appBase}/api`
export const optimadeBase = `${appBase}/optimade`
export const guiBase = process.env.PUBLIC_URL
export const kibanaBase = window.nomadEnv.kibanaBase
export const matomoUrl = window.nomadEnv.matomoUrl
export const matomoSiteId = window.nomadEnv.matomoSiteId
......
......@@ -40,7 +40,7 @@ def url(endpoint: str = None, **kwargs):
api = Api(
blueprint,
version='1.0', title='NOMAD optimade PI',
description='The NOMAD optimade API',
version='1.0', title='NOMAD\'s OPTiMaDe API implementation',
description='NOMAD\'s OPTiMaDe API implementation, version 0.10.0.',
validate=True)
""" Provides the flask restplust api instance for the optimade api"""
......@@ -34,8 +34,9 @@ def base_request_args():
return properties_str.split(',')
return None
ns = api.namespace('optimade', description='The (only) API namespace with all OPTiMaDe endpoints.')
@api.route('/calculations')
@ns.route('/calculations')
class CalculationList(Resource):
@api.doc('list_calculations')
@api.response(400, 'Invalid requests, e.g. bad parameter.')
......@@ -84,7 +85,7 @@ class CalculationList(Resource):
), 200
@api.route('/calculations/<string:id>')
@ns.route('/calculations/<string:id>')
class Calculation(Resource):
@api.doc('retrieve_calculation')
@api.response(400, 'Invalid requests, e.g. bad parameter.')
......@@ -110,7 +111,7 @@ class Calculation(Resource):
), 200
@api.route('/info/calculation')
@ns.route('/info/calculation')
class CalculationInfo(Resource):
@api.doc('calculations_info')
@api.response(400, 'Invalid requests, e.g. bad parameter.')
......@@ -143,7 +144,7 @@ class CalculationInfo(Resource):
), 200
@api.route('/info')
@ns.route('/info')
class Info(Resource):
@api.doc('info')
@api.response(400, 'Invalid requests, e.g. bad parameter.')
......
......@@ -30,16 +30,16 @@ def worker():
run_worker()
@run.command(help='Run the nomad development api.')
@run.command(help='Run the nomad development app with all apis.')
@click.option('--debug', help='Does run flask in debug.', is_flag=True)
@click.option('--with-chaos', type=int, default=0, help='Enable a certain percentage of chaos.')
def api(debug: bool, with_chaos: int):
def app(debug: bool, with_chaos: int):
config.services.api_chaos = with_chaos
run_api(debug=debug)
run_app(debug=debug)
def run_api(**kwargs):
config.service = 'api'
def run_app(**kwargs):
config.service = 'app'
from nomad import infrastructure
from nomad.app.__main__ import run_dev_server
infrastructure.setup()
......@@ -52,9 +52,9 @@ def run_worker():
processing.app.worker_main(['worker', '--loglevel=INFO', '-Q', 'celery,uploads,calcs'])
@run.command(help='Run both api and worker.')
@run.command(help='Run both app and worker.')
def apiworker():
executor = ProcessPoolExecutor(2)
loop = asyncio.get_event_loop()
loop.run_in_executor(executor, run_api)
loop.run_in_executor(executor, run_app)
loop.run_in_executor(executor, run_worker)
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "nomad.fullname" . }}-api-gunicorn-log-config
name: {{ include "nomad.fullname" . }}-app-gunicorn-log-config
labels:
app.kubernetes.io/name: {{ include "nomad.name" . }}-api-gunicorn-log-config
app.kubernetes.io/name: {{ include "nomad.name" . }}-app-gunicorn-log-config
helm.sh/chart: {{ include "nomad.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
......@@ -55,43 +55,43 @@ data:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "nomad.fullname" . }}-api-gunicorn-config
name: {{ include "nomad.fullname" . }}-app-gunicorn-config
labels:
app.kubernetes.io/name: {{ include "nomad.name" . }}-api-gunicorn-config
app.kubernetes.io/name: {{ include "nomad.name" . }}-app-gunicorn-config
helm.sh/chart: {{ include "nomad.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
gunicorn.conf: |
secure_scheme_headers = {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
worker_class = '{{ .Values.api.workerClass }}'
threads = {{ .Values.api.threads }}
worker_class = '{{ .Values.app.workerClass }}'
threads = {{ .Values.app.threads }}
worker_connections = 1000
worker = {{ .Values.api.worker }}
worker = {{ .Values.app.worker }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nomad.fullname" . }}-api
name: {{ include "nomad.fullname" . }}-app
labels:
app.kubernetes.io/name: {{ include "nomad.name" . }}-api
app.kubernetes.io/name: {{ include "nomad.name" . }}-app
helm.sh/chart: {{ include "nomad.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.api.replicas }}
replicas: {{ .Values.app.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nomad.name" . }}-api
app.kubernetes.io/name: {{ include "nomad.name" . }}-app
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "nomad.name" . }}-api
app.kubernetes.io/name: {{ include "nomad.name" . }}-app
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ include "nomad.name" . }}-api
- name: {{ include "nomad.name" . }}-app
image: "{{ .Values.images.nomad.name }}:{{ .Values.images.nomad.tag }}"
volumeMounts:
- mountPath: /app/nomad.yaml
......@@ -111,11 +111,11 @@ spec:
name: nomad-volume
env:
- name: NOMAD_SERVICE
value: "api"
value: "app"
- name: NOMAD_CONSOLE_LOGLEVEL
value: "{{ .Values.api.console_loglevel }}"
value: "{{ .Values.app.console_loglevel }}"
- name: NOMAD_LOGSTASH_LEVEL
value: "{{ .Values.api.logstash_loglevel }}"
value: "{{ .Values.app.logstash_loglevel }}"
{{ if .Values.postgres.password_secret }}
- name: NOMAD_REPOSITORY_DB_PASSWORD
valueFrom:
......@@ -144,17 +144,17 @@ spec:
initialDelaySeconds: 5
periodSeconds: 5
nodeSelector:
nomadtype: {{ .Values.api.nomadNodeType }}
nomadtype: {{ .Values.app.nomadNodeType }}
imagePullSecrets:
- name: {{ .Values.images.secret }}
imagePullPolicy: always
volumes:
- name: gunicorn-log-conf
configMap:
name: {{ include "nomad.fullname" . }}-api-gunicorn-log-config
name: {{ include "nomad.fullname" . }}-app-gunicorn-log-config
- name: gunicorn-conf
configMap:
name: {{ include "nomad.fullname" . }}-api-gunicorn-config
name: {{ include "nomad.fullname" . }}-app-gunicorn-config
- name: nomad-conf
configMap:
name: {{ include "nomad.fullname" . }}-configmap
......
......@@ -16,7 +16,7 @@ data:
location {{ .Values.proxy.external.path }} {
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_pass http://{{ include "nomad.fullname" . }}-api:8000;
proxy_pass http://{{ include "nomad.fullname" . }}-app:8000;
proxy_connect_timeout {{ .Values.proxy.timeout }};
proxy_send_timeout {{ .Values.proxy.timeout }};
proxy_read_timeout {{ .Values.proxy.timeout }};
......@@ -44,7 +44,7 @@ data:
proxy_request_buffering off;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_pass http://{{ include "nomad.fullname" . }}-api:8000;
proxy_pass http://{{ include "nomad.fullname" . }}-app:8000;
proxy_connect_timeout {{ .Values.proxy.timeout }};
}
......@@ -52,13 +52,13 @@ data:
proxy_buffering off;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_pass http://{{ include "nomad.fullname" . }}-api:8000;
proxy_pass http://{{ include "nomad.fullname" . }}-app:8000;
proxy_connect_timeout {{ .Values.proxy.timeout }};
}
}
env.js: |
window.nomadEnv = {
"apiBase": "{{ .Values.proxy.external.path }}/api",
"appBase": "{{ .Values.proxy.external.path }}",
"kibanaBase": "{{ .Values.proxy.external.kibanaPath }}",
"matomoSiteId": {{ .Values.gui.matomoSiteId }},
"matomoUrl": "{{ .Values.gui.matomoUrl }}",
......
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