Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
normalizer-repo-tags
Commits
48f76c8d
Commit
48f76c8d
authored
Nov 28, 2017
by
Jungho Shin
Browse files
executing python2 directly
parent
fd783d7f
Changes
10
Hide whitespace changes
Inline
Side-by-side
normalizer/normalizer-repo-tags/calculate_repo_tags.py
View file @
48f76c8d
...
...
@@ -15,12 +15,11 @@ def calculateTags(inputDict, backend, calcUri):
else
:
backend
.
openContext
(
calcUri
)
repoSect
=
backend
.
openSection
(
"section_repository_info"
)
repo_dic_sub
=
subprocess
.
Popen
([
'/u/jungho/myscratch/NomadRepositoryParser/bin/python'
,
'extract_from_repo.py'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
repo_dic_sub_out
=
repo_dic_sub
.
communicate
(
json
.
dumps
(
inputDict
)
+
'
\n
'
)[
0
]
repo_dic
=
json
.
loads
(
repo_dic_sub_out
)
repo_dic_sub
=
subprocess
.
Popen
([
os
.
path
.
join
(
base_path
,
'extract_from_repo.sh'
),
'/scratch/u/jungho/NomadRepositoryParser/'
,
base_path
,
'/nomad/jshin/work/normalizer/scalaOut1.txt'
],
stdout
=
subprocess
.
PIPE
)
repo_dic
=
json
.
load
(
repo_dic_sub
.
stdout
)
backend
.
addValue
(
"repository_checksum"
,
repo_dic
[
'checksum'
])
#backend.addValue("repository_checksum", repo_dic['checksum'])
backend
.
addValue
(
"repository_chemical_formula"
,
repo_dic
[
'formula'
])
backend
.
addValue
(
"repository_parser_id"
,
repo_dic
[
'prog_name'
]
+
' v1.0'
)
backend
.
addValue
(
"repository_atomic_elements"
,
repo_dic
[
'elements'
])
...
...
@@ -56,7 +55,7 @@ def main():
parserInfo
=
{
'name'
:
'RepoTagsNormalizer'
,
'version'
:
'1.0'
})
dictReader
=
ParseStreamedDicts
(
sys
.
stdin
)
#dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut
1
.txt", 'r'))
#dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut
2
.txt", 'r'))
while
True
:
inputDict
=
dictReader
.
readNextDict
()
...
...
normalizer/normalizer-repo-tags/extract_from_repo.py
View file @
48f76c8d
import
setup_paths_repo
import
os.path
,
sys
,
json
#import setup_paths, setup_paths_repo
import
sys
,
json
import
sqlalchemy
base_path
=
sys
.
exec_prefix
+
'/python'
sys
.
path
.
insert
(
0
,
base_path
)
from
nomadrepo.core.settings
import
connect_database
,
settings
from
nomadrepo.core.api
import
API
inputStr
=
sys
.
stdin
.
readline
()
base_path
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
def
extract_metadata
(
dic
):
work
=
API
()
inp_str
=
""
.
join
(
sys
.
argv
[
1
:])
for
calc
,
error
in
work
.
_parse
(
dic
,
"normalizerRepo"
):
calc
,
error
=
work
.
classify
(
calc
)
calc
.
info
[
'oadate'
]
=
None
#calc.info['checksum'] = calc.get_checksum()
json
.
dump
(
calc
.
info
,
sys
.
__stdout__
)
pass
work
=
API
()
for
calc
,
error
in
work
.
_parse
(
inp_str
,
"normalizerRepo"
):
calc
,
error
=
work
.
classify
(
calc
)
calc
.
info
[
'oadate'
]
=
None
calc
.
info
[
'checksum'
]
=
calc
.
get_checksum
()
json
.
dump
(
calc
.
info
,
sys
.
__stdout__
)
def
main
()
:
inputDict
=
json
.
loads
(
inputStr
)
extract_metadata
(
inputDict
)
if
__name__
==
"__main__"
:
main
(
)
normalizer/normalizer-repo-tags/extract_from_repo.sh
deleted
100755 → 0
View file @
fd783d7f
#!/bin/bash
source
$1
/bin/activate
python
$2
/extract_from_repo.py
$3
normalizer/normalizer-repo-tags/normalizer/__init__.py
deleted
100755 → 0
View file @
fd783d7f
normalizer/normalizer-repo-tags/normalizer/manifest.json
deleted
100755 → 0
View file @
fd783d7f
{
"enabled"
:
1
}
normalizer/normalizer-repo-tags/normalizer/normalizer.py
deleted
100644 → 0
View file @
fd783d7f
from
ase
import
Atoms
from
nomadrepo.parsers
import
Output
from
numpy
import
array
class
normalizerRepo
(
Output
):
def
__init__
(
self
,
filename
,
**
kwargs
):
Output
.
__init__
(
self
,
filename
)
# fill out i.e. backend.addValue unsing input Dict
# "repository_checksum",
# "repository_chemical_formula",
# "repository_parser_id",
# "repository_atomic_elements",
# "repository_basis_set_type",
# "repository_code_version",
# "repository_crystal_system",
# "repository_program_name",
# "repository_spacegroup_nr",
# "repository_system_type",
# "repository_xc_treatment"
# add more?
filename_f
=
open
(
filename
,
'r'
)
import
json
inputDict
=
json
.
load
(
filename_f
)[
0
]
filename_f
.
close
()
atom_symbols
=
inputDict
[
'section_system.last'
][
'atom_labels'
][
'flatData'
]
## Change these ##
simulation_cell
=
[
50.0
,
50.0
,
50.0
]
configuration_periodic_dimensions
=
[
False
,
False
,
False
]
####
atom_positions_flat
=
inputDict
[
'section_system.last'
][
'atom_positions'
][
'flatData'
]
atom_positions_shape
=
inputDict
[
'section_system.last'
][
'atom_positions'
][
'shape'
]
atom_positions_list
=
[]
for
atom_i
in
range
(
0
,
atom_positions_shape
[
0
]):
atom_i_start
=
atom_i
*
atom_positions_shape
[
1
]
atom_positions_list
.
append
(
atom_positions_flat
[
atom_i_start
:
atom_i_start
+
atom_positions_shape
[
1
]])
atom_positions
=
array
(
atom_positions_list
)
self
.
structures
.
append
(
Atoms
(
symbols
=
atom_symbols
,
cell
=
simulation_cell
,
positions
=
atom_positions
,
pbc
=
configuration_periodic_dimensions
))
self
.
info
[
'energy'
]
=
inputDict
[
'energy_total.last'
]
self
.
info
[
'prog'
]
=
inputDict
[
'program_name'
][
0
]
+
' '
+
inputDict
[
'program_version'
][
0
]
## Need the path of mainly parsed file.
from
nomadrepo.parsers.LAB.LAB
import
ParsingContext
from
nomadrepo.parsers.LAB.LAB
import
save_xcFunctional
context
=
ParsingContext
()
self
.
electrons
[
'type'
]
=
context
.
toDict_bs_type
()[
inputDict
[
'program_name'
][
0
]]
save_xcFunctional
(
self
,
inputDict
[
'XC_functional_name'
])
# "repository_xc_treatment"
@
staticmethod
def
fingerprints
(
test_string
,
file
=
None
):
# fake method
return
False
normalizer/normalizer-repo-tags/setting.json
0 → 100644
View file @
48f76c8d
{
'repo_base_path'
=
'/u/jungho/myscratch/NomadRepositoryParser'
}
normalizer/normalizer-repo-tags/setup_paths.py
View file @
48f76c8d
import
sys
,
os
,
os
.
path
baseDir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
commonDir
=
os
.
path
.
normpath
(
os
.
path
.
join
(
baseDir
,
"../../../../python-common/common/python"
))
#repoParserDir = os.path.normpath(os.path.join(baseDir,"/u/jungho/myscratch/NomadRepositoryParser/python/"))
if
not
commonDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
commonDir
)
#if not repoParserDir in sys.path:
# sys.path.insert(0, repoParserDir)
normalizer/normalizer-repo-tags/setup_paths_repo.py
deleted
100644 → 0
View file @
fd783d7f
import
sys
,
os
,
os
.
path
baseDir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
repoParserDir
=
os
.
path
.
normpath
(
os
.
path
.
join
(
baseDir
,
"/u/jungho/myscratch/NomadRepositoryParser/python/"
))
if
not
repoParserDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
repoParserDir
)
src/test/scala/eu/nomad_lab/normalizers/FhiAimsBasisNormalizer.scala
0 → 100644
View file @
48f76c8d
package
eu.nomad_lab.normalizers
import
eu.nomad_lab.
{
parsers
,
DefaultPythonInterpreter
}
import
org.scalacheck.Properties
import
org.specs2.mutable.Specification
import
org.
{
json4s
=>
jn
}
object
FhiAimsBasisNormalizerSpec
extends
Specification
{
}
Write
Preview
Supports
Markdown
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