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
parser-molcas
Compare Revisions
92d5084cb99c23b5f41f615813ff64278d2b1aa9...6b536f8f244da0fb7177d17d21543a922f7bff8f
Commits (1)
Adopted implementation for nomad-fairdi.
· 6b536f8f
Markus Scheidgen
authored
Aug 13, 2019
6b536f8f
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
6b536f8f
# use glob syntax.
syntax: glob
*.ser
*.class
*~
*.bak
#*.off
*.old
# python
__pycache__
.mypy_cache
*.pyc
*.bk
*.swp
.DS_Store
**/__pycache__
# logging files
detailed.log
# eclipse conf file
.settings
.classpath
.project
.manager
.scala_dependencies
# idea
.idea
*.iml
# building
target
build
null
tmp*
temp*
dist
test-output
build.log
# other scm
.svn
.CVS
.hg*
# switch to regexp syntax.
# syntax: regexp
# ^\.pc/
#SHITTY output not in target directory
build.log
#emacs TAGS
TAGS
lib/
env/
# Egg
parser/parser-big-dft/bigdftparser.egg-info/
*.egg-info/
\ No newline at end of file
molcasparser/__init__.py
0 → 100644
View file @
6b536f8f
from
.main
import
MolcasParser
parser/parser-
molcas/functionals.py
→
molcas
parser
/functionals.py
View file @
6b536f8f
# Copyright 2016-2018
The NOMAD Developers Group
# Copyright 2016-2018
Ask Hjorth Larsen, Fawzi Mohamed
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
parser/parser-
molcas/main.py
→
molcas
parser
/main.py
View file @
6b536f8f
# Copyright 2016-2018
The NOMAD Developers Group
# Copyright 2016-2018
Ask Hjorth Larsen, Fawzi Mohamed
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -17,8 +17,8 @@
from
__future__
import
print_function
import
os
import
sys
import
setup_paths
import
re
import
logging
import
numpy
as
np
from
ase
import
Atoms
...
...
@@ -29,10 +29,11 @@ from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.unit_conversion.unit_conversion
\
import
register_userdefined_quantity
,
convert_unit
import
nomad_meta_info
from
functionals
import
functionals
from
.
functionals
import
functionals
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"../../../../
nomad
-
meta
-
info
/meta_info/nomad_meta_info/
molcas.nomadmetainfo.json"
))
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad
_
meta
_
info
.
__file__
)),
"
molcas.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
...
...
@@ -640,29 +641,53 @@ def molcas_main_loop_sm():
]
+
get_anymodule_sms
())
return
m
mainFileDescription
=
SM
(
name
=
'root'
,
weak
=
True
,
startReStr
=
''
,
fixedStartValues
=
{
'program_name'
:
'Molcas'
,
'program_basis_set_type'
:
'gaussians'
},
sections
=
[
'section_run'
],
subMatchers
=
[
get_header_sm
(),
#get_inputfile_echo_sm(),
molcas_main_loop_sm
(),
SM
(
r
'x^'
,
# force parser to parse the whole file
name
=
'impossible'
)
])
def
main
(
**
kwargs
):
mainFunction
(
mainFileDescription
=
mainFileDescription
,
metaInfoEnv
=
metaInfoEnv
,
parserInfo
=
parser_info
,
cachingLevelForMetaName
=
{},
superContext
=
context
,
**
kwargs
)
def
main_file_description
():
return
SM
(
name
=
'root'
,
weak
=
True
,
startReStr
=
''
,
fixedStartValues
=
{
'program_name'
:
'Molcas'
,
'program_basis_set_type'
:
'gaussians'
},
sections
=
[
'section_run'
],
subMatchers
=
[
get_header_sm
(),
#get_inputfile_echo_sm(),
molcas_main_loop_sm
(),
SM
(
r
'x^'
,
# force parser to parse the whole file
name
=
'impossible'
)
])
class
MolcasParser
():
""" A proper class envolop for running this parser from within python. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
global
context
context
=
MolcasContext
()
from
unittest.mock
import
patch
logging
.
debug
(
'molcas parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
metaInfoEnv
)
with
patch
.
object
(
sys
,
'argv'
,
[
'<exe>'
,
'--uri'
,
'nmd://uri'
,
mainfile
]):
mainFunction
(
mainFileDescription
=
main_file_description
(),
metaInfoEnv
=
metaInfoEnv
,
parserInfo
=
parser_info
,
cachingLevelForMetaName
=
{},
superContext
=
context
,
superBackend
=
backend
)
return
backend
if
__name__
==
'__main__'
:
main
()
mainFunction
(
mainFileDescription
=
main_file_description
(),
metaInfoEnv
=
metaInfoEnv
,
parserInfo
=
parser_info
,
cachingLevelForMetaName
=
{},
superContext
=
context
,
**
kwargs
)
parser/parser-molcas/generate_scala_testcode.py
deleted
100755 → 0
View file @
9ae0c172
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Main author and maintainer: Ask Hjorth Larsen <asklarsen@gmail.com>
from
__future__
import
print_function
import
os
from
glob
import
glob
scala_imports
=
"""package eu.nomad_lab.parsers
import eu.nomad_lab.{ parsers, DefaultPythonInterpreter }
import org.scalacheck.Properties
import org.specs2.mutable.Specification
import org.{ json4s => jn }
"""
test_template
=
"""
\
"test %(name)s " >> {
"test with json-events" >> {
ParserRun.parse(MolcasParser, "parsers/molcas/test/examples/%(name)s", "json-events") must_== ParseResult.ParseSuccess
}
"test with json" >> {
ParserRun.parse(MolcasParser, "parsers/molcas/test/examples/%(name)s", "json") must_== ParseResult.ParseSuccess
}
}"""
fd
=
open
(
'out.scala'
,
'w'
)
fd
.
write
(
scala_imports
)
print
(
'object MolcasParserSpec extends Specification {'
,
file
=
fd
)
print
(
' "MolcasParserTest" >> {'
,
file
=
fd
)
fnames
=
glob
(
'test/test???.input.out'
)
fnames
.
sort
()
for
fname
in
fnames
:
fname
=
os
.
path
.
basename
(
fname
)
print
(
test_template
%
dict
(
name
=
fname
),
file
=
fd
)
print
(
' }'
,
file
=
fd
)
print
(
'}'
,
file
=
fd
)
parser/parser-molcas/nomad_meta_info
deleted
120000 → 0
View file @
9ae0c172
../../../../nomad-meta-info/meta_info/nomad_meta_info
\ No newline at end of file
parser/parser-molcas/runtests.py
deleted
100755 → 0
View file @
9ae0c172
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Main author and maintainer: Ask Hjorth Larsen <asklarsen@gmail.com>
from
__future__
import
print_function
from
glob
import
glob
import
re
from
optparse
import
OptionParser
from
subprocess
import
Popen
,
PIPE
import
os
from
ase.parallel
import
world
import
platform
p
=
OptionParser
()
opts
,
args
=
p
.
parse_args
()
if
len
(
args
)
==
0
:
testfiles
=
glob
(
'test/test???.input.out'
)
testfiles
.
sort
()
else
:
testfiles
=
argv
for
i
,
testfile
in
enumerate
(
testfiles
):
if
i
%
world
.
size
!=
world
.
rank
:
continue
dirname
,
basename
=
os
.
path
.
split
(
testfile
)
py
=
'python'
if
platform
.
node
()
==
'labdev-nomad'
:
py
=
'/labEnv3/bin/python'
args
=
[
py
,
'main.py'
,
'--annotate'
]
args
.
append
(
testfile
)
print
(
' '
.
join
(
args
))
proc
=
Popen
(
args
,
stdout
=
PIPE
)
txt
=
proc
.
stdout
.
read
()
with
open
(
'%s.json'
%
testfile
,
'w'
)
as
fd
:
fd
.
write
(
txt
.
decode
(
'ascii'
))
parser/parser-molcas/setup_paths.py
deleted
100644 → 0
View file @
9ae0c172
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Main author and maintainer: Ask Hjorth Larsen <asklarsen@gmail.com>
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"
))
if
not
commonDir
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
commonDir
)
parser/parser-molcas/test
deleted
120000 → 0
View file @
9ae0c172
../../test/examples
\ No newline at end of file
pysrc
deleted
120000 → 0
View file @
9ae0c172
parser/parser-molcas
\ No newline at end of file
setup.py
0 → 100644
View file @
6b536f8f
# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
setuptools
import
setup
,
find_packages
def
main
():
setup
(
name
=
'molcasparser'
,
version
=
'0.1'
,
description
=
'NOMAD parser implementation for Molcas.'
,
author
=
'Ask Hjorth Larsen, Fawzi Mohamed'
,
license
=
'APACHE 2.0'
,
packages
=
find_packages
(),
install_requires
=
[
'nomadcore'
],
)
if
__name__
==
'__main__'
:
main
()
src/main/scala/eu/nomad_lab/parsers/MolcasParser.scala
deleted
100644 → 0
View file @
9ae0c172
/*
Copyright 2016-2017 The NOMAD Developers Group
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
eu.nomad_lab.parsers
import
eu.
{
nomad_lab
=>
lab
}
import
eu.nomad_lab.DefaultPythonInterpreter
import
org.
{
json4s
=>
jn
}
import
scala.collection.breakOut
object
MolcasParser
extends
SimpleExternalParserGenerator
(
name
=
"MolcasParser"
,
parserInfo
=
jn
.
JObject
(
(
"name"
->
jn
.
JString
(
"MolcasParser"
))
::
(
"parserId"
->
jn
.
JString
(
"MolcasParser"
+
lab
.
MolcasVersionInfo
.
version
))
::
(
"versionInfo"
->
jn
.
JObject
(
(
"nomadCoreVersion"
->
jn
.
JObject
(
lab
.
NomadCoreVersionInfo
.
toMap
.
map
{
case
(
k
,
v
)
=>
k
->
jn
.
JString
(
v
.
toString
)
}(
breakOut
)
:
List
[(
String
,
jn.JString
)]))
::
(
lab
.
MolcasVersionInfo
.
toMap
.
map
{
case
(
key
,
value
)
=>
(
key
->
jn
.
JString
(
value
.
toString
))
}(
breakOut
)
:
List
[(
String
,
jn.JString
)])
))
::
Nil
),
mainFileTypes
=
Seq
(
"text/.*"
),
mainFileRe
=
"""
\s*\^[\s\^]*M O L C A S\s*
\s*\^[\s\^]*version \S+ patchlevel \S+\s*
"""
.
r
,
cmd
=
Seq
(
DefaultPythonInterpreter
.
pythonExe
(),
"${envDir}/parsers/molcas/parser/parser-molcas/main.py"
,
"--uri"
,
"${mainFileUri}"
,
"${mainFilePath}"
),
resList
=
Seq
(
"parser-molcas/main.py"
,
"parser-molcas/functionals.py"
,
"parser-molcas/setup_paths.py"
,
"nomad_meta_info/public.nomadmetainfo.json"
,
"nomad_meta_info/common.nomadmetainfo.json"
,
"nomad_meta_info/meta_types.nomadmetainfo.json"
,
"nomad_meta_info/molcas.nomadmetainfo.json"
)
++
DefaultPythonInterpreter
.
commonFiles
(),
dirMap
=
Map
(
"parser-molcas"
->
"parsers/molcas/parser/parser-molcas"
,
"nomad_meta_info"
->
"nomad-meta-info/meta_info/nomad_meta_info"
,
"python"
->
"python-common/common/python/nomadcore"
)
++
DefaultPythonInterpreter
.
commonDirMapping
(),
metaInfoEnv
=
Some
(
lab
.
meta
.
KnownMetaInfoEnvs
.
molcas
)
)
src/test/scala/eu/nomad_lab/parsers/MolcasParserSpec.scala
deleted
100644 → 0
View file @
9ae0c172
This diff is collapsed.
Click to expand it.
test
/example
s/.gitignore
→
tests/.gitignore
View file @
6b536f8f
File moved
test
/example
s/inputs/test000.input
→
tests/inputs/test000.input
View file @
6b536f8f
File moved
test
/example
s/inputs/test001.input
→
tests/inputs/test001.input
View file @
6b536f8f
File moved
test
/example
s/inputs/test002.input
→
tests/inputs/test002.input
View file @
6b536f8f
File moved
test
/example
s/inputs/test003.input
→
tests/inputs/test003.input
View file @
6b536f8f
File moved
test
/example
s/inputs/test004.input
→
tests/inputs/test004.input
View file @
6b536f8f
File moved
test
/example
s/inputs/test005.input
→
tests/inputs/test005.input
View file @
6b536f8f
File moved
Prev
1
2
3
4
5
…
8
Next