Skip to content

Commit 58799b5

Browse files
committed
first commit
0 parents  commit 58799b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1665
-0
lines changed

.copier-answers.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changes here will be overwritten by Copier
2+
_commit: 2.6.0
3+
_src_path: gh:DiamondLightSource/python-copier-template
4+
author_email: [email protected]
5+
author_name: Raymond Fan
6+
component_lifecycle: production
7+
component_owner: ''
8+
component_type: library
9+
description: Bluesky code for Diamond's surface and magnetic materials beamline.
10+
distribution_name: sm_bluesky
11+
docker: false
12+
docs_type: sphinx
13+
git_platform: github.com
14+
github_org: DiamondLightSource
15+
package_name: sm_bluesky
16+
pypi: false
17+
repo_name: sm-bluesky
18+
type_checker: pyright

.devcontainer/devcontainer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// For format details, see https://containers.dev/implementors/json_reference/
2+
{
3+
"name": "Python 3 Developer Container",
4+
"build": {
5+
"dockerfile": "../Dockerfile",
6+
"target": "developer"
7+
},
8+
"remoteEnv": {
9+
// Allow X11 apps to run inside the container
10+
"DISPLAY": "${localEnv:DISPLAY}"
11+
},
12+
"customizations": {
13+
"vscode": {
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {
16+
"python.defaultInterpreterPath": "/venv/bin/python"
17+
},
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"ms-python.python",
21+
"github.vscode-github-actions",
22+
"tamasfe.even-better-toml",
23+
"redhat.vscode-yaml",
24+
"ryanluker.vscode-coverage-gutters",
25+
"charliermarsh.ruff",
26+
"ms-azuretools.vscode-docker"
27+
]
28+
}
29+
},
30+
"features": {
31+
// add in eternal history and other bash features
32+
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1.0.0": {}
33+
},
34+
// Create the config folder for the bash-config feature
35+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
36+
"runArgs": [
37+
// Allow the container to access the host X11 display and EPICS CA
38+
"--net=host",
39+
// Make sure SELinux does not disable with access to host filesystems like tmp
40+
"--security-opt=label=disable"
41+
],
42+
// Mount the parent as /workspaces so we can pip install peers as editable
43+
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
44+
// After the container is created, install the python project in editable form
45+
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
46+
}

.github/CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contribute to the project
2+
3+
Contributions and issues are most welcome! All issues and pull requests are
4+
handled through [GitHub](https://github.com/DiamondLightSource/sm-bluesky/issues). Also, please check for any existing issues before
5+
filing a new one. If you have a great idea but it involves big changes, please
6+
file a ticket before making a pull request! We want to make sure you don't spend
7+
your time coding something that might not fit the scope of the project.
8+
9+
## Issue or Discussion?
10+
11+
Github also offers [discussions](https://github.com/DiamondLightSource/sm-bluesky/discussions) as a place to ask questions and share ideas. If
12+
your issue is open ended and it is not obvious when it can be "closed", please
13+
raise it as a discussion instead.
14+
15+
## Code Coverage
16+
17+
While 100% code coverage does not make a library bug-free, it significantly
18+
reduces the number of easily caught bugs! Please make sure coverage remains the
19+
same or is improved by a pull request!
20+
21+
## Developer Information
22+
23+
It is recommended that developers use a [vscode devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). This repository contains configuration to set up a containerized development environment that suits its own needs.
24+
25+
This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.
26+
27+
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.6.0/how-to.html).

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug Report
3+
about: The template to use for reporting bugs and usability issues
4+
title: " "
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
Describe the bug, including a clear and concise description of the expected behavior, the actual behavior and the context in which you encountered it (ideally include details of your environment).
11+
12+
## Steps To Reproduce
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Click on '....'
16+
3. Scroll down to '....'
17+
4. See error
18+
19+
20+
## Acceptance Criteria
21+
- Specific criteria that will be used to judge if the issue is fixed

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Issue
3+
about: The standard template to use for feature requests, design discussions and tasks
4+
title: " "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
A brief description of the issue, including specific stakeholders and the business case where appropriate
11+
12+
## Acceptance Criteria
13+
- Specific criteria that will be used to judge if the issue is fixed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Fixes #ISSUE
2+
3+
### Instructions to reviewer on how to test:
4+
1. Do thing x
5+
2. Confirm thing y happens
6+
7+
### Checks for reviewer
8+
- [ ] Would the PR title make sense to a user on a set of release notes
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Install requirements
2+
description: Install a version of python then call pip install and report what was installed
3+
inputs:
4+
python-version:
5+
description: Python version to install, default is from Dockerfile
6+
default: "dev"
7+
pip-install:
8+
description: Parameters to pass to pip install
9+
default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]"
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Get version of python
15+
run: |
16+
PYTHON_VERSION="${{ inputs.python-version }}"
17+
if [ $PYTHON_VERSION == "dev" ]; then
18+
PYTHON_VERSION=$(sed -n "s/ARG PYTHON_VERSION=//p" Dockerfile)
19+
fi
20+
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV"
21+
shell: bash
22+
23+
- name: Setup python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
28+
- name: Install packages
29+
run: pip install ${{ inputs.pip-install }}
30+
shell: bash
31+
32+
- name: Report what was installed
33+
run: pip freeze
34+
shell: bash

