<commit_before>.. currentmodule:: databroker


********
Tutorial
********

The databroker is tool for access data from many sources through a unified
interface. It emphasizes rich searching capabilities and handling multiple
concurrent "streams" of data in an organized way.


.. ipython:: python
    :suppress:

    import os
    import yaml
    from databroker import temp_config
    config = temp_config()
    os.makedirs('~/.config/databroker', exist_ok=True)
    path = os.path.expanduser('~/.config/databroker/example.yml')
    with open(path, 'w') as f:
        yaml.dump(config, f)
    from databroker import Broker
    db = Broker.named('example')
    from bluesky import RunEngine
    from bluesky.plans import scan
    from bluesky.examples import det, motor
    RE = RunEngine({})
    RE.subscribe(db.insert)
    for _ in range(5):
        RE(scan([det], motor, 1, 5, 5))

Basic Walkthrough
-----------------

Get a Broker
============

List the names of available configurations.

.. ipython:: python

    from databroker import list_configs

    list_configs()

If this list is empty, no one has created any configuration files yet. See the
section on :doc:`configuration`.<commit_msg>DOC: Cludge to work around pyepics mock version error.<commit_after>.. currentmodule:: databroker


********
Tutorial
********

The databroker is tool for access data from many sources through a unified
interface. It emphasizes rich searching capabilities and handling multiple
concurrent "streams" of data in an organized way.


.. ipython:: python
    :suppress:

    import os
    import yaml
    import epics
    epics.__version__ = "0.0.0"
    from databroker import temp_config
    config = temp_config()
    os.makedirs('~/.config/databroker', exist_ok=True)
    path = os.path.expanduser('~/.config/databroker/example.yml')
    with open(path, 'w') as f:
        yaml.dump(config, f)
    from databroker import Broker
    db = Broker.named('example')
    from bluesky import RunEngine
    from bluesky.plans import scan
    from ophyd.sim import det, motor
    RE = RunEngine({})
    RE.subscribe(db.insert)
    for _ in range(5):
        RE(scan([det], motor, 1, 5, 5))

Basic Walkthrough
-----------------

Get a Broker
============

List the names of available configurations.

.. ipython:: python

    from databroker import list_configs

    list_configs()

If this list is empty, no one has created any configuration files yet. See the
section on :doc:`configuration`.
{'fraction_non_alphanumeric': 0.11930673115679162, 'fraction_numerical': 0.004433696090286175, 'mean_word_length': 3.2354948805460753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2063139', 'n_tokens_mistral': 760, 'n_tokens_neox': 725, 'n_words': 259}