Skip to content
Snippets Groups Projects
Commit 9a6d0b96 authored by Jungho Shin's avatar Jungho Shin
Browse files

get configuration for repo from setting.json

parent 6b33e8e8
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,8 @@ from nomadcore.parse_streamed_dicts import *
import logging
base_path = os.path.abspath(os.path.dirname(__file__))
## test
with open(base_path+'/setting.json', 'r') as file_conf: repo_conf = json.load(file_conf)
repo_base_path = repo_conf['repo_base_path']
def calculateTags(inputDict, backend, calcUri):
repoSectUri = inputDict.get("section_repository_info.uri")
......@@ -16,12 +17,12 @@ 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 = subprocess.Popen([os.path.join(repo_base_path, 'bin/python'), base_path+'/extract_from_repo.py'], stdin = subprocess.PIPE, stdout = subprocess.PIPE)
inputDict_str = json.dumps(inputDict)+'\n'
repo_dic_sub_out = repo_dic_sub.communicate(inputDict_str.encode('utf-8'))[0]
repo_dic = json.loads(repo_dic_sub_out.decode("utf-8"))
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'])
......
import sys, json
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
def extract_metadata(dic_in):
session = connect_database(settings, None)()
checksum = session.execute("SELECT checksum FROM calculations WHERE calc_id = %d ;" % 4000000).fetchone()[0]
session.commit(); session.close()
#session = connect_database(settings, None)()
#checksum = session.execute("SELECT checksum FROM calculations WHERE calc_id = %d ;" % 4000000).fetchone()[0]
#session.commit(); session.close()
work = API()
for calc, error in work._parse(dic_in, "normalizerRepo"):
calc, error = work.classify(calc)
calc.info['oadate'] = None
calc.info['checksum'] = str(checksum)
#calc.info['checksum'] = calc.get_checksum()
json.dump(calc.info, sys.__stdout__)
pass
......
{'repo_base_path' = '/u/jungho/myscratch/NomadRepositoryParser'}
{"repo_base_path":"/u/jungho/myscratch/NomadRepositoryParser/"}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment