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

Better way to prepare bluesky environment #141

Merged
merged 14 commits into from
Aug 18, 2023
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
45 changes: 28 additions & 17 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,43 @@ jobs:
with:
docker-binary: ${{ env.DOCKER_BINARY }}

- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge

- name: Install documentation-building requirements
# - name: Set up Python ${{ matrix.python-version }}
# uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
# auto-update-conda: true
# miniconda-version: "latest"
# python-version: ${{ matrix.python-version }}
# mamba-version: "*"
# channels: conda-forge

- name: Install documentation-building requirements with apt/dpkg
run: |
set -vxeo pipefail
conda env list
mamba install -c conda-forge pandoc
pip install --upgrade pip wheel
pip install -v .
pip install -r requirements-dev.txt
pip list
conda list
set -vxeuo pipefail
wget --progress=dot:giga "https://github.com/jgm/pandoc/releases/download/3.1.6.1/pandoc-3.1.6.1-1-amd64.deb" -O /tmp/pandoc.deb
sudo dpkg -i /tmp/pandoc.deb
# conda install -c conda-forge -y pandoc
which pandoc
pandoc --version

- name: Install documentation-building requirements with pip
run: |
set -vxeuo pipefail
python -m pip install --upgrade pip wheel
python -m pip install -v .
python -m pip install -r requirements-dev.txt
python -m pip list

- name: Copy databroker config file
run: |
set -vxeuo pipefail
mkdir -v -p ~/.config/databroker/
cp examples/local.yml ~/.config/databroker/
cp -v examples/local.yml ~/.config/databroker/

- name: Build Docs
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
set -vxeuo pipefail
python -m pip install --upgrade pip
pip install wheel setuptools
python -m pip install wheel setuptools
python setup.py sdist bdist_wheel

- name: Publish wheels to PyPI
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,34 @@ jobs:
with:
docker-binary: ${{ env.DOCKER_BINARY }}

- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge

# - name: Set up Python ${{ matrix.python-version }} with conda
# uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
# auto-update-conda: true
# miniconda-version: "latest"
# python-version: ${{ matrix.python-version }}
# mamba-version: "*"
# channels: conda-forge

- name: Install the package and its dependencies
run: |
# set -vxeuo pipefail
# Do not check for unbound variables (the '-u' flag) as it fails on
# conda deactivate command:
# /usr/share/miniconda3/envs/sirepo-bluesky-py3.9/etc/conda/deactivate.d/glib_deactivate.sh:
# line 1: GSETTINGS_SCHEMA_DIR_CONDA_BACKUP: unbound variable
set -vxeo pipefail
conda env list
pip install --upgrade pip wheel
pip install -v .
pip install -r requirements-dev.txt
pip list
conda list
python -m pip install --upgrade pip wheel
python -m pip install -v .
python -m pip install -r requirements-dev.txt
python -m pip list

- name: Copy databroker config file
run: |
set -vxeuo pipefail
mkdir -v -p ~/.config/databroker/
cp examples/local.yml ~/.config/databroker/
cp -v examples/local.yml ~/.config/databroker/

- name: Test with pytest
run: |
Expand Down
4 changes: 3 additions & 1 deletion docs/source/notebooks/madx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_flyer_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__ -e flyer\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand Down
10 changes: 7 additions & 3 deletions docs/source/notebooks/shadow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_det_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__\n",
"\n",
"from sirepo_bluesky.sirepo_bluesky import SirepoBluesky\n",
"from sirepo_bluesky.sirepo_ophyd import BeamStatisticsReport, create_classes\n",
Expand Down Expand Up @@ -104,7 +106,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_det_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__\n",
"\n",
"from sirepo_bluesky.sirepo_bluesky import SirepoBluesky\n",
"from sirepo_bluesky.sirepo_ophyd import BeamStatisticsReport, create_classes\n",
Expand Down Expand Up @@ -190,7 +194,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
12 changes: 9 additions & 3 deletions docs/source/notebooks/srw.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_det_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__\n",
"\n",
"from sirepo_bluesky.sirepo_bluesky import SirepoBluesky\n",
"from sirepo_bluesky.sirepo_ophyd import create_classes\n",
Expand Down Expand Up @@ -103,7 +105,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_det_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__\n",
"\n",
"from sirepo_bluesky.sirepo_bluesky import SirepoBluesky\n",
"from sirepo_bluesky.sirepo_ophyd import create_classes\n",
Expand Down Expand Up @@ -184,7 +188,9 @@
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../../examples/prepare_det_env.py\n",
"from sirepo_bluesky import prepare_re_env\n",
"\n",
"%run -i $prepare_re_env.__file__\n",
"\n",
"from sirepo_bluesky.sirepo_bluesky import SirepoBluesky\n",
"from sirepo_bluesky.sirepo_ophyd import create_classes\n",
Expand Down
4 changes: 3 additions & 1 deletion docs/source/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ API
is turned into a document for SRW and Shadow apps. The beam stats show up in
Bluesky's ``BestEffortCallback``.
- Removed old API support and relevant tests.
- ``create_classes`` does not need the ``data`` kwarg as it obtains it via
``connection``.

Documentation
.............
- Suppress Shadow3 code's stdout in notebooks/code.
- Converted project's `README.rst` to `README.md` for better rendering on PyPI.
- Converted project's ``README.rst`` to ``README.md`` for better rendering on PyPI.

Examples
........
Expand Down
36 changes: 0 additions & 36 deletions examples/prepare_det_env.py

This file was deleted.

32 changes: 0 additions & 32 deletions examples/prepare_flyer_env.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ matplotlib
nbsphinx
numpydoc
pandoc
sphinx
sphinx==7.1.2
sphinx-copybutton
tabulate>=0.9.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
entry_points={
"console_scripts": [
# 'command = some.module:some_function',
"json-yaml-converter = sirepo_bluesky.utils.json_yaml_converter:cli_converter"
"json-yaml-converter = sirepo_bluesky.utils.json_yaml_converter:cli_converter",
],
},
include_package_data=True,
Expand Down
1 change: 1 addition & 0 deletions sirepo_bluesky/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ophyd import Signal

from ._version import get_versions
from .utils import prepare_re_env # noqa: F401

__version__ = get_versions()["version"]
del get_versions
Expand Down
6 changes: 0 additions & 6 deletions sirepo_bluesky/tests/test_entrypoint.py

This file was deleted.

6 changes: 4 additions & 2 deletions sirepo_bluesky/tests/test_sirepo_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _test_sirepo_flyer(RE_no_plot, db, tmpdir, sim_id, server_name):
hdr = db[-1]
t = hdr.table(stream_name="sirepo_flyer")
db_means = []
actual_means = [
expected_means = [
36779651609602.38,
99449330615601.89,
149289119385413.34,
Expand All @@ -78,7 +78,9 @@ def _test_sirepo_flyer(RE_no_plot, db, tmpdir, sim_id, server_name):
for i in range(len(t)):
db_means.append(t.iloc[i]["sirepo_flyer_mean"])

assert set(actual_means) == set(db_means), "fly scan means do not match actual means"
assert np.allclose(
sorted(expected_means), sorted(db_means), rtol=1.0e-6
), "fly scan expected means do not match actual means"

durations = []
for i in range(len(t)):
Expand Down
Loading
Loading