diff --git a/.copier-answers.yml b/.copier-answers.yml index f853e50..3f3c17a 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,8 +2,8 @@ # It is needed to track the repo template version, and editing may break things. # This file will be overwritten by copier on template updates. -_commit: v1.2.2 +_commit: v1.2.8 _src_path: https://github.com/bec-project/plugin_copier_template.git make_commit: true -project_name: pearl +project_name: pearl_bec widget_plugins_input: [] diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f7e971c..07b45fe 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI for pearl +name: CI for pearl_bec on: push: pull_request: @@ -28,7 +28,7 @@ on: description: "Python version to use" required: false type: string - default: "3.11" + default: "3.12" permissions: pull-requests: write @@ -44,7 +44,19 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "${{ inputs.PYTHON_VERSION || '3.11' }}" + python-version: "${{ inputs.PYTHON_VERSION || '3.12' }}" + + - name: Checkout BEC Plugin Repository + uses: actions/checkout@v4 + with: + repository: bec/pearl_bec + ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.head_ref || github.sha }}" + path: ./pearl_bec + + - name: Lint for merge conflicts from template updates + shell: bash + # Find all Copier conflicts except this line + run: '! grep -r "<<<<<<< before updating" | grep -v "grep -r \"<<<<<<< before updating"' - name: Checkout BEC Core uses: actions/checkout@v4 @@ -67,13 +79,6 @@ jobs: ref: "${{ inputs.BEC_WIDGETS_BRANCH || 'main' }}" path: ./bec_widgets - - name: Checkout BEC Plugin Repository - uses: actions/checkout@v4 - with: - repository: bec/pearl - ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.head_ref || github.sha }}" - path: ./pearl - - name: Install dependencies shell: bash run: | @@ -90,8 +95,8 @@ jobs: uv pip install --system -e ./bec/bec_ipython_client uv pip install --system -e ./bec/bec_server[dev] uv pip install --system -e ./bec_widgets[dev,pyside6] - uv pip install --system -e ./pearl + uv pip install --system -e ./pearl_bec - name: Run Pytest with Coverage id: coverage - run: pytest --random-order --cov=./pearl --cov-config=./pearl/pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./pearl/tests/ || test $? -eq 5 + run: pytest --random-order --cov=./pearl_bec --cov-config=./pearl_bec/pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./pearl_bec/tests/ || test $? -eq 5 diff --git a/.gitea/workflows/create_update_pr.yml b/.gitea/workflows/create_update_pr.yml new file mode 100644 index 0000000..6d6365a --- /dev/null +++ b/.gitea/workflows/create_update_pr.yml @@ -0,0 +1,62 @@ +name: Create template upgrade PR for pearl_bec +on: + workflow_dispatch: + +permissions: + pull-requests: write + +jobs: + create_update_branch_and_pr: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install tools + run: | + pip install copier PySide6 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Perform update + run: | + git config --global user.email "bec_ci_staging@psi.ch" + git config --global user.name "BEC automated CI" + + branch="chore/update-template-$(python -m uuid)" + echo "switching to branch $branch" + git checkout -b $branch + + echo "Running copier update..." + output="$(copier update --trust --defaults --conflict inline 2>&1)" + echo "$output" + msg="$(printf '%s\n' "$output" | head -n 1)" + + if ! grep -q "make_commit: true" .copier-answers.yml ; then + echo "Autocommit not made, committing..." + git add -A + git commit -a -m "$msg" + fi + + if diff-index --quiet HEAD ; then + echo "No changes detected" + exit 0 + fi + + git push -u origin $branch + curl -X POST "https://gitea.psi.ch/api/v1/repos/${{ gitea.repository }}/pulls" \ + -H "Authorization: token ${{ secrets.CI_REPO_WRITE }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"title\": \"Template: $(echo $msg)\", + \"body\": \"This PR was created by Gitea Actions\", + \"head\": \"$(echo $branch)\", + \"base\": \"main\" + }" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ecb3565..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,7 +0,0 @@ -include: -- file: /templates/plugin-repo-template.yml - inputs: - name: pearl - target: pearl - branch: $CHILD_PIPELINE_BRANCH - project: bec/awi_utils diff --git a/pearl/__init__.py b/pearl_bec/__init__.py similarity index 100% rename from pearl/__init__.py rename to pearl_bec/__init__.py diff --git a/pearl/bec_ipython_client/__init__.py b/pearl_bec/bec_ipython_client/__init__.py similarity index 100% rename from pearl/bec_ipython_client/__init__.py rename to pearl_bec/bec_ipython_client/__init__.py diff --git a/pearl/bec_ipython_client/high_level_interface/__init__.py b/pearl_bec/bec_ipython_client/high_level_interface/__init__.py similarity index 100% rename from pearl/bec_ipython_client/high_level_interface/__init__.py rename to pearl_bec/bec_ipython_client/high_level_interface/__init__.py diff --git a/pearl/bec_ipython_client/startup/__init__.py b/pearl_bec/bec_ipython_client/startup/__init__.py similarity index 100% rename from pearl/bec_ipython_client/startup/__init__.py rename to pearl_bec/bec_ipython_client/startup/__init__.py diff --git a/pearl/bec_ipython_client/startup/post_startup.py b/pearl_bec/bec_ipython_client/startup/post_startup.py similarity index 100% rename from pearl/bec_ipython_client/startup/post_startup.py rename to pearl_bec/bec_ipython_client/startup/post_startup.py diff --git a/pearl/bec_ipython_client/startup/pre_startup.py b/pearl_bec/bec_ipython_client/startup/pre_startup.py similarity index 95% rename from pearl/bec_ipython_client/startup/pre_startup.py rename to pearl_bec/bec_ipython_client/startup/pre_startup.py index c500de3..5df88ef 100644 --- a/pearl/bec_ipython_client/startup/pre_startup.py +++ b/pearl_bec/bec_ipython_client/startup/pre_startup.py @@ -7,7 +7,7 @@ import os from bec_lib.service_config import ServiceConfig -import pearl +import pearl_bec def extend_command_line_args(parser): @@ -23,7 +23,7 @@ def get_config() -> ServiceConfig: """ Create and return the ServiceConfig for the plugin repository """ - deployment_path = os.path.dirname(os.path.dirname(os.path.dirname(pearl.__file__))) + deployment_path = os.path.dirname(os.path.dirname(os.path.dirname(pearl_bec.__file__))) files = os.listdir(deployment_path) if "bec_config.yaml" in files: return ServiceConfig(config_path=os.path.join(deployment_path, "bec_config.yaml")) diff --git a/pearl/bec_widgets/__init__.py b/pearl_bec/bec_widgets/__init__.py similarity index 100% rename from pearl/bec_widgets/__init__.py rename to pearl_bec/bec_widgets/__init__.py diff --git a/pearl/bec_widgets/auto_updates/__init__.py b/pearl_bec/bec_widgets/auto_updates/__init__.py similarity index 100% rename from pearl/bec_widgets/auto_updates/__init__.py rename to pearl_bec/bec_widgets/auto_updates/__init__.py diff --git a/pearl/bec_widgets/widgets/__init__.py b/pearl_bec/bec_widgets/widgets/__init__.py similarity index 100% rename from pearl/bec_widgets/widgets/__init__.py rename to pearl_bec/bec_widgets/widgets/__init__.py diff --git a/pearl/deployments/__init__.py b/pearl_bec/deployments/__init__.py similarity index 100% rename from pearl/deployments/__init__.py rename to pearl_bec/deployments/__init__.py diff --git a/pearl/deployments/device_server/__init__.py b/pearl_bec/deployments/device_server/__init__.py similarity index 100% rename from pearl/deployments/device_server/__init__.py rename to pearl_bec/deployments/device_server/__init__.py diff --git a/pearl/deployments/device_server/startup.py b/pearl_bec/deployments/device_server/startup.py similarity index 100% rename from pearl/deployments/device_server/startup.py rename to pearl_bec/deployments/device_server/startup.py diff --git a/pearl/device_configs/__init__.py b/pearl_bec/device_configs/__init__.py similarity index 100% rename from pearl/device_configs/__init__.py rename to pearl_bec/device_configs/__init__.py diff --git a/pearl/devices/__init__.py b/pearl_bec/devices/__init__.py similarity index 100% rename from pearl/devices/__init__.py rename to pearl_bec/devices/__init__.py diff --git a/pearl/file_writer/__init__.py b/pearl_bec/file_writer/__init__.py similarity index 100% rename from pearl/file_writer/__init__.py rename to pearl_bec/file_writer/__init__.py diff --git a/pearl/macros/README.md b/pearl_bec/macros/README.md similarity index 86% rename from pearl/macros/README.md rename to pearl_bec/macros/README.md index f846214..96cb0ff 100644 --- a/pearl/macros/README.md +++ b/pearl_bec/macros/README.md @@ -2,5 +2,5 @@ This directory is intended to store macros which will be loaded automatically when starting BEC. Macros are small functions to make repetitive tasks easier. Functions defined in python files in this directory will be accessible from the BEC console. -Please do not put any code outside of function definitions here. If you wish for code to be automatically run when starting BEC, see the startup script at pearl/bec_ipython_client/startup/post_startup.py +Please do not put any code outside of function definitions here. If you wish for code to be automatically run when starting BEC, see the startup script at pearl_bec/bec_ipython_client/startup/post_startup.py For a guide on writing macros, please see: https://bec.readthedocs.io/en/latest/user/command_line_interface.html#how-to-write-a-macro diff --git a/pearl/macros/__init__.py b/pearl_bec/macros/__init__.py similarity index 100% rename from pearl/macros/__init__.py rename to pearl_bec/macros/__init__.py diff --git a/pearl/scans/__init__.py b/pearl_bec/scans/__init__.py similarity index 100% rename from pearl/scans/__init__.py rename to pearl_bec/scans/__init__.py diff --git a/pearl/scans/metadata_schema/__init__.py b/pearl_bec/scans/metadata_schema/__init__.py similarity index 100% rename from pearl/scans/metadata_schema/__init__.py rename to pearl_bec/scans/metadata_schema/__init__.py diff --git a/pearl/scans/metadata_schema/metadata_schema_registry.py b/pearl_bec/scans/metadata_schema/metadata_schema_registry.py similarity index 100% rename from pearl/scans/metadata_schema/metadata_schema_registry.py rename to pearl_bec/scans/metadata_schema/metadata_schema_registry.py diff --git a/pearl/scans/metadata_schema/metadata_schema_template.py b/pearl_bec/scans/metadata_schema/metadata_schema_template.py similarity index 100% rename from pearl/scans/metadata_schema/metadata_schema_template.py rename to pearl_bec/scans/metadata_schema/metadata_schema_template.py diff --git a/pearl/services/__init__.py b/pearl_bec/services/__init__.py similarity index 100% rename from pearl/services/__init__.py rename to pearl_bec/services/__init__.py diff --git a/pyproject.toml b/pyproject.toml index 9f1078a..20e84b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "pearl" +name = "pearl_bec" version = "0.0.0" description = "A plugin repository for BEC" -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", @@ -28,29 +28,29 @@ dev = [ ] [project.entry-points."bec"] -plugin_bec = "pearl" +plugin_bec = "pearl_bec" [project.entry-points."bec.deployment.device_server"] -plugin_ds_startup = "pearl.deployments.device_server.startup:run" +plugin_ds_startup = "pearl_bec.deployments.device_server.startup:run" [project.entry-points."bec.file_writer"] -plugin_file_writer = "pearl.file_writer" +plugin_file_writer = "pearl_bec.file_writer" [project.entry-points."bec.scans"] -plugin_scans = "pearl.scans" +plugin_scans = "pearl_bec.scans" [project.entry-points."bec.scans.metadata_schema"] -plugin_metadata_schema = "pearl.scans.metadata_schema" +plugin_metadata_schema = "pearl_bec.scans.metadata_schema" [project.entry-points."bec.ipython_client_startup"] -plugin_ipython_client_pre = "pearl.bec_ipython_client.startup.pre_startup" -plugin_ipython_client_post = "pearl.bec_ipython_client.startup" +plugin_ipython_client_pre = "pearl_bec.bec_ipython_client.startup.pre_startup" +plugin_ipython_client_post = "pearl_bec.bec_ipython_client.startup" [project.entry-points."bec.widgets.auto_updates"] -plugin_widgets_update = "pearl.bec_widgets.auto_updates" +plugin_widgets_update = "pearl_bec.bec_widgets.auto_updates" [project.entry-points."bec.widgets.user_widgets"] -plugin_widgets = "pearl.bec_widgets.widgets" +plugin_widgets = "pearl_bec.bec_widgets.widgets" [tool.hatch.build.targets.wheel] include = ["*"]