diff --git a/normalizer/normalizer-repo-tags/calculate_repo_tags.py b/normalizer/normalizer-repo-tags/calculate_repo_tags.py index 5f501667fbdff0d4f2d160b0b2a8bfea27b60f00..59b6c295b3a0d5ca7224c848b40044d5e1b9f8b0 100644 --- a/normalizer/normalizer-repo-tags/calculate_repo_tags.py +++ b/normalizer/normalizer-repo-tags/calculate_repo_tags.py @@ -20,7 +20,7 @@ def calculateTags(inputDict, backend, calcUri): 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']) @@ -55,8 +55,8 @@ 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/scalaOut2.txt", 'r')) + dictReader=ParseStreamedDicts(sys.stdin) + #dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut2.txt", 'r')) while True: inputDict=dictReader.readNextDict() diff --git a/normalizer/normalizer-repo-tags/extract_from_repo.py b/normalizer/normalizer-repo-tags/extract_from_repo.py index b1375f56d8f4076726990137ebd4aae52954e995..989f398b502e078398650e945ba511d609a73c4a 100644 --- a/normalizer/normalizer-repo-tags/extract_from_repo.py +++ b/normalizer/normalizer-repo-tags/extract_from_repo.py @@ -1,23 +1,27 @@ -#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() -def extract_metadata(dic): +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() + work = API() - for calc, error in work._parse(dic, "normalizerRepo"): + for calc, error in work._parse(dic_in, "normalizerRepo"): calc, error = work.classify(calc) calc.info['oadate'] = None - #calc.info['checksum'] = calc.get_checksum() + calc.info['checksum'] = str(checksum) json.dump(calc.info, sys.__stdout__) pass def main(): + inputStr = sys.stdin.readline() inputDict = json.loads(inputStr) extract_metadata(inputDict)