Commit fd783d7f authored by Jungho Shin's avatar Jungho Shin
Browse files

enhance interface to the Repository codebase

parent 2b0999a9
import setup_paths
import json
import os.path, sys
import os.path, sys, subprocess
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.parser_backend import JsonParseEventsWriterBackend
from nomadcore.parse_streamed_dicts import *
import logging
from nomadrepo.core.api import API
base_path = os.path.abspath(os.path.dirname(__file__))
def calculateTags(inputDict, backend, calcUri):
......@@ -18,21 +16,21 @@ def calculateTags(inputDict, backend, calcUri):
backend.openContext(calcUri)
repoSect = backend.openSection("section_repository_info")
work = API()
for calc, error in work._parse("/nomad/jshin/work/normalizer/scalaOut1.txt", "normalizerRepo"):
calc, error = work.classify(calc)
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", calc.get_checksum())
backend.addValue("repository_chemical_formula", calc.info['formula']
#backend.addValue("repository_parser_id", value)
backend.addValue("repository_atomic_elements", calc.info['elements'])
backend.addValue("repository_basis_set_type", calc.info['ansatz'])
#backend.addValue("repository_code_version", value)
backend.addValue("repository_crystal_system", calc.info['symmetry'])
#backend.addValue("repository_program_name", calc.info[''])
backend.addValue("repository_spacegroup_nr", calc.info['ng'])
backend.addValue("repository_system_type", calc.info['periodicity'])
backend.addValue("repository_xc_treatment", calc.info['H_types'])
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'])
backend.addValue("repository_basis_set_type", repo_dic['ansatz'])
backend.addValue("repository_code_version", repo_dic['prog'].split(repo_dic['prog_name'])[0])
backend.addValue("repository_crystal_system", repo_dic['symmetry'])
backend.addValue("repository_program_name", repo_dic['prog_name'])
backend.addValue("repository_spacegroup_nr", repo_dic['ng'])
backend.addValue("repository_system_type", repo_dic['periodicity'])
backend.addValue("repository_xc_treatment", repo_dic['H_types'])
if repoSectUri:
backend.closeContext(repoSectUri)
......@@ -57,14 +55,14 @@ def main():
calcUri,
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(sys.stdin)
#dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut1.txt", 'r'))
while True:
inputDict=dictReader.readNextDict()
if inputDict is None:
break
calculateTags(inputDict,backend, calcUri)
calculateTags(inputDict, backend, calcUri)
backend.finishedParsingSession("ParseSuccess", None)
sys.stdout.flush()
......
#!/bin/bash
for python_file in NomadRepositoryParser/python/nomadrepo/core/settings.py NomadRepositoryParser/python/nomadrepo/core/symmetry.py
do
2to3 -w $python_file
done
import setup_paths_repo
import os.path, sys, json
from nomadrepo.core.api import API
base_path = os.path.abspath(os.path.dirname(__file__))
inp_str = "".join(sys.argv[1:])
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__)
#!/bin/bash
source $1/bin/activate
python $2/extract_from_repo.py $3
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/"))
#repoParserCoreDir = os.path.normpath(os.path.join(baseDir,"NomadRepositoryParser/python/nomadrepo/core/"))
#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)
#if not repoParserCoreDir in sys.path:
# sys.path.insert(0, repoParserCoreDir)
#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)
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