Skip to content

Commit

Permalink
Merge 'ophyd-epics-devices/main'
Browse files Browse the repository at this point in the history
Most merge conflicts were due to naming issues, i.e.
ophyd-epics-devices vs ophyd-async, and file locations
  • Loading branch information
Rose Yemelyanova committed Sep 1, 2023
2 parents a92116c + 51a075a commit 967206f
Show file tree
Hide file tree
Showing 30 changed files with 2,418 additions and 90 deletions.
37 changes: 37 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is for use as a devcontainer and a runtime container
#
# The devcontainer should use the build target and run as root with podman
# or docker with user namespaces.
#
FROM python:3.8 as build

ARG PIP_OPTIONS

# Add any system dependencies for the developer/build environment here e.g.
# RUN apt-get update && apt-get upgrade -y && \
# apt-get install -y --no-install-recommends \
# desired-packages \
# && rm -rf /var/lib/apt/lists/*

# set up a virtual environment and put it in PATH
RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH

# Copy any required context for the pip install over
COPY . /context
WORKDIR /context

# install python package into /venv
RUN pip install ${PIP_OPTIONS}

FROM python:3.8-slim as runtime

# Add apt-get system dependecies for runtime here if needed

# copy the virtual environment from the build stage and put it in PATH
COPY --from=build /venv/ /venv/
ENV PATH=/venv/bin:$PATH

# change this entrypoint if it is not the same as the repo
ENTRYPOINT ["python", "-m", "ophyd_epics_devices"]
CMD ["--version"]
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "Python 3 Developer Container",
"build": {
"dockerfile": "Dockerfile",
"target": "build",
// Only upgrade pip, we will install the project below
"args": {
"PIP_OPTIONS": "--upgrade pip"
},
},
"remoteEnv": {
"DISPLAY": "${localEnv:DISPLAY}"
},
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters"
]
}
},
// Make sure the files we are mapping into the container exist on the host
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
"runArgs": [
"--net=host",
"--security-opt=label=type:container_runtime_t"
],
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind",
// map in home directory - not strictly necessary but useful
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
],
// make the workspace folder the same inside and outside of the container
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"workspaceFolder": "${localWorkspaceFolder}",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install -e .[dev] --config-settings editable_mode=compat"
}
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ filing a new one. If you have a great idea but it involves big changes, please
file a ticket before making a pull request! We want to make sure you don't spend
your time coding something that might not fit the scope of the project.

.. _GitHub: https://github.com/bluesky/ophyd_async/issues
.. _GitHub: https://github.com/bluesky/ophyd-async/issues

Issue or Discussion?
--------------------
Expand All @@ -16,7 +16,7 @@ Github also offers discussions_ as a place to ask questions and share ideas. If
your issue is open ended and it is not obvious when it can be "closed", please
raise it as a discussion instead.

.. _discussions: https://github.com/bluesky/ophyd_async/discussions
.. _discussions: https://github.com/bluesky/ophyd-async/discussions

Code coverage
-------------
Expand All @@ -31,4 +31,4 @@ The `Developer Guide`_ contains information on setting up a development
environment, running the tests and what standards the code and documentation
should follow.

.. _Developer Guide: https://blueskyproject.io/ophyd_async/main/developer/how-to/contribute.html
.. _Developer Guide: https://blueskyproject.io/ophyd-async/main/developer/how-to/contribute.html
34 changes: 34 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,37 @@ jobs:
- name: Test module --version works using the installed wheel
# If more than one module in src/ replace with module name to test
run: python -m $(ls src | head -1) --version

release:
# upload to PyPI and make a release on every tag
needs: [lint, dist, test]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
env:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}

steps:
- uses: actions/download-artifact@v3

