Skip to content

Commit a54f813

Browse files
huaweil-nvsacpis
andauthored
Improve validate_pycudaq.sh script (#3608)
- Simplify cudaq installation using --find-links instead of pypi-server - Add execution logging for all example and snippet runs - Add API key checks for multiple quantum backends (fermioniq, qci, oqc, nvqc, pasqal, ionq) Signed-off-by: huaweil <[email protected]> Co-authored-by: Sachin Pisal <[email protected]>
1 parent 8b9a8f5 commit a54f813

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

scripts/validate_pycudaq.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ while IFS= read -r line; do
9595
conda_env=$(echo "$line" | sed "s#conda activate##" | tr -d '[:space:]')
9696
source $(conda info --base)/bin/activate $conda_env
9797
if [ -n "${extra_packages}" ]; then
98-
eval "pip install pypiserver"
99-
eval "pypi-server run -p 8080 ${extra_packages} &"
98+
eval "pip install cudaq --find-links ${extra_packages}"
10099
fi
101100
elif [ -n "$(echo $line | tr -d '[:space:]')" ]; then
102101
eval "$line"
@@ -182,6 +181,7 @@ fi
182181
# Some snippets generate plots
183182
python3 -m pip install --user matplotlib
184183
for ex in `find "$root_folder/snippets" -name '*.py' -not -path '*/nvqc/*'`; do
184+
echo "Executing $ex"
185185
python3 "$ex"
186186
if [ ! $? -eq 0 ]; then
187187
echo -e "\e[01;31mFailed to execute $ex.\e[0m" >&2
@@ -190,6 +190,7 @@ for ex in `find "$root_folder/snippets" -name '*.py' -not -path '*/nvqc/*'`; do
190190
done
191191
if [ -n "${NVQC_API_KEY}" ]; then
192192
for ex in `find "$root_folder/snippets" -name '*.py' -path '*/nvqc/*'`; do
193+
echo "Executing $ex"
193194
python3 "$ex"
194195
if [ ! $? -eq 0 ]; then
195196
echo -e "\e[01;31mFailed to execute $ex.\e[0m" >&2
@@ -219,6 +220,7 @@ for ex in `find "$root_folder/examples" -name '*.py'`; do
219220
fi
220221
done
221222
if ! $skip_example; then
223+
echo "Executing $ex"
222224
python3 "$ex"
223225
if [ ! $? -eq 0 ]; then
224226
echo -e "\e[01;31mFailed to execute $ex.\e[0m" >&2
@@ -238,9 +240,28 @@ if [ -d "$root_folder/targets" ]; then
238240
# to submit a (paid) job to Amazon Braket (includes QuEra).
239241
echo -e "\e[01;31mWarning: Explicitly set target braket or quera in $ex; skipping validation due to paid submission.\e[0m" >&2
240242
skip_example=true
243+
elif [ "$t" == "fermioniq" ] && [ -z "${FERMIONIQ_ACCESS_TOKEN_ID}" ]; then
244+
echo -e "\e[01;31mWarning: Explicitly set target fermioniq in $ex; skipping validation due to missing API key.\e[0m" >&2
245+
skip_example=true
246+
elif [ "$t" == "qci" ] && [ -z "${QCI_AUTH_TOKEN}" ]; then
247+
echo -e "\e[01;31mWarning: Explicitly set target qci in $ex; skipping validation due to missing API key.\e[0m" >&2
248+
skip_example=true
249+
elif [ "$t" == "oqc" ] && [ -z "${OQC_URL}" ]; then
250+
echo -e "\e[01;31mWarning: Explicitly set target oqc in $ex; skipping validation due to missing URL.\e[0m" >&2
251+
skip_example=true
252+
elif [ "$t" == "nvqc" ] && [ -z "${NVQC_API_KEY}" ]; then
253+
echo -e "\e[01;31mWarning: Explicitly set target nvqc in $ex; skipping validation due to missing API key.\e[0m" >&2
254+
skip_example=true
255+
elif [ "$t" == "pasqal" ] && [ -z "${PASQAL_PASSWORD}" ]; then
256+
echo -e "\e[01;31mWarning: Explicitly set target pasqal in $ex; skipping validation due to missing token.\e[0m" >&2
257+
skip_example=true
258+
elif [ "$t" == "ionq" ] && [ -z "${IONQ_API_KEY}" ]; then
259+
echo -e "\e[01;31mWarning: Explicitly set target ionq in $ex; skipping validation due to missing API key.\e[0m" >&2
260+
skip_example=true
241261
fi
242262
done
243263
if ! $skip_example; then
264+
echo "Executing $ex"
244265
python3 "$ex"
245266
if [ ! $? -eq 0 ]; then
246267
echo -e "\e[01;31mFailed to execute $ex.\e[0m" >&2

0 commit comments

Comments
 (0)