- name: Create Open WebUI data directory
  file:
    path: "{{ courseware_state_dir }}/open-webui"
    state: directory
    mode: "0755"

- name: Create Open WebUI virtual environment
  command:
    argv:
      - "{{ courseware_python_bin }}"
      - -m
      - venv
      - "{{ courseware_venvs_dir }}/open-webui"
  args:
    creates: "{{ courseware_venvs_dir }}/open-webui/bin/python"

- name: Upgrade Open WebUI venv tooling
  command:
    argv:
      - "{{ courseware_venvs_dir }}/open-webui/bin/python"
      - -m
      - pip
      - install
      - --upgrade
      - pip
      - setuptools
      - wheel

- name: Install Open WebUI
  command:
    argv:
      - "{{ courseware_venvs_dir }}/open-webui/bin/python"
      - -m
      - pip
      - install
      - "{{ courseware_open_webui_spec }}"
      - "numpy<2"

- name: Create Embedding Atlas virtual environment
  command:
    argv:
      - "{{ courseware_python_bin }}"
      - -m
      - venv
      - "{{ courseware_venvs_dir }}/embedding-atlas"
  args:
    creates: "{{ courseware_venvs_dir }}/embedding-atlas/bin/python"

- name: Upgrade Embedding Atlas venv tooling
  command:
    argv:
      - "{{ courseware_venvs_dir }}/embedding-atlas/bin/python"
      - -m
      - pip
      - install
      - --upgrade
      - pip
      - setuptools
      - wheel

- name: Install Embedding Atlas
  command:
    argv:
      - "{{ courseware_venvs_dir }}/embedding-atlas/bin/python"
      - -m
      - pip
      - install
      - "{{ courseware_embedding_atlas_spec }}"
      - "numpy<2"