- name: Fixup blank lockfiles
# Github release artifacts can't be blank
run: for f in lockfiles/*; do [ -s $f ] || echo '# No requirements' >> $f; done

- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: |
dist/*
lockfiles/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
if: ${{ env.HAS_PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
15 changes: 14 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import sys
from pathlib import Path
from subprocess import check_output

import requests

import ophyd_async

# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -147,7 +150,17 @@
html_theme = "pydata_sphinx_theme"
github_repo = project
github_user = "bluesky"

switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
# Don't check switcher if it doesn't exist, but warn in a non-failing way
check_switcher = requests.get(switcher_json).ok
if not check_switcher:
print(
"*** Can't read version switcher, is GitHub pages enabled? \n"
" Once Docs CI job has successfully run once, set the "
"Github pages source branch to be 'gh-pages' at:\n"
f" https://github.com/{github_user}/{github_repo}/settings/pages",
file=sys.stderr,
)

# Theme options for pydata_sphinx_theme
html_theme_options = dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,11 @@ During this process, the folder structure should incrementally be changed to
│ └── devices
└── ...

The :python:`__init__.py` files of each submodule (core, devices.epics and devices.tango) will
The `__init__.py` files of each submodule (core, devices.epics and devices.tango) will
be modified such that end users experience little disruption to how they use Ophyd Async.
For such users, lines like
For such users, `from ophyd.v2.core import ...` can be replaced with
`from ophyd_async.core import ...`.

.. code:: python
from ophyd.v2.core import ...
will be replaced with
.. code:: python
from ophyd_async.core import ...

Consequences
------------
Expand All @@ -90,4 +85,4 @@ The git history of all three repositories being merged will be preserved, and th
code bases neatly subdivided.

Merge conflicts dealt with for ophyd-epics-devices and ophyd-tango-devices will be
clearly stated in the commit messages regarding their resolutions.
clearly stated in the commit messages regarding their resolutions.
2 changes: 1 addition & 1 deletion docs/developer/how-to/make-release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ To make a new release, please follow this checklist:
Note that tagging and pushing to the main branch has the same effect except that
you will not get the option to edit the release notes.

.. _release: https://github.com/bluesky/ophyd_async/releases
.. _release: https://github.com/bluesky/ophyd-async/releases
6 changes: 3 additions & 3 deletions docs/developer/tutorials/dev-install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Clone the repository
First clone the repository locally using `Git
<https://git-scm.com/downloads>`_::

$ git clone git://github.com/bluesky/ophyd_async.git
$ git clone git://github.com/bluesky/ophyd-async.git

Install dependencies
--------------------
Expand All @@ -25,7 +25,7 @@ requires python 3.8 or later) or to run in a container under `VSCode

.. code::
$ cd ophyd_async
$ cd ophyd-async
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -e '.[dev]'
Expand All @@ -34,7 +34,7 @@ requires python 3.8 or later) or to run in a container under `VSCode

.. code::
$ vscode ophyd_async
$ vscode ophyd-async
# Click on 'Reopen in Container' when prompted
# Open a new terminal
Expand Down
45 changes: 45 additions & 0 deletions docs/examples/ad_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import bluesky.plan_stubs as bps
import bluesky.plans as bp # noqa
import bluesky.preprocessors as bpp

# Import bluesky and ophyd
import matplotlib.pyplot as plt
from bluesky import RunEngine
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.utils import ProgressBarManager, register_transform
from ophyd.v2.core import DeviceCollector

from ophyd_async.devices import areadetector

# Create a run engine, with plotting, progressbar and transform
RE = RunEngine({}, call_returns_result=True)
bec = BestEffortCallback()
RE.subscribe(bec)
RE.waiting_hook = ProgressBarManager()
plt.ion()
register_transform("RE", prefix="<")

# Start IOC with demo pvs in subprocess
pv_prefix = "pc0105-AD-SIM-01:"


# Create v2 devices
with DeviceCollector():
det1 = areadetector.MySingleTriggerSim(pv_prefix)
det2 = areadetector.MyHDFWritingSim(pv_prefix)
det3 = areadetector.MyHDFFlyerSim(pv_prefix)


# And a plan
@bpp.run_decorator()
@bpp.stage_decorator([det3])
def fly_det3(num: int):
yield from bps.mov(det3.drv.num_images, num)
yield from bps.kickoff(det3, wait=True)
status = yield from bps.complete(det3, wait=False, group="complete")
while status and not status.done:
yield from bps.collect(det3, stream=True, return_payload=False)
yield from bps.sleep(0.1)
yield from bps.wait(group="complete")
# One last one
yield from bps.collect(det3, stream=True, return_payload=False)
Loading

0 comments on commit 967206f

Please sign in to comment.