bluesky / hklpy

Diffractometer computation library with ophyd pseudopositioner support
https://blueskyproject.io/hklpy
BSD 3-Clause "New" or "Revised" License
2 stars 11 forks source link

Run a tiled server in the testing workflow #294

Closed prjemian closed 8 months ago

prjemian commented 8 months ago

Still need to run a tiled server in the testing workflow, then refactor to databroker v2. So this PR is in draft mode ATM.

Originally posted by @prjemian in https://github.com/bluesky/hklpy/issues/284#issuecomment-1791026416

Tasks

prjemian commented 8 months ago

At least two options for MongoDB server action:

prjemian commented 8 months ago

Code examples from both show the same action:

    - name: Start MongoDB
      uses: supercharge/mongodb-github-action@1.10.0
      with:
        mongodb-version: ${{ matrix.mongodb-version }}

The second one has gone EOL. So only one action now...

prjemian commented 8 months ago

Run tiled server in docker container.

docker pull ghcr.io/bluesky/tiled:main
prjemian commented 8 months ago

Good advice:

Some of the examples below set an environment variable TILED_SINGLE_USER_API_KEY to secret, as a placeholder. For actual use, use a difficult-to-guess secret. Two equally good ways to generate a secure secret...

With openssl:

openssl rand -hex 32

With python:

python -c "import secrets; print(secrets.token_hex(32))"
prjemian commented 8 months ago

Start tiled server:

docker run \
  -p 8000:8000 \
  -e TILED_SINGLE_USER_API_KEY=secret \
  ghcr.io/bluesky/tiled:latest
prjemian commented 8 months ago

The tests are the first items to reconfigure:

(bluesky_2023_3) prjemian@arf:~/.../Bluesky/hklpy$ git grep insert | grep subscribe
docs/source/examples/notebooks/geo_e4cv.ipynb:    "RE.subscribe(db.insert)\n",
docs/source/examples/notebooks/geo_e6c.ipynb:    "RE.subscribe(db.insert)\n",
docs/source/examples/notebooks/geo_k4cv.ipynb:    "RE.subscribe(db.insert)\n",
docs/source/examples/notebooks/tst_UB_in_descriptor_document.ipynb:    "RE.subscribe(cat.v1.insert)\n",
docs/source/examples/notebooks/tst_UB_in_stream.ipynb:    "RE.subscribe(cat.v1.insert)\n",
hkl/tests/test_save_restore_UB.py:    engine.subscribe(cat.v1.insert)
hkl/tests/test_util.py:    engine.subscribe(cat.v1.insert)
prjemian commented 8 months ago

Interestingly, tests run successfully without making a change to subscribe() with databroker v2.0.0b30.

prjemian commented 8 months ago

Not necessary for PR #284.