Skip to content

Commit

Permalink
Merge pull request #48 from DiamondLightSource/copier-update
Browse files Browse the repository at this point in the history
Update to copier template to 2.1.0-40-g9e70b8b
  • Loading branch information
GDYendell authored Jul 26, 2024
2 parents db33d03 + b51eaf9 commit 178eb0a
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 2.0.2-10-g0eb87d2
_commit: 2.1.0-40-g9e70b8b
_src_path: gh:DiamondLightSource/python-copier-template
author_email: [email protected]
author_name: Gary Yendell
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
}
}
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua

This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.

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.0.2/how-to.html).
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.1.0/how-to.html).
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug Report
about: The template to use for reporting bugs and usability issues
title: " "
labels: 'bug'
assignees: ''

---

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).

## Steps To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error


## Acceptance Criteria
- Specific criteria that will be used to judge if the issue is fixed
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Issue
about: The standard template to use for feature requests, design discussions and tasks
title: " "
labels: ''
assignees: ''

---

A brief description of the issue, including specific stakeholders and the business case where appropriate

## Acceptance Criteria
- Specific criteria that will be used to judge if the issue is fixed
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Fixes #ISSUE

### Instructions to reviewer on how to test:
1. Do thing x
2. Confirm thing y happens

### Checks for reviewer
- [ ] Would the PR title make sense to a user on a set of release notes
2 changes: 1 addition & 1 deletion .github/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<link rel="canonical" href="main/index.html">
</head>

</html>
</html>
4 changes: 2 additions & 2 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
if: github.ref_type == 'tag' || github.ref_name == 'main'
# 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: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true
keep_files: true
2 changes: 1 addition & 1 deletion .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Create 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@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: "*"
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repos:
- id: check-added-large-files
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: local
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"recommendations": [
"ms-vscode-remote.remote-containers",
]
}
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"files.insertFinalNewline": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"problemMatcher": [],
}
]
}
}
2 changes: 1 addition & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ metadata:
spec:
type: documentation
lifecycle: experimental
owner: user:mef65357
owner: user:mef65357
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,5 @@
html_show_copyright = False

# Logo
html_logo = "images/fastcs.svg"
html_favicon = "images/fastcs.svg"
html_logo = "images/dls-logo.svg"
html_favicon = html_logo
2 changes: 1 addition & 1 deletion docs/how-to/contribute.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
```{include} ../../.github/CONTRIBUTING.md
```
```
11 changes: 11 additions & 0 deletions docs/images/dls-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 8 additions & 15 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# API

This is the internal API reference for fastcs. The key modules are summarised below.

## Controllers

```{eval-rst}
.. automodule:: fastcs.controller
:members:
```
.. automodule:: fastcs
## Attributes

```{eval-rst}
.. automodule:: fastcs.attributes
:members:
``fastcs``
-----------------------------------
```

## Datatypes
This is the internal API reference for fastcs

```{eval-rst}
.. automodule:: fastcs.datatypes
:members:
.. data:: fastcs.__version__
:type: str
Version number as calculated by https://github.com/pypa/setuptools_scm
```
25 changes: 16 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
build-backend = "setuptools.build_meta"

[project]
Expand Down Expand Up @@ -55,7 +55,7 @@ name = "Martin Gaughran"


[tool.setuptools_scm]
write_to = "src/fastcs/_version.py"
version_file = "src/fastcs/_version.py"

[tool.mypy]
ignore_missing_imports = true # Ignore missing stubs in imported modules
Expand Down Expand Up @@ -105,11 +105,18 @@ commands =
src = ["src", "tests"]
line-length = 88
lint.select = [
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
"SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self
]

[tool.ruff.lint.per-file-ignores]
# By default, private member access is allowed in tests
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
# Remove this line to forbid private member access in tests
"tests/**/*" = ["SLF001"]
8 changes: 5 additions & 3 deletions src/fastcs/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ def allowed_values(self) -> list[str] | None:
return self._allowed_values

async def process(self, value: T) -> None:
if self._write_display_callback is not None:
await self._write_display_callback(self._datatype.dtype(value))

await self.process_without_display_update(value)
await self.update_display_without_process(value)

async def process_without_display_update(self, value: T) -> None:
if self._process_callback is not None:
await self._process_callback(self._datatype.dtype(value))

async def update_display_without_process(self, value: T) -> None:
if self._write_display_callback is not None:
await self._write_display_callback(self._datatype.dtype(value))

def set_process_callback(self, callback: AttrCallback[T] | None) -> None:
self._process_callback = callback

Expand Down
2 changes: 1 addition & 1 deletion src/fastcs/backends/epics/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _get_input_record(pv_name: str, datatype: DataType) -> RecordWrapper:


def _create_and_link_read_pv(pv_name: str, attribute: AttrR) -> None:
record = _get_input_record(pv_name, attribute._datatype)
record = _get_input_record(pv_name, attribute.datatype)

async def async_wrapper(v):
record.set(v)
Expand Down
2 changes: 1 addition & 1 deletion src/fastcs/backends/tango/dsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def register_dev(dev_name: str, dev_class: str, dsr_instance: str) -> None:
dsr_name = f"{dev_class}/{dsr_instance}"
dev_info = DbDevInfo()
dev_info.name = dev_name
dev_info._class = dev_class
dev_info._class = dev_class # noqa
dev_info.server = dsr_name

db = Database()
Expand Down
12 changes: 7 additions & 5 deletions src/fastcs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def path(self) -> list[str]:
"""Path prefix of attributes, recursively including parent ``Controller``s."""
return self._path

def set_path(self, path: list[str]):
if self._path:
raise ValueError(f"SubController is already registered under {self.path}")

self._path = path

def _bind_attrs(self) -> None:
for attr_name in dir(self):
attr = getattr(self, attr_name)
Expand All @@ -29,13 +35,9 @@ def register_sub_controller(self, name: str, sub_controller: SubController):
raise ValueError(
f"Controller {self} already has a SubController registered as {name}"
)
if sub_controller.path:
raise ValueError(
f"SubController is already registered under {sub_controller.path}"
)

self.__sub_controller_tree[name] = sub_controller
sub_controller._path = self.path + [name]
sub_controller.set_path(self.path + [name])

def get_sub_controllers(self) -> dict[str, BaseController]:
return self.__sub_controller_tree
Expand Down

0 comments on commit 178eb0a

Please sign in to comment.