-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '341-new-j20-setup' of github.com:DiamondLightSource/dod…
…al into 341-new-j20-setup
- Loading branch information
Showing
64 changed files
with
1,733 additions
and
1,553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,96 +112,6 @@ jobs: | |
# If more than one module in src/ replace with module name to test | ||
run: python -m dodal --version | ||
|
||
container: | ||
needs: [lint, dist, test] | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
TEST_TAG: "testing" | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# image names must be all lower case | ||
- name: Generate image repo name | ||
run: echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV | ||
|
||
- name: Set lockfile location in environment | ||
run: | | ||
echo "DIST_LOCKFILE_PATH=lockfiles-${{ env.CONTAINER_PYTHON }}-dist-${{ github.sha }}" >> $GITHUB_ENV | ||
- name: Download wheel and lockfiles | ||
uses: actions/[email protected] | ||
with: | ||
path: artifacts/ | ||
pattern: "*dist*" | ||
|
||
- name: Log in to GitHub Docker Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and export to Docker local cache | ||
uses: docker/build-push-action@v5 | ||
with: | ||
# Note build-args, context, file, and target must all match between this | ||
# step and the later build-push-action, otherwise the second build-push-action | ||
# will attempt to build the image again | ||
build-args: | | ||
PIP_OPTIONS=-r ${{ env.DIST_LOCKFILE_PATH }}/requirements.txt ${{ env.DIST_WHEEL_PATH }}/*.whl | ||
context: artifacts/ | ||
file: ./Dockerfile | ||
target: runtime | ||
load: true | ||
tags: ${{ env.TEST_TAG }} | ||
# If you have a long docker build (2+ minutes), uncomment the | ||
# following to turn on caching. For short build times this | ||
# makes it a little slower | ||
#cache-from: type=gha | ||
#cache-to: type=gha,mode=max | ||
|
||
- name: Create tags for publishing image | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.IMAGE_REPOSITORY }} | ||
tags: | | ||
type=ref,event=tag | ||
type=raw,value=latest, enable=${{ github.ref_type == 'tag' }} | ||
# type=edge,branch=main | ||
# Add line above to generate image for every commit to given branch, | ||
# and uncomment the end of if clause in next step | ||
|
||
- name: Push cached image to container registry | ||
if: github.ref_type == 'tag' # || github.ref_name == 'main' | ||
uses: docker/build-push-action@v5 | ||
# This does not build the image again, it will find the image in the | ||
# Docker cache and publish it | ||
with: | ||
# Note build-args, context, file, and target must all match between this | ||
# step and the previous build-push-action, otherwise this step will | ||
# attempt to build the image again | ||
build-args: | | ||
PIP_OPTIONS=-r ${{ env.DIST_LOCKFILE_PATH }}/requirements.txt ${{ env.DIST_WHEEL_PATH }}/*.whl | ||
context: artifacts/ | ||
file: ./Dockerfile | ||
target: runtime | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
release: | ||
# upload to PyPI and make a release on every tag | ||
needs: [lint, dist, test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ side-bar. | |
:caption: How-to Guides | ||
:maxdepth: 1 | ||
|
||
how-to/run-container | ||
how-to/create-beamline.rst | ||
|
||
+++ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from .coordination import group_uuid, inject | ||
from .maths import in_micros, step_to_num | ||
from .types import MsgGenerator, PlanGenerator | ||
|
||
__all__ = [ | ||
"group_uuid", | ||
"inject", | ||
"in_micros", | ||
"MsgGenerator", | ||
"PlanGenerator", | ||
"step_to_num", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import uuid | ||
|
||
from dodal.common.types import Group | ||
|
||
|
||
def group_uuid(name: str) -> Group: | ||
""" | ||
Returns a unique but human-readable string, to assist debugging orchestrated groups. | ||
Args: | ||
name (str): A human readable name | ||
Returns: | ||
readable_uid (Group): name appended with a unique string | ||
""" | ||
return f"{name}-{str(uuid.uuid4())[:6]}" | ||
|
||
|
||
def inject(name: str): # type: ignore | ||
""" | ||
Function to mark a default argument of a plan method as a reference to a device | ||
that is stored in the Blueapi context, as devices are constructed on startup of the | ||
service, and are not available to be used when writing plans. | ||
Bypasses mypy linting, returning x as Any and therefore valid as a default | ||
argument. | ||
e.g. For a 1-dimensional scan, that is usually performed on a consistent Movable | ||
axis with name "stage_x" | ||
def scan(x: Movable = inject("stage_x"), start: float = 0.0 ...) | ||
Args: | ||
name (str): Name of a device to be fetched from the Blueapi context | ||
Returns: | ||
Any: name but without typing checking, valid as any default type | ||
""" | ||
|
||
return name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from typing import Tuple | ||
|
||
import numpy as np | ||
|
||
|
||
def step_to_num(start: float, stop: float, step: float) -> Tuple[float, float, int]: | ||
""" | ||
Standard handling for converting from start, stop, step to start, stop, num | ||
Forces step to be same direction as length | ||
Includes a final point if it is within 1% of the final step, prevents floating | ||
point arithmatic errors from giving inconsistent shaped scans between steps of an | ||
outer axis. | ||
Args: | ||
start (float): | ||
Start of length, will be returned unchanged | ||
stop (float): | ||
End of length, if length/step does not divide cleanly will be returned | ||
extended up to 1% of step, or else truncated. | ||
step (float): | ||
Length of a step along the line formed from start to stop. | ||
If stop < start, will be coerced to be backwards. | ||
Returns: | ||
start, adjusted_stop, num = Tuple[float, float, int] | ||
start will be returned unchanged | ||
adjusted_stop = start + (num - 1) * step | ||
num is the maximal number of steps that could fit into the length. | ||
""" | ||
# Make step be the right direction | ||
step = abs(step) if stop >= start else -abs(step) | ||
# If stop is within 1% of a step then include it | ||
steps = int((stop - start) / step + 0.01) | ||
return start, start + steps * step, steps + 1 # include 1st point | ||
|
||
|
||
def in_micros(t: float) -> int: | ||
""" | ||
Converts between a positive number of seconds and an equivalent | ||
number of microseconds. | ||
Args: | ||
t (float): A time in seconds | ||
Raises: | ||
ValueError: if t < 0 | ||
Returns: | ||
t (int): A time in microseconds, rounded up to the nearest whole microsecond, | ||
""" | ||
if t < 0: | ||
raise ValueError(f"Expected a positive time in seconds, got {t!r}") | ||
return int(np.ceil(t * 1e6)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import ( | ||
Any, | ||
Callable, | ||
Generator, | ||
) | ||
|
||
from bluesky.utils import Msg | ||
|
||
# String identifier used by 'wait' or stubs that await | ||
Group = str | ||
# A true 'plan', usually the output of a generator function | ||
MsgGenerator = Generator[Msg, Any, None] | ||
# A function that generates a plan | ||
PlanGenerator = Callable[..., MsgGenerator] |
Oops, something went wrong.