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

ENH: Set up the presets #95

Merged
merged 8 commits into from
Apr 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ requirements:
- pyyaml
- coloredlogs
- pyfiglet
- happi >=0.5.0
- pcdsdevices >=0.4.0
- pcdsdaq >=1.0.0
- happi >=1.1.1
- pcdsdevices >=0.6.0
- pcdsdaq >=1.1.0
- psdm_qs_cli >=0.2.0
- lightpath >=0.3.0
- cookiecutter >=1.6.0
Expand Down
25 changes: 23 additions & 2 deletions hutch_python/load_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from bluesky import RunEngine
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.utils import install_kicker
from pcdsdevices.mv_interface import setup_preset_paths

from . import plan_defaults
from .cache import LoadCache
Expand Down Expand Up @@ -97,8 +98,9 @@ def load_conf(conf, hutch_dir=None):
``Path`` object that points to the hutch's launch directory. This is
the directory that includes the ``experiments`` directory and a
hutchname directory e.g. ``mfx``
If this is missing, we'll be unable to write the ``db.txt`` file or do
relative filepath database selection for ``happi``.
If this is missing, we'll be unable to write the ``db.txt`` file,
do relative filepath database selection for ``happi``,
or establish a preset positions directory.

Returns
------
Expand Down Expand Up @@ -248,6 +250,25 @@ def load_conf(conf, hutch_dir=None):

default_class_namespace(object, 'all_objects', cache)

# Install Presets
if hutch_dir is not None:
with safe_load('position presets'):
presets_dir = Path(hutch_dir) / 'presets'
beamline_presets = presets_dir / 'beamline'
preset_paths = [presets_dir, beamline_presets]
if proposal is not None:
experiment_presets = presets_dir / (proposal + str(run))
preset_paths.append(experiment_presets)
for path in preset_paths:
if not path.exists():
path.mkdir()
path.chmod(0o777)
if proposal is None:
setup_preset_paths(hutch=beamline_presets)
else:
setup_preset_paths(hutch=beamline_presets,
exp=experiment_presets)

# Write db.txt info file to the user's module
try:
cache.write_file()
Expand Down
3 changes: 3 additions & 0 deletions hutch_python/tests/test_load_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os.path
from types import SimpleNamespace

from pcdsdevices.mv_interface import Presets

import hutch_python.qs_load
from hutch_python.load_conf import load, load_conf

Expand All @@ -18,6 +20,7 @@ def test_file_load():
for elem in should_have:
assert not isinstance(objs[elem], SimpleNamespace), err.format(elem)
assert 'tst' in objs
assert len(Presets._paths) == 2


def test_no_file():
Expand Down