Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
b59dc5a5
Commit
b59dc5a5
authored
Oct 02, 2020
by
Markus Scheidgen
Browse files
Fixed client documentation.
parent
684b3bad
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/archive/client.py
View file @
b59dc5a5
...
...
@@ -9,33 +9,22 @@ from nomad.metainfo import units
query
=
ArchiveQuery
(
# url='http://nomad-lab.eu/prod/rae/beta/api',
query
=
{
'$and'
:
[
{
'dft.code_name'
:
'VASP'
},
{
'$gte'
:
{
'n_atoms'
:
3
}},
{
'$lte'
:
{
'dft.workflow.section_relaxation.final_energy_difference'
:
1e-24
}}
]
'dft.code_name'
:
'VASP'
},
required
=
{
'section_workflow'
:
{
'section_relaxation'
:
{
'final_calculation_ref'
:
{
'energy_total'
:
'*'
,
'single_configuration_calculation_to_system_ref'
:
{
'chemical_composition_reduced'
:
'*'
}
}
}
'section_run'
:
{
'section_single_configuration_calculation'
:
'*'
,
'section_system'
:
'*'
}
},
parallel
=
10
,
per_page
=
1000
,
max
=
10000
)
per_page
=
10
,
max
=
100
)
print
(
query
)
for
i
,
result
in
enumerate
(
query
):
if
i
<
10
:
calc
=
result
.
section_
workflow
.
section_
relaxati
on
.
fi
nal
_calculation
_ref
calc
=
result
.
section_
run
[
0
]
.
section_
single_c
onfi
guration
_calculation
[
-
1
]
energy
=
calc
.
energy_total
formula
=
calc
.
single_configuration_calculation_to_system_ref
.
chemical_composition_reduced
print
(
'%s: energy %s'
%
(
formula
,
energy
.
to
(
units
.
hartree
)))
print
(
query
)
examples/archive/client_workflows.py
0 → 100644
View file @
b59dc5a5
'''
A simple example that uses the NOMAD client library to access the archive.
'''
from
nomad.client
import
ArchiveQuery
from
nomad.metainfo
import
units
query
=
ArchiveQuery
(
query
=
{
'$and'
:
[
{
'dft.code_name'
:
'VASP'
},
{
'$gte'
:
{
'n_atoms'
:
3
}},
{
'$lte'
:
{
'dft.workflow.section_geometry_optimization.final_energy_difference'
:
1e-24
}}
]
},
required
=
{
'section_workflow'
:
{
'calculation_result_ref'
:
{
'energy_total'
:
'*'
,
'single_configuration_calculation_to_system_ref'
:
{
'chemical_composition_reduced'
:
'*'
}
}
}
},
parallel
=
10
,
per_page
=
10
,
max
=
100
)
for
i
,
result
in
enumerate
(
query
):
if
i
<
10
:
calc
=
result
.
section_workflow
.
calculation_result_ref
energy
=
calc
.
energy_total
formula
=
calc
.
single_configuration_calculation_to_system_ref
.
chemical_composition_reduced
print
(
'%s: energy %s'
%
(
formula
,
energy
.
to
(
units
.
hartree
)))
print
(
query
)
nomad/app/api/archive.py
View file @
b59dc5a5
...
...
@@ -300,13 +300,19 @@ class ArchiveQueryResource(Resource):
per_page
=
per_page
,
page
=
page
,
order_by
=
'upload_id'
)
except
KeyError
as
e
:
abort
(
400
,
str
(
e
))
abort
(
400
,
'The query part contained an unknown quantity or section: %s'
%
str
(
e
))
try
:
required_with_references
=
compute_required_with_referenced
(
required
)
except
KeyError
as
e
:
abort
(
400
,
message
=
'The required part contained an unknown quantity or section: %s'
%
str
(
e
))
data
=
[]
calcs
=
results
[
'results'
]
upload_files
=
None
current_upload_id
=
None
required_with_references
=
compute_required_with_referenced
(
required
)
archive_is_complete
=
False
if
required_with_references
is
not
None
:
archive_is_complete
=
True
...
...
nomad/client.py
View file @
b59dc5a5
...
...
@@ -35,7 +35,7 @@ source distribution
First example
_____________
.. literalinclude:: ../examples/client.py
.. literalinclude:: ../examples/
archive/
client.py
:language: python
This script should yield a result like this:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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