Commit 2b46db58 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding python remote acc set credentials feature, fixing failing test linkage



Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 8f144f42
......@@ -36,7 +36,6 @@ endif()
include(ExternalProject)
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
......@@ -66,12 +65,9 @@ message(STATUS "${BoldGreen}Installing XACC to ${CMAKE_install_PREFIX}. Override
if (XACC_BUILD_TESTS)
enable_testing()
macro(add_xacc_test _TEST_NAME)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -fno-stack-protector")
set(XACC_LIBRARIES "${CMAKE_BINARY_DIR}/quantum/gate/libxacc-quantum-gate.dylib")
add_executable(${_TEST_NAME}Tester ${_TEST_NAME}Tester.cpp)
add_test(NAME xacc_${_TEST_NAME}Tester COMMAND ${_TEST_NAME}Tester)
target_link_libraries(${_TEST_NAME}Tester ${GTEST_LIBRARIES} xacc xacc-quantum-gate) #xacc-quantum-gate xacc-quantum-aqc)
target_link_libraries(${_TEST_NAME}Tester ${GTEST_LIBRARIES} xacc xacc-quantum-gate xacc-quantum-aqc)
endmacro()
macro(set_cache_variable VAR_NAME VAR_DESCRIPTION)
......
from _pyxacc import *
import os, platform
import os, platform, sys
import argparse
def parse_args(args):
parser = argparse.ArgumentParser(description="XACC Framework Utility.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
fromfile_prefix_chars='@')
parser.add_argument("-c", "--set-credentials", type=str, help="Set your credentials for any of the remote Accelerators.", required=False)
parser.add_argument("-k", "--api-key", type=str, help="The API key for the remote Accelerators.", required=False)
parser.add_argument("-u", "--user-id", type=str, help="The User Id for the remote Accelerators.", required=False)
parser.add_argument("--url", type=str, help="The URL for the remote Accelerators.", required=False)
parser.add_argument("-L", "--location", action='store_true', help="Print the path to the XACC install location.", required=False)
parser.add_argument("-b", "--branch", default='master',type=str, help="Print the path to the XACC install location.", required=False)
opts = parser.parse_args(args)
if opts.set_credentials and not opts.api_key:
print('Error in arg input, must supply api-key if setting credentials')
sys.exit(1)
return opts
def initialize():
xaccHome = os.environ['HOME']+'/.xacc'
......@@ -33,4 +52,42 @@ def initialize():
file.write(contents)
file.close()
def setCredentials(opts):
defaultUrls = {'ibm':'https://quantumexperience.ng.bluemix.net','rigetti':'https://api.rigetti.com/qvm'}
acc = opts.set_credentials
url = opts.url if not opts.url == None else defaultUrls[acc]
if acc == 'rigetti' and not os.path.exists(os.environ['HOME']+'/.pyquil_config'):
apikey = opts.api_key
if opts.user_id == None:
print('Error, must provide user-id for Rigetti accelerator')
sys.exit(1)
user = opts.user_id
f = open(os.environ['HOME']+'/.pyquil_config','w')
f.write('key: ' + apikey + '\n')
f.write('user-id: ' + user + '\n')
f.write('url: ' + url + '\n')
f.close()
else:
if not os.path.exists(os.environ['HOME']+'/.'+acc+'_config'):
f = open(os.environ['HOME']+'/.'+acc+'_config','w')
f.write('key: '+ opts.api_key + '\n')
f.write('url: '+ url + '\n')
f.close()
fname = acc if 'rigetti' not in acc else 'pyquil'
print('\nCreated '+acc+' config file:\n$ cat ~/.'+fname+'_config:')
print(open(os.environ['HOME']+'/.'+fname+'_config','r').read())
def main(argv=None):
opts = parse_args(sys.argv[1:])
xaccLocation = os.path.dirname(os.path.realpath(__file__))
if opts.location:
print(xaccLocation)
sys.exit(0)
if not opts.set_credentials == None:
setCredentials(opts)
initialize()
if __name__ == "__main__":
sys.exit(main())
......@@ -28,4 +28,4 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog)
include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
add_subdirectory(gate)
#add_subdirectory(aqc)
add_subdirectory(aqc)
......@@ -36,12 +36,12 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
US_BUNDLE_NAME ${_bundle_name}
)
if(BUILD_SHARED_LIBS)
set_target_properties(${LIBRARY_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1
)
endif()
#if(BUILD_SHARED_LIBS)
# set_target_properties(${LIBRARY_NAME} PROPERTIES
# CXX_VISIBILITY_PRESET hidden
# VISIBILITY_INLINES_HIDDEN 1
# )
#endif()
# Embed meta-data from a manifest.json file
usFunctionEmbedResources(TARGET ${LIBRARY_NAME}
......@@ -51,10 +51,7 @@ usFunctionEmbedResources(TARGET ${LIBRARY_NAME}
manifest.json
)
#set(BOOST_ROOT ${CMAKE_INSTALL_PREFIX})
#find_package(Boost COMPONENTS system program_options filesystem chrono regex graph REQUIRED)
target_link_libraries(${LIBRARY_NAME} PUBLIC CppMicroServices xacc ${Boost_LIBRARIES})
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc)
if(APPLE)
set_target_properties(xacc-quantum-aqc PROPERTIES INSTALL_RPATH "@loader_path")
......
......@@ -38,12 +38,12 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
US_BUNDLE_NAME ${_bundle_name}
)
if(BUILD_SHARED_LIBS)
set_target_properties(${LIBRARY_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1
)
endif()
#if(BUILD_SHARED_LIBS)
# set_target_properties(${LIBRARY_NAME} PROPERTIES
# CXX_VISIBILITY_PRESET hidden
# VISIBILITY_INLINES_HIDDEN 1
# )
#endif()
# Embed meta-data from a manifest.json file
usFunctionEmbedResources(TARGET ${LIBRARY_NAME}
......
......@@ -2,14 +2,14 @@ add_xacc_test(CNOT)
add_xacc_test(CPhase)
add_xacc_test(ConditionalFunction)
add_xacc_test(GateFunction)
#add_xacc_test(GateIR)
add_xacc_test(GateIR)
add_xacc_test(GateVisitor)
add_xacc_test(Hadamard)
#add_xacc_test(InverseQFT)
#add_xacc_test(QFT)
add_xacc_test(InverseQFT)
add_xacc_test(QFT)
add_xacc_test(Measure)
#add_xacc_test(QubitMapIRPreprocessor)
#add_xacc_test(ReadoutErrorIRPreprocessor)
add_xacc_test(QubitMapIRPreprocessor)
add_xacc_test(ReadoutErrorIRPreprocessor)
add_xacc_test(Rx)
add_xacc_test(Ry)
add_xacc_test(Rz)
......
Supports Markdown
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