コード例 #1
0
    def get_generated_xAOD(self, a, cache_path: str):
        # Calculate the AST hash. If this is already around then we don't need to do very much!
        hash = ast_hash.calc_ast_hash(a)

        # Next, see if the hash file is there.
        query_file_path = os.path.join(cache_path, hash)
        cache_file = os.path.join(query_file_path, 'rep_cache.pickle')
        if os.path.isfile(cache_file):
            # We have a cache hit. Look it up.
            file = find_dataset(a)
            with open(cache_file, 'rb') as f:
                result_cache = pickle.load(f)
                return result_cache, extract_dataset_info(file)

        # Create the files to run in that location.
        if not os.path.exists(query_file_path):
            os.makedirs(query_file_path)

        exe = atlas_xaod_executor()
        print("------>", exe)
        f_spec = exe.write_cpp_files(exe.apply_ast_transformations(a), query_file_path)
        print(f_spec)

        os.system("ls -lht " + query_file_path)

        return GeneratedFileResult(hash, query_file_path)
コード例 #2
0
    def get_generated_uproot(self, a, cache_path: str):
        hash = ast_hash.calc_ast_hash(a)
        query_file_path = os.path.join(cache_path, hash)

        # Create the files to run in that location.
        if not os.path.exists(query_file_path):
            os.makedirs(query_file_path)

        src = generate_python_source(a)
        print(query_file_path)
        with open(os.path.join(query_file_path, 'generated_transformer.py'), 'w') as python_file:
            python_file.write(src)

        os.system("ls -lht " + query_file_path)

        return GeneratedFileResult(hash, query_file_path)
コード例 #3
0
ファイル: test_ast_hash.py プロジェクト: iris-hep/func_adl
def test_slightly_different_queries():
    a1 = build_ast_array_1()
    a2 = build_ast_array_2()

    assert ast_hash.calc_ast_hash(a1) != ast_hash.calc_ast_hash(a2)
コード例 #4
0
ファイル: test_ast_hash.py プロジェクト: iris-hep/func_adl
def test_ast_hash_works():
    a = build_ast()
    h = ast_hash.calc_ast_hash(a)
    assert h is not None
コード例 #5
0
def test_slightly_different_queries():
    a1 = build_ast_array_1('file://root1.root')
    a2 = build_ast_array_2('file://root1.root')

    assert ast_hash.calc_ast_hash(a1) != ast_hash.calc_ast_hash(a2)
コード例 #6
0
def test_ast_with_different_files_not_different():
    a1 = build_ast("file://root1.root")
    a2 = build_ast("file://root2.root")
    assert ast_hash.calc_ast_hash(a1) != ast_hash.calc_ast_hash(a2)
コード例 #7
0
def test_ast_hash_works():
    a = build_ast("file://root.root")
    h = ast_hash.calc_ast_hash(a)
    assert h is not None