diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 02e4daa..f747b2e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,50 +10,50 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.12] fail-fast: false steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - # These packages are installed in the base environment but may be older - # versions. Explicitly upgrade them because they often create - # installation problems if out of date. - python -m pip install --upgrade pip setuptools numpy - - pip install . - pip install -r requirements-dev.txt - pip install -r requirements-agents.txt - pip list - - - name: Build Docs - run: | - make -C docs/ html - - - name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo - run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV - - - name: Upload built docs as artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.REPOSITORY_NAME }}-docs - path: docs/build/html - - - name: Deploy documentation to blueskyproject.io. - if: github.repository_owner == 'bluesky' && github.ref_name == 'main' - # We pin to the SHA, not the tag, for security reasons. - # https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 - with: - deploy_key: ${{ secrets.ACTIONS_DOCUMENTATION_DEPLOY_KEY }} - publish_branch: master - publish_dir: ./docs/build/html - external_repository: bluesky/bluesky.github.io - destination_dir: ${{ env.REPOSITORY_NAME }} # just the repo name, without the "bluesky/" - keep_files: true # Keep old files. - force_orphan: false # Keep git history. + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + # These packages are installed in the base environment but may be older + # versions. Explicitly upgrade them because they often create + # installation problems if out of date. + python -m pip install --upgrade pip setuptools numpy + + pip install . + pip install -r requirements-dev.txt + pip install -r requirements-agents.txt + pip list + + - name: Build Docs + run: | + make -C docs/ html + + - name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo + run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + + - name: Upload built docs as artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.REPOSITORY_NAME }}-docs + path: docs/build/html + + - name: Deploy documentation to blueskyproject.io. + if: github.repository_owner == 'bluesky' && github.ref_name == 'main' + # We pin to the SHA, not the tag, for security reasons. + # https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions + uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 + with: + deploy_key: ${{ secrets.ACTIONS_DOCUMENTATION_DEPLOY_KEY }} + publish_branch: master + publish_dir: ./docs/build/html + external_repository: bluesky/bluesky.github.io + destination_dir: ${{ env.REPOSITORY_NAME }} # just the repo name, without the "bluesky/" + keep_files: true # Keep old files. + force_orphan: false # Keep git history. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3862262..76a105c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,85 +7,89 @@ on: - main workflow_dispatch: schedule: - - cron: '0 0 * * 0' # weekly + - cron: "0 0 * * 0" # weekly jobs: unit-tests: runs-on: ubuntu-latest strategy: - matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] - fail-fast: false + fail-fast: false steps: - - uses: actions/checkout@v4 - - - name: Download and build bluesky-pods - run: | - docker pull ghcr.io/bluesky/bluesky-pods-bluesky:main - docker tag ghcr.io/bluesky/bluesky-pods-bluesky:main bluesky:latest - - - name: Start Bluesky containers - run: | - pushd bluesky_adaptive/tests/podman - docker-compose up -d - popd - - - name: Log which containers are running - run: docker ps -a - - - name: Check container status and fetch logs if any failed - run: | - failed_containers=() - while read -r container; do - status=$(docker inspect --format='{{.State.Status}}' "$container") - if [ "$status" != "running" ]; then - echo "::error ::Container $container has status $status" - failed_containers+=("$container") + - uses: actions/checkout@v4 + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Download and build bluesky-pods + run: | + docker pull ghcr.io/bluesky/bluesky-pods-bluesky:main + docker tag ghcr.io/bluesky/bluesky-pods-bluesky:main bluesky:latest + + - name: Start Bluesky containers + run: | + pushd bluesky_adaptive/tests/podman + docker-compose up -d + popd + + - name: Log which containers are running + run: docker ps -a + + - name: Check container status and fetch logs if any failed + run: | + failed_containers=() + while read -r container; do + status=$(docker inspect --format='{{.State.Status}}' "$container") + if [ "$status" != "running" ]; then + echo "::error ::Container $container has status $status" + failed_containers+=("$container") + fi + done < <(docker ps -aq) + + for container in "${failed_containers[@]}"; do + echo "Logs for $container:" + docker logs "$container" + done + + if [ ${#failed_containers[@]} -ne 0 ]; then + echo "::error ::Some containers failed to start" + docker ps -a + exit 1 fi - done < <(docker ps -aq) - - for container in "${failed_containers[@]}"; do - echo "Logs for $container:" - docker logs "$container" - done - - if [ ${#failed_containers[@]} -ne 0 ]; then - echo "::error ::Some containers failed to start" - docker ps -a - exit 1 - fi - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install - shell: bash -l {0} - run: | - set -vxeuo pipefail - pip install --upgrade pip wheel - pip install . - pip install -r requirements-dev.txt - pip install -r requirements-agents.txt - mkdir -p /home/runner/.config/tiled/profiles - cp ./bluesky_adaptive/tests/podman/tiled_client_config.yml /home/runner/.config/tiled/profiles/tiled_client_config.yml - pip list - - - name: Reload Permissions for QServer (Ensures plans are available) - shell: bash -l {0} - run: | - set -vxeuo pipefail - qserver environment open - qserver permissions reload - - - name: Test with pytest - shell: bash -l {0} - run: | - set -vxeuo pipefail - coverage run -m pytest -v - coverage report + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install + shell: bash -l {0} + run: | + set -vxeuo pipefail + pip install --upgrade pip wheel + pip install . + pip install -r requirements-dev.txt + pip install -r requirements-agents.txt + mkdir -p /home/runner/.config/tiled/profiles + cp ./bluesky_adaptive/tests/podman/tiled_client_config.yml /home/runner/.config/tiled/profiles/tiled_client_config.yml + pip list + + - name: Reload Permissions for QServer (Ensures plans are available) + shell: bash -l {0} + run: | + set -vxeuo pipefail + qserver environment open + qserver permissions reload + + - name: Test with pytest + shell: bash -l {0} + run: | + set -vxeuo pipefail + coverage run -m pytest -v + coverage report diff --git a/bluesky_adaptive/tests/test_botorch_agents.py b/bluesky_adaptive/tests/test_botorch_agents.py index 93860de..dff4596 100644 --- a/bluesky_adaptive/tests/test_botorch_agents.py +++ b/bluesky_adaptive/tests/test_botorch_agents.py @@ -72,8 +72,10 @@ def test_remodel_from_report(catalog): partial_acq_function=lambda gp: UpperConfidenceBound(gp, beta=1.5), ) acqf, gp = new_agent.remodel_from_report(catalog[agent_uid]) - assert ( - gp.get_parameter("covar_module.base_kernel.raw_lengthscale") - == agent.surrogate_model.get_parameter("covar_module.base_kernel.raw_lengthscale") - ).all() + try: + param = gp.get_parameter("covar_module.base_kernel.raw_lengthscale") + assert (param == agent.surrogate_model.get_parameter("covar_module.base_kernel.raw_lengthscale")).all() + except AttributeError: + param = gp.get_parameter("covar_module.raw_lengthscale") + assert (param == agent.surrogate_model.get_parameter("covar_module.raw_lengthscale")).all() assert acqf.beta == 0.1 diff --git a/bluesky_adaptive/tests/test_communication.py b/bluesky_adaptive/tests/test_communication.py index de505c9..6ea1397 100644 --- a/bluesky_adaptive/tests/test_communication.py +++ b/bluesky_adaptive/tests/test_communication.py @@ -1,4 +1,4 @@ -""""Testing the communication patterns of Bluesky Adatptive Async Agents""" +"""Testing the communication patterns of Bluesky Adaptive Async Agents""" from typing import Sequence, Tuple, Union diff --git a/requirements.txt b/requirements.txt index b19b8ef..b1853bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,6 @@ tiled[client] numpy pydantic -databroker @ git+https://github.com/bluesky/databroker.git@v2.0.0b41#egg=databroker +databroker @ git+https://github.com/bluesky/databroker.git@v2.0.0b56#egg=databroker +bluesky-tiled-plugins +json-rpc