Skip to content

Commit 2f87027

Browse files
authored
Adding venv and fixing regex (#3610)
* adding venv and fix regex Signed-off-by: Sachin Pisal <[email protected]> * adding sudo Signed-off-by: Sachin Pisal <[email protected]> * reverting regex Signed-off-by: Sachin Pisal <[email protected]> * fixing the regex Signed-off-by: Sachin Pisal <[email protected]> * capturing single quotes in regex Signed-off-by: Sachin Pisal <[email protected]> * capture only the target Signed-off-by: Sachin Pisal <[email protected]> * fix regex Signed-off-by: Sachin Pisal <[email protected]> * fixing the regex to combine the target and option as a valid backend Signed-off-by: Sachin Pisal <[email protected]> * adding escape for # Signed-off-by: Sachin Pisal <[email protected]> * format Signed-off-by: Sachin Pisal <[email protected]> * simplifying the condition Signed-off-by: Sachin Pisal <[email protected]> * updating torch version Signed-off-by: Sachin Pisal <[email protected]> * Adding pattern matching examples and fetching only the target, ignoring option Signed-off-by: Sachin Pisal <[email protected]> * updating python3-venv Signed-off-by: Sachin Pisal <[email protected]> * making spellchecker happy Signed-off-by: Sachin Pisal <[email protected]> * skipping logical_aim_sqale and updating pip install for hqnn Signed-off-by: Sachin Pisal <[email protected]> * format Signed-off-by: Sachin Pisal <[email protected]> --------- Signed-off-by: Sachin Pisal <[email protected]>
1 parent 90f0b68 commit 2f87027

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

.github/workflows/docker_images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ jobs:
841841
# In containers without GPU support, UCX does not work properly since it is configured to work with GPU-support.
842842
# Hence, don't enforce UCX when running these tests.
843843
docker exec cuda-quantum bash -c "python3 -m pip install --break-system-packages pandas scipy seaborn h5py contfrac"
844+
docker exec cuda-quantum bash -c "sudo apt install -y python3-venv"
844845
(docker exec cuda-quantum bash -c "unset OMPI_MCA_pml && set -o pipefail && bash validate_container.sh | tee /tmp/validation.out") && passed=true || passed=false
845846
docker cp cuda-quantum:"/tmp/validation.out" /tmp/validation.out
846847
docker stop cuda-quantum

docs/notebook_validation.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,33 @@ def read_available_backends():
2525
return [backend.strip() for backend in available_backends]
2626

2727

28+
# Following pattern matches
29+
# `set_target("abc")`
30+
# `set_target( "abc")`
31+
# `set_target("abc", option="xyz")`
32+
# `set_target("abc", option = "xyz")`
33+
# `set_target(\"abc\")`
34+
# `set_target( \"abc\")`
35+
# `set_target(\"abc\", option=\"xyz\")`
36+
# `set_target(\"abc\", option = \"xyz\")`
37+
# `set_target('abc')`
38+
# `set_target( 'abc')`
39+
# `set_target('abc', option='xyz')`
40+
# `set_target('abc', option = 'xyz')`
41+
pattern = r"set_target\(\s*(\\?['\"])([^'\"]+)\1(?:\s*,\s*option\s*=\s*(\\?['\"])([^'\"]+)\3)?\)"
42+
43+
2844
def validate(notebook_filename, available_backends):
2945
with open(notebook_filename) as f:
3046
lines = f.readlines()
3147
for notebook_content in lines:
32-
match = re.search('set_target[\\\s\(]+"(.+)\\\\"[)]', notebook_content)
33-
if match and (match.group(1) not in available_backends):
34-
return False
48+
if re.search(r'\s*\#', notebook_content):
49+
continue
50+
51+
match = re.search(pattern, notebook_content)
52+
if match:
53+
target = match.group(2)
54+
return target in available_backends
3555
for notebook_content in lines:
3656
match = re.search('--target ([^ ]+)', notebook_content)
3757
if match and (match.group(1) not in available_backends):
@@ -122,7 +142,9 @@ def print_results(success, failed, skipped=[]):
122142

123143
## `quantum_transformer`:
124144
## See: https://github.com/NVIDIA/cuda-quantum/issues/2689
125-
notebooks_skipped = ['quantum_transformer.ipynb']
145+
notebooks_skipped = [
146+
'quantum_transformer.ipynb', 'logical_aim_sqale.ipynb'
147+
]
126148

127149
for notebook_filename in notebook_filenames:
128150
base_name = os.path.basename(notebook_filename)

docs/sphinx/applications/python/hybrid_quantum_neural_networks.ipynb

Lines changed: 8 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)