Skip to main content

Model of a Bluesky Data Acquisition Instrument in console, notebook, & queueserver.

Project description

APSBITS: Template Package for Bluesky Instruments

PyPI Coverage
PyPi Coverage Status

BITS: Bluesky Instrument Template Structure

Template of a Bluesky Data Acquisition Instrument in console, notebook, & queueserver.

Production use of BITS

Please create a bits instrument using our template repository: https://github.com/BCDA-APS/DEMO-BITS

Installing the BITS Package

export INSTALL_ENVIRONMENT_NAME=apsbits_env
conda create -y -n "${INSTALL_ENVIRONMENT_NAME}" python=3.11 pyepics
conda activate "${INSTALL_ENVIRONMENT_NAME}"
pip install apsbits

For development please reference our documentation

Startup Architecture

When a user runs from apsbits.demo_instrument.startup import *, the following import and initialization sequence executes. No module runs code on import. All initialization flows through startup.py via explicit function calls.

Module Dependency Graph

Arrows show import direction. No circular imports exist.

graph LR
    subgraph utils["apsbits.utils (base layer)"]
        config_loaders
        aps_functions
        controls_setup
        helper_functions --> config_loaders
        logging_setup -.->|"inside fn"| config_loaders
        baseline_setup --> config_loaders
        metadata -.->|"inside fn"| apsbits_init
        stored_dict -.->|"inside fn"| config_loaders
        sim_creator --> helper_functions
    end

    subgraph core["apsbits.core (middle layer)"]
        core_init["core/__init__"] --> helper_functions
        best_effort_init --> helper_functions
        catalog_init
        instrument_init --> config_loaders
        run_engine_init --> controls_setup
        run_engine_init --> metadata
        run_engine_init --> stored_dict
    end

    subgraph demo["demo_instrument (top layer)"]
        startup
        nexus_cb["callbacks/nexus"]
        spec_cb["callbacks/spec"]
        sim_plans --> instrument_init
    end

    subgraph api["apsbits.api"]
        create_new_instrument
        delete_instrument
        run_instrument --> instrument_init
    end

    apsbits_init["apsbits/__init__"]

    startup --> logging_setup
    startup --> core_init
    startup --> best_effort_init
    startup --> catalog_init
    startup --> instrument_init
    startup --> run_engine_init
    startup --> helper_functions
    startup --> config_loaders
    startup --> baseline_setup
    startup --> aps_functions
    startup -.->|"if enabled"| nexus_cb
    startup -.->|"if enabled"| spec_cb
    startup --> sim_plans

Solid arrows = module-level imports. Dashed arrows = conditional or function-level imports.

Initialization Sequence

Everything is called explicitly by startup.py in this order:

graph TD
    S["startup.py"] -->|1| A["configure_logging()"]
    A -->|reads| A1[("logging.yml")]
    S -->|2| B["prepare_bits()"]
    S -->|3| C["load_config()"]
    C -->|reads| C1[("iconfig.yml")]
    S -->|4| D["configure_logging(extra)"]
    D -->|reads| D1[("extra_logging.yml")]
    S -->|5| E["init_instrument()"]
    E -->|creates| E1["instrument, oregistry"]
    S -->|6| F["init_bec_peaks(iconfig)"]
    F -->|creates| F1["bec, peaks"]
    S -->|7| G["init_catalog(iconfig)"]
    G -->|creates| G1["cat"]
    S -->|8| H["init_RE(iconfig, ...)"]
    H -->|creates| H1["RE, sd"]
    S -->|"9 (if enabled)"| I["nxwriter_init(RE, iconfig)"]
    I -->|creates| I1["nxwriter"]
    S -->|"10 (if enabled)"| J["init_specwriter_with_RE(RE, iconfig)"]
    J -->|creates| J1["specwriter"]
    S -->|11| K["make_devices(...)"]
    K -->|reads| K1[("devices.yml")]
    S -->|12| L["setup_baseline_stream()"]

    style S fill:#fff3e0
    style A1 fill:#f3e5f5
    style C1 fill:#f3e5f5
    style D1 fill:#f3e5f5
    style K1 fill:#f3e5f5
    style E1 fill:#c8e6c9
    style F1 fill:#c8e6c9
    style G1 fill:#c8e6c9
    style H1 fill:#c8e6c9
    style I1 fill:#c8e6c9
    style J1 fill:#c8e6c9

Purple = YAML config files read from disk. Green = objects available in your session.

Testing the apsbits base installation

On an ipython console

from apsbits.demo_instrument.startup import *
listobjects()
RE(sim_print_plan())
RE(sim_count_plan())
RE(sim_rel_scan_plan())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apsbits-2.0.3.tar.gz (155.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apsbits-2.0.3-py3-none-any.whl (66.2 kB view details)

Uploaded Python 3

File details

Details for the file apsbits-2.0.3.tar.gz.

File metadata

  • Download URL: apsbits-2.0.3.tar.gz
  • Upload date:
  • Size: 155.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for apsbits-2.0.3.tar.gz
Algorithm Hash digest
SHA256 0945cab8c0c0695a90425b4a94a79a987869a8336c6c65ace6334c5584a9f4e3
MD5 4f60685d66dccf106e3894a35f8344b0
BLAKE2b-256 9070c5f44bdad9f4e9fcd4e46d77a5371588fa23f3741e0f692a2c06d932c98c

See more details on using hashes here.

Provenance

The following attestation bundles were made for apsbits-2.0.3.tar.gz:

Publisher: pypi.yml on BCDA-APS/BITS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apsbits-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: apsbits-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 66.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for apsbits-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44759d020e9c73401b0229ccd38823a26f1ac332bf2fe4e40d08e6eb1c2e620e
MD5 bc292a75a8556e3d7ec54ef4609f74a8
BLAKE2b-256 e6dd4c5643a4c4be39dfc88cd6e095c9f4119743eefc0f55ce123b5889d208e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for apsbits-2.0.3-py3-none-any.whl:

Publisher: pypi.yml on BCDA-APS/BITS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page