.github/dependabot.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
groups:
13+
actions:
14+
patterns:
15+
- "*"
16+
17+
- package-ecosystem: "pip"
18+
directory: "/"
19+
schedule:
20+
interval: "weekly"
21+
groups:
22+
dev-dependencies:
23+
patterns:
24+
- "*"

.github/pages/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Redirecting to main branch</title>
6+
<meta charset="utf-8">
7+
<meta http-equiv="refresh" content="0; url=./main/index.html">
8+
<link rel="canonical" href="main/index.html">
9+
</head>
10+
11+
</html>

.github/pages/make_switcher.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
"""Make switcher.json to allow docs to switch between different versions."""
2+
3+
import json
4+
import logging
5+
from argparse import ArgumentParser
6+
from pathlib import Path
7+
from subprocess import CalledProcessError, check_output
8+
9+
10+
def report_output(stdout: bytes, label: str) -> list[str]:
11+
"""Print and return something received frm stdout."""
12+
ret = stdout.decode().strip().split("\n")
13+
print(f"{label}: {ret}")
14+
return ret
15+
16+
17+
def get_branch_contents(ref: str) -> list[str]:
18+
"""Get the list of directories in a branch."""
19+
stdout = check_output(["git", "ls-tree", "-d", "--name-only", ref])
20+
return report_output(stdout, "Branch contents")
21+
22+
23+
def get_sorted_tags_list() -> list[str]:
24+
"""Get a list of sorted tags in descending order from the repository."""
25+
stdout = check_output(["git", "tag", "-l", "--sort=-v:refname"])
26+
return report_output(stdout, "Tags list")
27+
28+
29+
def get_versions(ref: str, add: str | None) -> list[str]:
30+
"""Generate the file containing the list of all GitHub Pages builds."""
31+
# Get the directories (i.e. builds) from the GitHub Pages branch
32+
try:
33+
builds = set(get_branch_contents(ref))
34+
except CalledProcessError:
35+
builds = set()
36+
logging.warning(f"Cannot get {ref} contents")
37+
38+
# Add and remove from the list of builds
39+
if add:
40+
builds.add(add)
41+
42+
# Get a sorted list of tags
43+
tags = get_sorted_tags_list()
44+
45+
# Make the sorted versions list from main branches and tags
46+
versions: list[str] = []
47+
for version in ["master", "main"] + tags:
48+
if version in builds:
49+
versions.append(version)
50+
builds.remove(version)
51+
52+
# Add in anything that is left to the bottom
53+
versions += sorted(builds)
54+
print(f"Sorted versions: {versions}")
55+
return versions
56+
57+
58+
def write_json(path: Path, repository: str, versions: list[str]):
59+
"""Write the JSON switcher to path."""
60+
org, repo_name = repository.split("/")
61+
struct = [
62+
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
63+
for version in versions
64+
]
65+
text = json.dumps(struct, indent=2)
66+
print(f"JSON switcher:\n{text}")
67+
path.write_text(text, encoding="utf-8")
68+
69+
70+
def main(args=None):
71+
"""Parse args and write switcher."""
72+
parser = ArgumentParser(
73+
description="Make a versions.json file from gh-pages directories"
74+
)
75+
parser.add_argument(
76+
"--add",
77+
help="Add this directory to the list of existing directories",
78+
)
79+
parser.add_argument(
80+
"repository",
81+
help="The GitHub org and repository name: ORG/REPO",
82+
)
83+
parser.add_argument(
84+
"output",
85+
type=Path,
86+
help="Path of write switcher.json to",
87+
)
88+
args = parser.parse_args(args)
89+
90+
# Write the versions file
91+
versions = get_versions("origin/gh-pages", args.add)
92+
write_json(args.output, args.repository, versions)
93+
94+
95+
if __name__ == "__main__":
96+
main()

0 commit comments

Comments
 (0)