diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index e21286a407..bbd95f58d8 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -1,26 +1,43 @@ name: Create Caches -on: - workflow_dispatch + +on: workflow_dispatch + jobs: - build: + os_matrix: strategy: matrix: - os: [ ubuntu-latest, macos-12 ] - name: Create Caches on ${{ matrix.os }} conda + os: [ubuntu-latest, macos-latest] + include: + - os: ubuntu-latest + environment-file: environment.yml + default-shell: bash -l {0} + - os: macos-latest + environment-file: environment-mac.yml + default-shell: bash -l {0} + name: Test invoke.py on ${{ matrix.os }} with conda runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.default-shell }} steps: - - name: Set platform variables - id: vars - run: | - if [ "$RUNNER_OS" = "macOS" ]; then - echo "::set-output name=ENV_FILE::environment-mac.yml" - echo "::set-output name=PYTHON_BIN::/usr/local/miniconda/envs/ldm/bin/python" - elif [ "$RUNNER_OS" = "Linux" ]; then - echo "::set-output name=ENV_FILE::environment.yml" - echo "::set-output name=PYTHON_BIN::/usr/share/miniconda/envs/ldm/bin/python" - fi - name: Checkout sources uses: actions/checkout@v3 + + - name: setup miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-activate-base: false + auto-update-conda: false + miniconda-version: latest + + - name: set environment + run: | + [[ "$GITHUB_REF" == 'refs/heads/main' ]] \ + && echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV \ + || echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV + echo "CONDA_ROOT=$CONDA" >> $GITHUB_ENV + echo "CONDA_ENV_NAME=invokeai" >> $GITHUB_ENV + - name: Use Cached Stable Diffusion v1.4 Model id: cache-sd-v1-4 uses: actions/cache@v3 @@ -29,42 +46,52 @@ jobs: with: path: models/ldm/stable-diffusion-v1/model.ckpt key: ${{ env.cache-name }} - restore-keys: | - ${{ env.cache-name }} + restore-keys: ${{ env.cache-name }} + - name: Download Stable Diffusion v1.4 Model if: ${{ steps.cache-sd-v1-4.outputs.cache-hit != 'true' }} run: | - if [ ! -e models/ldm/stable-diffusion-v1 ]; then - mkdir -p models/ldm/stable-diffusion-v1 - fi - if [ ! -e models/ldm/stable-diffusion-v1/model.ckpt ]; then - curl -o models/ldm/stable-diffusion-v1/model.ckpt ${{ secrets.SD_V1_4_URL }} - fi - - name: Use Cached Dependencies - id: cache-conda-env-ldm + [[ -d models/ldm/stable-diffusion-v1 ]] \ + || mkdir -p models/ldm/stable-diffusion-v1 + [[ -r models/ldm/stable-diffusion-v1/model.ckpt ]] \ + || curl -o models/ldm/stable-diffusion-v1/model.ckpt ${{ secrets.SD_V1_4_URL }} + + - name: Use cached Conda Environment uses: actions/cache@v3 env: - cache-name: cache-conda-env-ldm + cache-name: cache-conda-env-${{ env.CONDA_ENV_NAME }} + conda-env-file: ${{ matrix.environment-file }} with: - path: ~/.conda/envs/ldm + path: ${{ env.CONDA_ROOT }}/envs/${{ env.CONDA_ENV_NAME }} key: ${{ env.cache-name }} - restore-keys: | - ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(steps.vars.outputs.ENV_FILE) }} - - name: Install Dependencies - if: ${{ steps.cache-conda-env-ldm.outputs.cache-hit != 'true' }} - run: | - conda env create -f ${{ steps.vars.outputs.ENV_FILE }} - - name: Use Cached Huggingface and Torch models - id: cache-huggingface-torch + restore-keys: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }} + + - name: Use cached Conda Packages uses: actions/cache@v3 env: - cache-name: cache-huggingface-torch + cache-name: cache-conda-env-${{ env.CONDA_ENV_NAME }} + conda-env-file: ${{ matrix.environment-file }} + with: + path: ${{ env.CONDA_PKGS_DIR }} + key: ${{ env.cache-name }} + restore-keys: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }} + + - name: Activate Conda Env + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: ${{ env.CONDA_ENV_NAME }} + environment-file: ${{ matrix.environment-file }} + + - name: Use Cached Huggingface and Torch models + id: cache-hugginface-torch + uses: actions/cache@v3 + env: + cache-name: cache-hugginface-torch with: path: ~/.cache key: ${{ env.cache-name }} restore-keys: | ${{ env.cache-name }}-${{ hashFiles('scripts/preload_models.py') }} - - name: Download Huggingface and Torch models - if: ${{ steps.cache-huggingface-torch.outputs.cache-hit != 'true' }} - run: | - ${{ steps.vars.outputs.PYTHON_BIN }} scripts/preload_models.py + + - name: run preload_models.py + run: python scripts/preload_models.py diff --git a/.github/workflows/mkdocs-material.yml b/.github/workflows/mkdocs-material.yml new file mode 100644 index 0000000000..8d3c262e47 --- /dev/null +++ b/.github/workflows/mkdocs-material.yml @@ -0,0 +1,40 @@ +name: mkdocs-material +on: + push: + branches: + - 'main' + - 'development' + +jobs: + mkdocs-material: + runs-on: ubuntu-latest + steps: + - name: checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: setup python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: install requirements + run: | + python -m \ + pip install -r requirements-mkdocs.txt + + - name: confirm buildability + run: | + python -m \ + mkdocs build \ + --clean \ + --verbose + + - name: deploy to gh-pages + if: ${{ github.ref == 'refs/heads/main' }} + run: | + python -m \ + mkdocs gh-deploy \ + --clean \ + --force diff --git a/.github/workflows/test-invoke-conda.yml b/.github/workflows/test-invoke-conda.yml index b5314cfd6b..e2643facfa 100644 --- a/.github/workflows/test-invoke-conda.yml +++ b/.github/workflows/test-invoke-conda.yml @@ -4,29 +4,55 @@ on: branches: - 'main' - 'development' + - 'fix-gh-actions-fork' + pull_request: + branches: + - 'main' + - 'development' + jobs: os_matrix: strategy: matrix: - os: [ ubuntu-latest, macos-12 ] + os: [ubuntu-latest, macos-latest] + include: + - os: ubuntu-latest + environment-file: environment.yml + default-shell: bash -l {0} + - os: macos-latest + environment-file: environment-mac.yml + default-shell: bash -l {0} name: Test invoke.py on ${{ matrix.os }} with conda runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.default-shell }} steps: - - run: | - echo The PR was merged - - name: Set platform variables - id: vars - run: | - # Note, can't "activate" via github action; specifying the env's python has the same effect - if [ "$RUNNER_OS" = "macOS" ]; then - echo "::set-output name=ENV_FILE::environment-mac.yml" - echo "::set-output name=PYTHON_BIN::/usr/local/miniconda/envs/ldm/bin/python" - elif [ "$RUNNER_OS" = "Linux" ]; then - echo "::set-output name=ENV_FILE::environment.yml" - echo "::set-output name=PYTHON_BIN::/usr/share/miniconda/envs/ldm/bin/python" - fi - name: Checkout sources uses: actions/checkout@v3 + + - name: setup miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-activate-base: false + auto-update-conda: false + miniconda-version: latest + + - name: set test prompt to main branch validation + if: ${{ github.ref == 'refs/heads/main' }} + run: echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV + + - name: set test prompt to development branch validation + if: ${{ github.ref == 'refs/heads/development' }} + run: echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV + + - name: set test prompt to Pull Request validation + if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }} + run: echo "TEST_PROMPTS=tests/pr_prompt.txt" >> $GITHUB_ENV + + - name: set conda environment name + run: echo "CONDA_ENV_NAME=invokeai" >> $GITHUB_ENV + - name: Use Cached Stable Diffusion v1.4 Model id: cache-sd-v1-4 uses: actions/cache@v3 @@ -35,31 +61,40 @@ jobs: with: path: models/ldm/stable-diffusion-v1/model.ckpt key: ${{ env.cache-name }} - restore-keys: | - ${{ env.cache-name }} + restore-keys: ${{ env.cache-name }} + - name: Download Stable Diffusion v1.4 Model if: ${{ steps.cache-sd-v1-4.outputs.cache-hit != 'true' }} run: | - if [ ! -e models/ldm/stable-diffusion-v1 ]; then - mkdir -p models/ldm/stable-diffusion-v1 - fi - if [ ! -e models/ldm/stable-diffusion-v1/model.ckpt ]; then - curl -o models/ldm/stable-diffusion-v1/model.ckpt ${{ secrets.SD_V1_4_URL }} - fi - - name: Use Cached Dependencies - id: cache-conda-env-ldm + [[ -d models/ldm/stable-diffusion-v1 ]] \ + || mkdir -p models/ldm/stable-diffusion-v1 + [[ -r models/ldm/stable-diffusion-v1/model.ckpt ]] \ + || curl -o models/ldm/stable-diffusion-v1/model.ckpt ${{ secrets.SD_V1_4_URL }} + + - name: Use cached Conda Environment uses: actions/cache@v3 env: - cache-name: cache-conda-env-ldm + cache-name: cache-conda-env-${{ env.CONDA_ENV_NAME }} + conda-env-file: ${{ matrix.environment-file }} with: - path: ~/.conda/envs/ldm - key: ${{ env.cache-name }} - restore-keys: | - ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(steps.vars.outputs.ENV_FILE) }} - - name: Install Dependencies - if: ${{ steps.cache-conda-env-ldm.outputs.cache-hit != 'true' }} - run: | - conda env create -f ${{ steps.vars.outputs.ENV_FILE }} + path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }} + key: env-${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }} + + - name: Use cached Conda Packages + uses: actions/cache@v3 + env: + cache-name: cache-conda-pkgs-${{ env.CONDA_ENV_NAME }} + conda-env-file: ${{ matrix.environment-file }} + with: + path: ${{ env.CONDA_PKGS_DIR }} + key: pkgs-${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }} + + - name: Activate Conda Env + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: ${{ env.CONDA_ENV_NAME }} + environment-file: ${{ matrix.environment-file }} + - name: Use Cached Huggingface and Torch models id: cache-hugginface-torch uses: actions/cache@v3 @@ -70,28 +105,22 @@ jobs: key: ${{ env.cache-name }} restore-keys: | ${{ env.cache-name }}-${{ hashFiles('scripts/preload_models.py') }} - - name: Download Huggingface and Torch models - if: ${{ steps.cache-hugginface-torch.outputs.cache-hit != 'true' }} - run: | - ${{ steps.vars.outputs.PYTHON_BIN }} scripts/preload_models.py -# - name: Run tmate -# uses: mxschmitt/action-tmate@v3 -# timeout-minutes: 30 + + - name: run preload_models.py + run: python scripts/preload_models.py + - name: Run the tests run: | - # Note, can't "activate" via github action; specifying the env's python has the same effect - if [ $(uname) = "Darwin" ]; then - export PYTORCH_ENABLE_MPS_FALLBACK=1 - fi - # Utterly hacky, but I don't know how else to do this - if [[ ${{ github.ref }} == 'refs/heads/master' ]]; then - time ${{ steps.vars.outputs.PYTHON_BIN }} scripts/invoke.py --from_file tests/preflight_prompts.txt - elif [[ ${{ github.ref }} == 'refs/heads/development' ]]; then - time ${{ steps.vars.outputs.PYTHON_BIN }} scripts/invoke.py --from_file tests/dev_prompts.txt - fi + time python scripts/invoke.py \ + --from_file ${{ env.TEST_PROMPTS }} + + - name: export conda env + run: | mkdir -p outputs/img-samples + conda env export --name ${{ env.CONDA_ENV_NAME }} > outputs/img-samples/environment-${{ runner.os }}.yml + - name: Archive results uses: actions/upload-artifact@v3 with: - name: results + name: results_${{ matrix.os }} path: outputs/img-samples