Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to use tiled server #252

Open
5 tasks
prjemian opened this issue Nov 7, 2023 · 4 comments
Open
5 tasks

switch to use tiled server #252

prjemian opened this issue Nov 7, 2023 · 4 comments
Assignees
Labels
task routine work
Milestone

Comments

@prjemian
Copy link
Contributor

prjemian commented Nov 7, 2023

As noted in an hklpy issue, we need to switch our catalog reference to use tiled server:

from tiled.client import from_uri

# For security, set the API key by setting env var
# TILED_API_KEY rather than putting it in code.

URI = "http://localhost:8020"
client = from_uri(URI)
cat = client["training"]
RE = RunEngine()
# RE.subscribe(cat.v1.insert)  # the old way
RE.subscribe(cat.post_document)

Tiled docs have advice about creating/storing the API key.

We'll need instructions for routine installation of a tiled server for each instrument, and reconfiguration of the instrument package for this change.

Tasks for unit testing

  • start MongoDB server
  • install database with bluesky catalogs for testing
  • Establish API key
  • start tiled server
  • reconfigure RE.subscribe()
@prjemian prjemian added the task routine work label Nov 7, 2023
@prjemian prjemian added this to the v1.0.2 milestone Nov 7, 2023
@prjemian prjemian self-assigned this Nov 7, 2023
@prjemian
Copy link
Contributor Author

prjemian commented Nov 9, 2023

Follow similar activity in hklpy.

@prjemian
Copy link
Contributor Author

prjemian commented Nov 9, 2023

CI workflow steps:

    - name: Checkout this repository
      uses: actions/checkout@v4

    - name: Start MongoDB
      uses: supercharge/[email protected]

    - name: Start tiled server on host port 8019
      run: |
        docker pull ghcr.io/bluesky/tiled:main
        docker run \
          -d \
          --rm \
          -p 8019:8000 \
          -e TILED_SINGLE_USER_API_KEY=secret \
          ghcr.io/bluesky/tiled:main

@prjemian
Copy link
Contributor Author

NOTE: needs apstools 1.6.19 (due by March 2024)

@prjemian
Copy link
Contributor Author

Example python code to start a local (no network) tiled server with config for MongoDB server (which is network based):

from tiled.client import Context, from_context
from tiled.server.app import build_app_from_config

config = {
    "trees": [
        {
            "path": "bluesky_runs",
            "tree": "databroker.mongo_normalized:MongoAdapter.from_uri",
            "args": {"uri": "mongodb://localhost:27017/bluesky_runs"},
        }
    ]
}

app = build_app_from_config(config)
context = Context.from_app(app)
client = from_context(context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task routine work
Projects
None yet
Development

No branches or pull requests

1 participant