Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ jobs:
# In containers without GPU support, UCX does not work properly since it is configured to work with GPU-support.
# Hence, don't enforce UCX when running these tests.
docker exec cuda-quantum bash -c "python3 -m pip install --break-system-packages pandas scipy seaborn h5py contfrac"
docker exec cuda-quantum bash -c "sudo apt install -y python3-venv"
(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
docker cp cuda-quantum:"/tmp/validation.out" /tmp/validation.out
docker stop cuda-quantum
Expand Down
26 changes: 23 additions & 3 deletions docs/notebook_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,33 @@ def read_available_backends():
return [backend.strip() for backend in available_backends]


# Following pattern matches
# set_target("abc")
# set_target( "abc")
# set_target("abc", option="xyz")
# set_target("abc", option = "xyz")
# set_target(\"abc\")
# set_target( \"abc\")
# set_target(\"abc\", option=\"xyz\")
# set_target(\"abc\", option = \"xyz\")
# set_target('abc')
# set_target( 'abc')
# set_target('abc', option='xyz')
# set_target('abc', option = 'xyz')
pattern = r"set_target\(\s*(\\?['\"])([^'\"]+)\1(?:\s*,\s*option\s*=\s*(\\?['\"])([^'\"]+)\3)?\)"


def validate(notebook_filename, available_backends):
with open(notebook_filename) as f:
lines = f.readlines()
for notebook_content in lines:
match = re.search('set_target[\\\s\(]+"(.+)\\\\"[)]', notebook_content)
if match and (match.group(1) not in available_backends):
return False
if re.search(r'\s*\#', notebook_content):
continue

match = re.search(pattern, notebook_content)
if match:
target = match.group(2)
return target in available_backends
for notebook_content in lines:
match = re.search('--target ([^ ]+)', notebook_content)
if match and (match.group(1) not in available_backends):
Expand Down

Large diffs are not rendered by default.

Loading