Skip to content

Commit 9d0cad0

Browse files
committed
Update repo with template version v1.4.0
1 parent d163e6f commit 9d0cad0

7 files changed

Lines changed: 120 additions & 9 deletions

File tree

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# It is needed to track the repo template version, and editing may break things.
33
# This file will be overwritten by copier on template updates.
44

5-
_commit: v1.2.2
5+
_commit: v1.4.0
66
_src_path: https://github.com/bec-project/plugin_copier_template.git
77
make_commit: true
88
project_name: bec_testing_plugin
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Create template upgrade PR for bec_testing_plugin
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
pull-requests: write
7+
8+
jobs:
9+
create_update_branch_and_pr:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Create virtualenv
25+
run: |
26+
python -m virtualenv .venv
27+
28+
- name: Install tools
29+
run: |
30+
source .venv/bin/activate
31+
pip install copier PySide6 bec_lib
32+
33+
- name: Perform update
34+
run: |
35+
source .venv/bin/activate
36+
git config --global user.email "bec_ci_staging@psi.ch"
37+
git config --global user.name "BEC automated CI"
38+
39+
branch="chore/update-template-$(python -m uuid)"
40+
echo "switching to branch $branch"
41+
git checkout -b $branch
42+
43+
echo "Running copier update..."
44+
copier update --trust --defaults --conflict inline 2>&1 | tee copier.log
45+
status=${PIPESTATUS[0]}
46+
output="$(cat copier.log)"
47+
echo $output
48+
msg="$(printf '%s\n' "$output" | head -n 1)"
49+
50+
if ! grep -q "make_commit: true" .copier-answers.yml ; then
51+
echo "Autocommit not made, committing..."
52+
git add -A
53+
git commit -a -m "$msg"
54+
fi
55+
56+
if diff-index --quiet HEAD ; then
57+
echo "No changes detected"
58+
exit 0
59+
fi
60+
61+
git push -u origin $branch
62+
curl -X POST "https://gitea.psi.ch/api/v1/repos/${{ gitea.repository }}/pulls" \
63+
-H "Authorization: token ${{ secrets.CI_REPO_WRITE }}" \
64+
-H "Content-Type: application/json" \
65+
-d "{
66+
\"title\": \"Template: $(echo $msg)\",
67+
\"body\": \"This PR was created by Gitea Actions\",
68+
\"head\": \"$(echo $branch)\",
69+
\"base\": \"main\"
70+
}"

.gitlab-ci.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

bec_testing_plugin/scans/scan_customization/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
Scan components for bec_testing_plugin.
3+
4+
The scan components module allows you to define custom components that can be used in your scans.
5+
These components can be used to encapsulate reusable logic, interact with devices, or perform specific actions during the scan lifecycle.
6+
"""
7+
8+
from bec_server.scan_server.scans.scan_components import ScanComponents
9+
10+
11+
class BecTestingPluginScanComponents(ScanComponents):
12+
"""Scan components for bec_testing_plugin."""
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Scan modifier plugin for bec_testing_plugin.
3+
4+
The scan modifier allows you to modify the scan lifecycle and run custom actions before or after the scan hook or replace the scan hook entirely.
5+
Note that the scan_modifier module must be registered as a plugin in the pyproject.toml file for it to be recognized by the BEC framework and that
6+
there can only be one scan_modifier plugin registered at a time. If you need to run multiple scan modifiers, you can create a single scan
7+
modifier plugin that runs multiple actions in sequence with conditional logic to determine which actions to run based on the scan context.
8+
"""
9+
10+
from bec_server.scan_server.scans.scan_modifier import ScanModifier, scan_hook_impl
11+
12+
13+
class BecTestingPluginScanModifier(ScanModifier):
14+
"""
15+
Scan modifier for bec_testing_plugin.
16+
17+
By inheriting from the ScanModifier base class, you get access to currently running scan (self.scan), the devices (self.dev), the scan info (self.scan_info),
18+
the scan components (self.components) and the scan actions (self.actions).
19+
"""
20+
21+
def __init__(self, **kwargs):
22+
"""Initialize the scan modifier."""
23+
super().__init__(**kwargs)
24+
25+
# Example of running code before the scan stage for a specific scan
26+
# @scan_hook_impl("stage", "before")
27+
# def before_stage(self):
28+
# """Run before the stage hook."""
29+
# self.actions.send_client_info("Custom stage logic executed by ScanModifier.")
30+
# if self.scan_info.scan_name == "example_scan":
31+
# self.dev.samx.set(20)
32+
33+

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66
name = "bec_testing_plugin"
77
version = "0.3.1"
88
description = "A plugin repository for BEC"
9-
requires-python = ">=3.10"
9+
requires-python = ">=3.11"
1010
classifiers = [
1111
"Development Status :: 3 - Alpha",
1212
"Programming Language :: Python :: 3",
@@ -39,6 +39,9 @@ plugin_file_writer = "bec_testing_plugin.file_writer"
3939
[project.entry-points."bec.scans"]
4040
plugin_scans = "bec_testing_plugin.scans"
4141

42+
[project.entry-points."bec.scans.scan_modifier"]
43+
plugin_scan_modifier = "bec_testing_plugin.scans.scan_customization.scan_modifier"
44+
4245
[project.entry-points."bec.scans.metadata_schema"]
4346
plugin_metadata_schema = "bec_testing_plugin.scans.metadata_schema"
4447

0 commit comments

Comments
 (0)