Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-FAIR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
nomad-FAIR
Commits
6abd956d
Commit
6abd956d
authored
5 years ago
by
Lauri Himanen
Browse files
Options
Downloads
Patches
Plain Diff
Realized that in base64 encoding the default 28 chars will be enough space for anything.
parent
e1b6b2a8
No related branches found
No related tags found
4 merge requests
!115
V0.8.0 beta
,
!113
V0.8.0
,
!103
Merging Encyclopedia functionality with v0.8.0
,
!102
First version of EncyclopediaNormalizer
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
nomad/metainfo/encyclopedia.py
+26
-3
26 additions, 3 deletions
nomad/metainfo/encyclopedia.py
nomad/normalizing/encyclopedia.py
+7
-7
7 additions, 7 deletions
nomad/normalizing/encyclopedia.py
nomad/utils.py
+4
-2
4 additions, 2 deletions
nomad/utils.py
with
37 additions
and
12 deletions
nomad/metainfo/encyclopedia.py
+
26
−
3
View file @
6abd956d
...
@@ -14,9 +14,8 @@ class Material(MSection):
...
@@ -14,9 +14,8 @@ class Material(MSection):
material_hash
=
Quantity
(
material_hash
=
Quantity
(
type
=
str
,
type
=
str
,
description
=
"""
description
=
"""
A unique material identifier. For crystals the hash
A fixed length, unique material identifier in the form of a hash
identifier is constructed from formula, space group and
digest.
wyckoff_position_population.
"""
"""
)
)
system_type
=
Quantity
(
system_type
=
Quantity
(
...
@@ -268,6 +267,30 @@ class Calculation(MSection):
...
@@ -268,6 +267,30 @@ class Calculation(MSection):
Mass density of the material based on the structural information.
Mass density of the material based on the structural information.
"""
"""
)
)
method_hash
=
Quantity
(
type
=
str
,
description
=
"""
A fixed length, unique method identifier in the form of a hash
digest.
"""
)
group_eos_hash
=
Quantity
(
type
=
str
,
description
=
"""
A fixed length, unique identifier for equation-of-state calculations.
Only calculations wihtin the same upload will be grouped under the same
hash.
"""
)
group_parametervariation_hash
=
Quantity
(
type
=
str
,
description
=
"""
A fixed length, unique identifier for calculations where structure is
identical but the used computational parameters are varied. Only
calculations within the same upload will be grouped under the same
hash.
"""
)
run_type
=
Quantity
(
run_type
=
Quantity
(
type
=
MEnum
(
type
=
MEnum
(
single_point
=
"
single point
"
,
single_point
=
"
single point
"
,
...
...
This diff is collapsed.
Click to expand it.
nomad/normalizing/encyclopedia.py
+
7
−
7
View file @
6abd956d
...
@@ -277,7 +277,7 @@ class Structure():
...
@@ -277,7 +277,7 @@ class Structure():
# Create and store hash based on SHA512
# Create and store hash based on SHA512
norm_hash_string
=
structure
.
get_symmetry_string
(
space_group_number
,
wyckoff_sets
)
norm_hash_string
=
structure
.
get_symmetry_string
(
space_group_number
,
wyckoff_sets
)
material
.
material_hash
=
hash
(
norm_hash_string
,
length
=
128
)
material
.
material_hash
=
hash
(
norm_hash_string
)
def
number_of_atoms
(
self
,
material
:
Material
,
std_atoms
:
ase
.
Atoms
)
->
None
:
def
number_of_atoms
(
self
,
material
:
Material
,
std_atoms
:
ase
.
Atoms
)
->
None
:
material
.
number_of_atoms
=
len
(
std_atoms
)
material
.
number_of_atoms
=
len
(
std_atoms
)
...
@@ -705,7 +705,7 @@ class Structure1D(Structure):
...
@@ -705,7 +705,7 @@ class Structure1D(Structure):
id_strings
.
append
(
formula
)
id_strings
.
append
(
formula
)
id_strings
.
append
(
fingerprint
)
id_strings
.
append
(
fingerprint
)
hash_seed
=
"
,
"
.
join
(
id_strings
)
hash_seed
=
"
,
"
.
join
(
id_strings
)
hash_val
=
hash
(
hash_seed
,
length
=
128
)
hash_val
=
hash
(
hash_seed
)
material
.
material_hash
=
hash_val
material
.
material_hash
=
hash_val
def
cell_normalized
(
self
,
material
:
Material
,
std_atoms
:
ase
.
Atoms
)
->
None
:
def
cell_normalized
(
self
,
material
:
Material
,
std_atoms
:
ase
.
Atoms
)
->
None
:
...
@@ -948,7 +948,7 @@ class Method():
...
@@ -948,7 +948,7 @@ class Method():
group_eos_hash
=
self
.
group_dict_to_hash
(
'
group_eos_hash
'
,
hash_dict
)
group_eos_hash
=
self
.
group_dict_to_hash
(
'
group_eos_hash
'
,
hash_dict
)
calculation
.
group_eos_hash
=
group_eos_hash
calculation
.
group_eos_hash
=
group_eos_hash
def
group_parametervariation_hash
(
self
):
def
group_parametervariation_hash
(
self
,
calculation
:
Calculation
):
# Create ordered dictionary with the values. Order is important for
# Create ordered dictionary with the values. Order is important for
# consistent hashing.
# consistent hashing.
hash_dict
:
OrderedDict
=
OrderedDict
()
hash_dict
:
OrderedDict
=
OrderedDict
()
...
@@ -960,7 +960,7 @@ class Method():
...
@@ -960,7 +960,7 @@ class Method():
# Form a hash from the dictionary
# Form a hash from the dictionary
group_eos_hash
=
self
.
group_dict_to_hash
(
'
group_eos_hash
'
,
hash_dict
)
group_eos_hash
=
self
.
group_dict_to_hash
(
'
group_eos_hash
'
,
hash_dict
)
calculation
.
group_
eos
_hash
=
group_eos_hash
calculation
.
group_
parametervariation
_hash
=
group_eos_hash
def
group_e_min
(
self
)
->
None
:
def
group_e_min
(
self
)
->
None
:
pass
pass
...
@@ -1006,15 +1006,15 @@ class Method():
...
@@ -1006,15 +1006,15 @@ class Method():
@abstractmethod
@abstractmethod
def
method_hash_dict
(
self
):
def
method_hash_dict
(
self
):
return
OrderedDict
()
;
return
OrderedDict
()
@abstractmethod
@abstractmethod
def
group_eos_hash_dict
(
self
):
def
group_eos_hash_dict
(
self
):
return
OrderedDict
()
;
return
OrderedDict
()
@abstractmethod
@abstractmethod
def
group_parametervariation_hash_dict
(
self
):
def
group_parametervariation_hash_dict
(
self
):
return
OrderedDict
()
;
return
OrderedDict
()
def
group_dict_to_hash
(
self
,
name
,
src_dict
:
OrderedDict
):
def
group_dict_to_hash
(
self
,
name
,
src_dict
:
OrderedDict
):
"""
Given a dictionary of computational settings, this function forms a
"""
Given a dictionary of computational settings, this function forms a
...
...
This diff is collapsed.
Click to expand it.
nomad/utils.py
+
4
−
2
View file @
6abd956d
...
@@ -73,7 +73,8 @@ def decode_handle_id(handle_str: str):
...
@@ -73,7 +73,8 @@ def decode_handle_id(handle_str: str):
def
hash
(
*
args
,
length
:
int
=
default_hash_len
)
->
str
:
def
hash
(
*
args
,
length
:
int
=
default_hash_len
)
->
str
:
"""
Creates a websave hash of the given length based on the repr of the given arguments.
"""
"""
Creates a websave hash of the given length based on the repr of the given arguments.
"""
hash
=
hashlib
.
sha512
()
hash
=
hashlib
.
sha512
()
for
arg
in
args
:
for
arg
in
args
:
hash
.
update
(
str
(
arg
).
encode
(
'
utf-8
'
))
hash
.
update
(
str
(
arg
).
encode
(
'
utf-8
'
))
...
@@ -82,7 +83,8 @@ def hash(*args, length: int = default_hash_len) -> str:
...
@@ -82,7 +83,8 @@ def hash(*args, length: int = default_hash_len) -> str:
def
make_websave
(
hash
,
length
:
int
=
default_hash_len
)
->
str
:
def
make_websave
(
hash
,
length
:
int
=
default_hash_len
)
->
str
:
"""
Creates a websave string for a hashlib hash object.
"""
"""
Creates a websave string for a hashlib hash object.
"""
if
length
>
0
:
if
length
>
0
:
return
base64
.
b64encode
(
hash
.
digest
(),
altchars
=
b
'
-_
'
)[:
length
].
decode
(
'
utf-8
'
)
return
base64
.
b64encode
(
hash
.
digest
(),
altchars
=
b
'
-_
'
)[:
length
].
decode
(
'
utf-8
'
)
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment