harishaseebat92 commited on
Commit
8d2a3b3
·
1 Parent(s): 021d346

Fix: Correct aqc_venv path for Docker environment

Browse files
Dockerfile CHANGED
@@ -46,7 +46,7 @@ COPY --chown=user:user . .
46
  COPY docker/nginx.conf /etc/nginx/nginx.conf
47
 
48
  # ---------------------------------------------------------------------------
49
- # [NEW] Create the 'aqc_venv' and install dependencies exactly as requested
50
  # ---------------------------------------------------------------------------
51
  RUN python3 -m venv utils/aqc_venv && \
52
  # 1. Upgrade pip inside the new venv
@@ -56,10 +56,14 @@ RUN python3 -m venv utils/aqc_venv && \
56
  git clone https://github.com/bjader/aqc-research.git && \
57
  # 3. Install aqc-research into the venv
58
  ../utils/aqc_venv/bin/pip install ./aqc-research && \
59
- # # 4. Remove the cloned folder
60
- # rm -rf aqc-research && \
61
  # 5. Install adapt-aqc (editable mode) into the venv
62
- ../utils/aqc_venv/bin/pip install -e ./adapt-aqc
 
 
 
 
63
 
64
  # Prepare writable directories for nginx (running as non-root later)
65
  RUN mkdir -p /tmp/nginx/body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi \
 
46
  COPY docker/nginx.conf /etc/nginx/nginx.conf
47
 
48
  # ---------------------------------------------------------------------------
49
+ # Create the 'aqc_venv' and install dependencies
50
  # ---------------------------------------------------------------------------
51
  RUN python3 -m venv utils/aqc_venv && \
52
  # 1. Upgrade pip inside the new venv
 
56
  git clone https://github.com/bjader/aqc-research.git && \
57
  # 3. Install aqc-research into the venv
58
  ../utils/aqc_venv/bin/pip install ./aqc-research && \
59
+ # 4. Remove the cloned folder (optional - you can keep it for debugging)
60
+ rm -rf aqc-research && \
61
  # 5. Install adapt-aqc (editable mode) into the venv
62
+ ../utils/aqc_venv/bin/pip install -e ./adapt-aqc && \
63
+ # 6. VERIFY: Print the Python path to confirm it exists
64
+ echo "=== Verifying aqc_venv installation ===" && \
65
+ ls -la /home/user/app/utils/aqc_venv/bin/ && \
66
+ /home/user/app/utils/aqc_venv/bin/python --version
67
 
68
  # Prepare writable directories for nginx (running as non-root later)
69
  RUN mkdir -p /tmp/nginx/body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi \
utils/EBU_Quantum/no_body/base_functions.py CHANGED
@@ -682,28 +682,31 @@ from pathlib import Path
682
  from qiskit import QuantumCircuit
683
  from qiskit.qasm3 import dumps, loads
684
 
685
- # --- Dynamic Path Detection ---
686
- # This file is at: .../utils/EBU_Quantum/no_body/base_functions.py
687
- # We need to find: .../utils/aqc_venv/
688
- CURRENT_FILE = Path(__file__).resolve()
689
-
690
- # Go up to the 'utils' directory (3 levels: base_functions.py -> no_body -> EBU_Quantum -> utils)
691
- UTILS_DIR = CURRENT_FILE.parents[2]
692
-
693
- # Define the path to the virtual environment python executable
694
- VENV_DIR = UTILS_DIR / "aqc_venv"
695
 
696
  if sys.platform == "win32":
697
- ADAPT_PYTHON = str(VENV_DIR / "Scripts" / "python.exe")
 
 
 
 
698
  else:
699
- ADAPT_PYTHON = str(VENV_DIR / "bin" / "python")
 
 
 
 
700
 
701
- # Debug: Print the path to help troubleshoot
702
- print(f"DEBUG: ADAPT_PYTHON path = {ADAPT_PYTHON}")
703
- print(f"DEBUG: VENV exists = {VENV_DIR.exists()}")
704
 
705
- # 3. Define the module path
706
- ADAPT_MODULE = "quantum.utils.EBU_Quantum.no_body.run_adapt_aqc"
 
707
 
708
  def generate_optimized_circuit(qc: QuantumCircuit) -> QuantumCircuit:
709
  """
@@ -743,9 +746,7 @@ sys.stdout.write(dumps(qc_opt))
743
  """
744
 
745
  # Launch subprocess, pipe in QASM3 string
746
- # We set cwd to the project root (parent of utils) so imports work correctly
747
- # UTILS_DIR is .../utils, so UTILS_DIR.parent is the project root (e.g., /home/user/app)
748
- PROJECT_ROOT = UTILS_DIR.parent
749
  proc = subprocess.run(
750
  [ADAPT_PYTHON, "-c", code],
751
  input=qasm_str,
@@ -768,4 +769,4 @@ sys.stdout.write(dumps(qc_opt))
768
  print(proc.stdout[:500])
769
  raise e
770
 
771
- return qc_opt
 
682
  from qiskit import QuantumCircuit
683
  from qiskit.qasm3 import dumps, loads
684
 
685
+ # -----------------------------------------------------------------------------
686
+ # Dynamic path detection for the virtual environment
687
+ # -----------------------------------------------------------------------------
688
+ # This file is at: quantum/utils/EBU_Quantum/no_body/base_functions.py
689
+ # We need to find: quantum/utils/aqc_venv/
 
 
 
 
 
690
 
691
  if sys.platform == "win32":
692
+ # Local Windows Development
693
+ # Go up from: utils/EBU_Quantum/no_body/ -> utils/
694
+ current_dir = Path(__file__).parent.resolve()
695
+ utils_dir = current_dir.parents[1] # no_body -> EBU_Quantum -> utils
696
+ ADAPT_PYTHON = utils_dir / "aqc_venv" / "Scripts" / "python.exe"
697
  else:
698
+ # Docker / Linux Production
699
+ # In Docker, WORKDIR is /home/user/app
700
+ # The venv is created at /home/user/app/utils/aqc_venv
701
+ # Use absolute path to be safe
702
+ ADAPT_PYTHON = Path("/home/user/app/utils/aqc_venv/bin/python")
703
 
704
+ # Convert to string for subprocess
705
+ ADAPT_PYTHON = str(ADAPT_PYTHON)
 
706
 
707
+ # Debug: Print the path (will appear in container logs)
708
+ print(f"[DEBUG] ADAPT_PYTHON path: {ADAPT_PYTHON}")
709
+ print(f"[DEBUG] ADAPT_PYTHON exists: {Path(ADAPT_PYTHON).exists()}")
710
 
711
  def generate_optimized_circuit(qc: QuantumCircuit) -> QuantumCircuit:
712
  """
 
746
  """
747
 
748
  # Launch subprocess, pipe in QASM3 string
749
+ # We set cwd to PROJECT_ROOT so imports like 'quantum.utils...' work correctly
 
 
750
  proc = subprocess.run(
751
  [ADAPT_PYTHON, "-c", code],
752
  input=qasm_str,
 
769
  print(proc.stdout[:500])
770
  raise e
771
 
772
+ return qc_opt