Commit 48f76c8d authored by Jungho Shin's avatar Jungho Shin
Browse files

executing python2 directly

parent fd783d7f
......@@ -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/scalaOut1.txt", 'r'))
#dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut2.txt", 'r'))
while True:
inputDict=dictReader.readNextDict()
......
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()
#!/bin/bash
source $1/bin/activate
python $2/extract_from_repo.py $3
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
{'repo_base_path' = '/u/jungho/myscratch/NomadRepositoryParser'}
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)
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)
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 {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment