diff --git a/gui/src/api.js b/gui/src/api.js index 354c0c4a566ff50d91f1777fcedff7df9ae399b1..3ab503dd3e35eb3513cce1e0e43edde652a50a85 100644 --- a/gui/src/api.js +++ b/gui/src/api.js @@ -144,6 +144,22 @@ function archive(uploadHash, calcHash) { .then(response => response.json()) } +function calcProcLog(uploadHash, calcHash) { + return fetch(`${apiBase}/logs/${uploadHash}/${calcHash}`) + .catch(networkError) + .then(response => { + if (!response.ok) { + if (response.status === 404) { + return '' + } else { + return handleResponseErrors(response) + } + } else { + return response.text() + } + }) +} + function archiveUrl(uploadHash, calcHash) { return `${apiBase}/archive/${uploadHash}/${calcHash}` } @@ -236,6 +252,7 @@ const api = { unstageUpload: unstageUpload, getUploads: getUploads, archive: archive, + calcProcLog: calcProcLog, archiveUrl: archiveUrl, repo: repo, repoAll: repoAll, diff --git a/gui/src/components/ArchiveCalc.js b/gui/src/components/ArchiveCalc.js index 40f8fd7545cde45f19d168ecc7cf4d94e5ce9c0d..831f184e93bcbf763ba1f22f11cda5ea1340d3b3 100644 --- a/gui/src/components/ArchiveCalc.js +++ b/gui/src/components/ArchiveCalc.js @@ -18,6 +18,10 @@ class ArchiveCalc extends React.Component { calcData: { padding: theme.spacing.unit }, + logs: { + marginTop: theme.spacing.unit * 2, + padding: theme.spacing.unit + }, metaInfo: { height: 120, padding: theme.spacing.unit * 2, @@ -37,6 +41,7 @@ class ArchiveCalc extends React.Component { super(props) this.state = { data: null, + logs: null, metaInfo: null, showMetaInfo: false } @@ -51,6 +56,12 @@ class ArchiveCalc extends React.Component { this.props.raiseError(error) }) + api.calcProcLog(uploadHash, calcHash).then(logs => { + if (logs && logs !== '') { + this.setState({logs: logs}) + } + }) + api.getMetaInfo().then(metaInfo => { this.setState({metaInfo: metaInfo}) }).catch(error => { @@ -112,6 +123,14 @@ class ArchiveCalc extends React.Component { : <LinearProgress variant="query" /> } </Paper> + { this.state.logs + ? + <Paper className={classes.logs}> + <pre> + {this.state.logs} + </pre> + </Paper> + : ''} </div> ) diff --git a/nomad/files.py b/nomad/files.py index 76a6252b0c73f2e3db34849e1003f7317dd3f8c7..f0ad0b90a6983e6a493ea8666e34d6aef89a401e 100644 --- a/nomad/files.py +++ b/nomad/files.py @@ -69,6 +69,7 @@ class Objects: path_segments = file_name.split('/') path = os.path.join(*([config.fs.objects, bucket] + path_segments)) directory = os.path.dirname(path) + if not os.path.isdir(directory): os.makedirs(directory) diff --git a/nomad/processing/data.py b/nomad/processing/data.py index 42d68605c1e7d73d082e906592e973bcfe283c10..d96f5591c073434efdac561fa5719d8c522be384 100644 --- a/nomad/processing/data.py +++ b/nomad/processing/data.py @@ -142,7 +142,7 @@ class Calc(Proc): self.normalizing() self.archiving() finally: - # close open loghandler + # close loghandler that was not closed due to failures try: if self._loghandler is not None: self._loghandler.close() @@ -196,6 +196,11 @@ class Calc(Proc): with ArchiveFile(self.archive_id).write_archive_json() as out: self._parser_backend.write_json(out, pretty=True) + # close loghandler + if self._loghandler is not None: + self._loghandler.close() + self._loghandler = None + class Upload(Chord): """