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

DEV: servers crash #283

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ ENV/
# pycharm
.idea/
# Rever
rever/
rever/*
4 changes: 2 additions & 2 deletions docs/_templates/post_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ start up ipython.
from xpdconf.conf import glbl_dict

# import the publisher which will send our data to the proxy
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.zmq import Publisher
# tell the publisher to send the data to the proxy with the prefix of raw
# (which stands for raw data)
pub = Publisher(glbl_dict['inbound_proxy_address'], prefix=b'raw')

# leave this line out if you don't need to change the darks
better_dark_uid = 'hello world'
# get the header
Expand Down
4 changes: 2 additions & 2 deletions examples/best_effort.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
SimpleToEventStream,
AlignEventStreams,
)
from xpdan.vend.callbacks.core import StripDepVar
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.core import StripDepVar
from bluesky.callbacks.zmq import Publisher
from xpdconf.conf import glbl_dict


Expand Down
2 changes: 1 addition & 1 deletion examples/ctPDF_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tomopy
from bluesky.run_engine import RunEngine
from ophyd.sim import SynSignal, hw
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.zmq import Publisher
from xpdconf.conf import glbl_dict

hw = hw()
Expand Down
4 changes: 2 additions & 2 deletions examples/fake_xpd/analysis.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import copy

from databroker.broker import Broker
from xpdan.startup.analysis_server import order, run_server
from xpdan.startup.analysis_server import ORDER, analysis_server

db = Broker.named("live_demo_data")
db.prepare_hook = lambda x, y: copy.deepcopy(y)

run_server(order=order, db=db, mask_setting={"setting": "first"})
analysis_server(order=ORDER, db=db, mask_setting={"setting": "first"})
2 changes: 1 addition & 1 deletion examples/fake_xpd/replay_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pprint import pprint
from databroker.broker import Broker
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.zmq import Publisher

# pull from local data, not needed at beamline
db = Broker.named("live_demo_data")
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_tomo_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tomopy
from bluesky.run_engine import RunEngine
from ophyd.sim import SynSignal, hw, SynSignalWithRegistry
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.zmq import Publisher
from xpdconf.conf import glbl_dict

hw = hw()
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tomopy
from bluesky.run_engine import RunEngine
from ophyd.sim import SynSignal, hw, SynSignalWithRegistry
from xpdan.vend.callbacks.zmq import Publisher
from bluesky.callbacks.zmq import Publisher
from xpdconf.conf import glbl_dict

hw = hw()
Expand Down
13 changes: 13 additions & 0 deletions news/news0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**Added:**

* A simple server to print out the message from the run engine.

**Changed:** None

**Deprecated:** None

**Removed:** None

**Fixed:** None

**Security:** None
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
env =
D:IS_TEST=1
XPDAN_SETUP=1
XPDAN_SETUP=1
addopts = -p no:xonsh
9 changes: 5 additions & 4 deletions xpdan/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import time

import numpy as np
from bluesky.callbacks.core import CallbackBase
from skbeam.io import save_output
from skbeam.io.fit2d import fit2d_save
from tifffile import imsave
from xpdtools.dev_utils import _timestampstr

from xpdan.formatters import pfmt, clean_template, render2
from xpdan.io import pdf_saver, dump_yml
from xpdan.vend.callbacks.core import CallbackBase
from xpdan.vend.callbacks.core import Retrieve
from xpdtools.dev_utils import _timestampstr


class StartStopCallback(CallbackBase):
Expand Down Expand Up @@ -158,8 +159,8 @@ def event(self, doc):
event=doc,
base_folder=bf,
)
.replace(".", ",")
.replace("__", "_")
.replace(".", ",")
.replace("__", "_")
for bf in self.base_folders
]
# Note that formally there are more steps to the formatting, but we
Expand Down
22 changes: 11 additions & 11 deletions xpdan/config/xpdan.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
home_dir_name : xpdUser
blconfig_dir_name : xpdConfig
beamline_host_name : xf28id1-ws2
archive_base_dir_name : /direct/XF28ID1/pe1_data/.userBeamtimeArchive
user_backup_dir_name : '2017'
owner : xf28id1
beamline_id : xpd
group : XPD
det_image_field : pe1_image
dark_field_key : sc_dk_field_uid
calib_config_name : xpdAcq_calib_info.yml
home_dir_name: xpdUser
blconfig_dir_name: xpdConfig
beamline_host_name: xf28id1-ws2
archive_base_dir_name: /direct/XF28ID1/pe1_data/.userBeamtimeArchive
user_backup_dir_name: '2017'
owner: xf28id1
beamline_id: xpd
group: XPD
det_image_field: pe1_image
dark_field_key: sc_dk_field_uid
calib_config_name: xpdAcq_calib_info.yml
mask_kwargs:
edge: 30
lower_thresh: 0.0
Expand Down
5 changes: 3 additions & 2 deletions xpdan/data_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# See LICENSE.txt for license information.
#
##############################################################################
import inspect
from functools import partial

from xpdan.data_reduction_core import (integrate_and_save, save_tiff,
integrate_and_save_last, save_last_tiff)
from xpdan.glbl import an_glbl
from functools import partial
import inspect

# We are going to do some inspection magic to make functions who's default
# kwargs come from the globals
Expand Down
6 changes: 4 additions & 2 deletions xpdan/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import collections
from itertools import islice
from pprint import pprint
from .dev_utils import _timestampstr
import collections

from databroker._core import Header

from .dev_utils import _timestampstr


def sort_scans_by_hdr_key(hdrs, key, verbose=True):
"""In a list of hdrs, group the scans by header-key.
Expand Down
3 changes: 2 additions & 1 deletion xpdan/fuzzybroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

from heapq import heapify, heappushpop
from pprint import pprint

from databroker.broker import Broker
from pyxdameraulevenshtein import \
normalized_damerau_levenshtein_distance as ndld

from databroker.broker import Broker
from .dev_utils import _timestampstr


Expand Down
1 change: 1 addition & 0 deletions xpdan/glbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
##############################################################################

from xpdconf.conf import glbl_dict

an_glbl = glbl_dict
2 changes: 1 addition & 1 deletion xpdan/io.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from collections import defaultdict

import numpy as np
import yaml

from .formatters import CleanFormatter, PartialFormatter
from collections import defaultdict

template_hdr = '''[DEFAULT]
# input and output specifications
Expand Down
3 changes: 2 additions & 1 deletion xpdan/mayavi_callbacks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from bluesky.callbacks import CallbackBase
from mayavi import mlab as mlab

from bluesky.callbacks import CallbackBase


class Live3DView(CallbackBase):
"""Callback for visualizing 3D data """
Expand Down
28 changes: 14 additions & 14 deletions xpdan/pipelines/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@

import numpy as np
import tifffile

from bluesky.callbacks.broker import LiveImage
from bluesky.callbacks.core import CallbackBase
from skbeam.core.utils import q_to_twotheta
from skbeam.io.fit2d import fit2d_save
from skbeam.io.save_powder_output import save_output
from xpdtools.calib import img_calibration, _save_calib_param
from xpdan.db_utils import query_dark, temporal_prox, query_background
from xpdan.dev_utils import _timestampstr
from xpdan.formatters import render_and_clean
from xpdan.io import pdf_saver, dump_yml, poni_saver
from xpdan.pipelines.pipeline_utils import (
if_dark,
if_calibration,
base_template,
)
from xpdtools.tools import (
generate_binner,
load_geo,
Expand All @@ -30,6 +18,18 @@
)
from xpdview.callbacks import LiveWaterfall

from bluesky.callbacks.broker import LiveImage
from bluesky.callbacks.core import CallbackBase
from xpdan.db_utils import query_dark, temporal_prox, query_background
from xpdan.dev_utils import _timestampstr
from xpdan.formatters import render_and_clean
from xpdan.io import pdf_saver, dump_yml, poni_saver
from xpdan.pipelines.pipeline_utils import (
if_dark,
if_calibration,
base_template,
)


def format_event(**kwargs):
return {"data": dict(**kwargs), "filled": {k: True for k in kwargs}}
Expand Down Expand Up @@ -97,8 +97,8 @@ def __init__(
"masked_img": LiveImage(
"overlay_mask",
window_title="Dark/Background/"
"Polarization Corrected "
"Image with Mask",
"Polarization Corrected "
"Image with Mask",
cmap="viridis",
limit_func=lambda im: (
np.nanpercentile(im, 1),
Expand Down
Loading