Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
aa120658
Commit
aa120658
authored
Oct 08, 2018
by
Markus Scheidgen
Browse files
Fixed raw all endpoint test. Added client reproduction skeleton.
parent
d028b9ed
Pipeline
#37670
passed with stages
in 7 minutes and 34 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/api.py
View file @
aa120658
...
...
@@ -23,7 +23,6 @@ import os.path
import
zipstream
from
zipfile
import
ZIP_DEFLATED
from
contextlib
import
contextmanager
import
types
from
nomad
import
config
,
infrastructure
from
nomad.files
import
UploadFile
,
ArchiveFile
,
ArchiveLogFile
...
...
nomad/client.py
View file @
aa120658
...
...
@@ -135,7 +135,7 @@ class CalcProcReproduction(UploadFile):
an fake 'upload' that only contains the respective calculation data. This allows us
to locally run processing code that is very similar to the one used on the server.
"""
def
__init__
(
self
,
archive_id
:
str
)
->
CalcProcReproducti
on
:
def
__init__
(
self
,
archive_id
:
str
)
->
N
on
e
:
local_path
=
os
.
path
.
join
(
config
.
fs
.
tmp
,
'%s.zip'
%
archive_id
)
if
not
os
.
path
.
exists
(
local_path
):
# download raw if not already downloaded
...
...
@@ -146,20 +146,20 @@ class CalcProcReproduction(UploadFile):
super
().
__init__
(
upload_id
=
'tmp_%s'
%
archive_id
,
local_path
=
local_path
)
def
parse
(
parser_name
:
str
=
None
):
def
parse
(
self
,
parser_name
:
str
=
None
):
"""
Run the given parser on the downloaded calculation. If no parser is given,
do parser matching and use the respective parser.
"""
pass
def
normalize
(
normalizer_name
:
str
):
def
normalize
(
self
,
normalizer_name
:
str
):
"""
Parse the downloaded calculation and run the given normalizer.
"""
pass
def
normalize_all
():
def
normalize_all
(
self
):
"""
Parse the downloaded calculation and run the whole normalizer chain.
"""
...
...
tests/test_api.py
View file @
aa120658
...
...
@@ -8,6 +8,8 @@ from mongoengine import connect
from
mongoengine.connection
import
disconnect
from
datetime
import
datetime
,
timedelta
import
base64
import
zipfile
import
io
from
nomad
import
config
# for convinience we test the api without path prefix
...
...
@@ -356,8 +358,9 @@ def test_raw_all_files(client, example_repo_with_files, no_warn):
rv
=
client
.
get
(
'/raw/%s?all=1'
%
example_repo_with_files
.
archive_id
)
assert
rv
.
status_code
==
200
assert
len
(
rv
.
data
)
>
0
with
open
(
'test.zip'
,
'wb'
)
as
f
:
f
.
write
(
rv
.
data
)
with
zipfile
.
ZipFile
(
io
.
BytesIO
(
rv
.
data
))
as
zip_file
:
assert
zip_file
.
testzip
()
is
None
assert
len
(
zip_file
.
namelist
())
==
5
def
test_raw_missing_mainfile
(
client
,
no_warn
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment