You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-11Lines changed: 16 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ Table of contents:
32
32
33
33
## 📌 Introduction
34
34
35
+
<!--TODO: Add links to STARS, relevant publication, and https://github.com/pythonhealthdatascience/rap_des/ -->
36
+
35
37
This repository provides a template for building discrete-event simulation (DES) models in Python.
36
38
37
39
😊 **Simple:** Easy-to-follow code structure using [SimPy](https://simpy.readthedocs.io/en/latest/). Implements a simple M/M/s queueing model in which patients arrive, wait to see a nurse, have a consultation with the nurse and then leave. Follows a modular structure: uses object-oriented programming, with the simulation implemented through classes.
@@ -52,9 +54,9 @@ This repository provides a template for building discrete-event simulation (DES)
52
54
53
55
For clarity, changes from the DES book in this template are explained in `docs/hsma_changes.md`.
54
56
55
-
✨ **Style and structure:** The coding style is based on the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html). Linting is implemented using `flake8` and `pylint` for `.py` files, and `pycodestyle` for `.ipynb` files. While this repository is designed to be used as a template—helping you create a new repository with all relevant metadata (e.g., `README.md`, `CITATION.cff`, `LICENSE`) and scripts—it also adheres to a package-like structure. This is aligned with the NHS Gold RAP tier, and key indicators of this structure include `__init__.py` marking directories to be treated like packages, and `pyproject.toml` specifying package metadata.
57
+
✨ **Style:** The coding style is based on the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html). Linting is implemented using `flake8` and `pylint` for `.py` files, and `pycodestyle` for `.ipynb` files.
56
58
57
-
<!--TODO: Add links to STARS, relevant publication, and https://github.com/pythonhealthdatascience/rap_des/ -->
59
+
🧱 **Package structure:** In Python, a package can simply be defined as a directory with an `__init__.py` file in it. In this repository, the scripts for model (within `simulation/`) are treated as a little local package. This keeps the code model code isolated from our experiments and analysis. It is installed as an editable (`-e`) local import - with `-e` meaning it will update with changes to the local files in `simulation/`. As it is installed in our environment, it can then easily be used anywhere else in the directory - here, in `notebooks/`and `tests/` - without needing any additional code (e.g. no need to modify `sys.path`, or have additional `__init__.py` files).
58
60
59
61
<br>
60
62
@@ -125,7 +127,7 @@ As an alternative, a `requirements.txt` file is provided which can be used to se
125
127
126
128
🔎 Choose your desired licence (e.g. <https://choosealicense.com/>). If keeping an MIT licence, just modify the copyright holder in `LICENSE`.
127
129
128
-
🔎 Review the example DES implementation in `scripts`. Modify and extend the code as needed for your specific use case.
130
+
🔎 Review the example DES implementation in `simulation` and `notebooks`. Modify and extend the code as needed for your specific use case.
129
131
130
132
🔎 Check you still fulfil the criteria in `docs/nhs_rap.md` and `docs/heather_2025.md`.
131
133
@@ -156,8 +158,8 @@ If you have changed the model behaviour, you may wish to amend, remove or write
156
158
You can lint the `.py` files by running either of this commands from the terminal:
157
159
158
160
```
159
-
flake8 scripts/simulation/model.py
160
-
pylint scripts/simulation/model.py
161
+
flake8 simulation/model.py
162
+
pylint simulation/model.py
161
163
```
162
164
163
165
The first commands in the `.ipynb` files will lint the notebooks using `pycodestyle` when executed:
@@ -201,15 +203,18 @@ This section describes the purposes of each class in the simulation.
201
203
repo/
202
204
├── .github/workflows/ # GitHub actions
203
205
├── docs/ # Documentation
204
-
├── scripts/ # Code for DES model and analysis
205
-
├── tests/ # Unit tests
206
+
├── inputs/ # Folder to store any input data
207
+
├── notebooks/ # Run DES model and analyse results
208
+
├── outputs/ # Folder to save any outputs from model
209
+
├── simulation/ # Local package containing code for the DES model
210
+
├── tests/ # Unit and back testing of the DES model
206
211
├── .gitignore # Untracked files
207
212
├── CHANGELOG.md # Describes changes between releases
├── pyproject.toml # Project metadata and build system configuration
217
+
├── pyproject.toml # Metadata for local `simulation/` package
213
218
├── README.md # This file! Describes the repository
214
219
└── requirements.txt # Virtual environment (used by GitHub actions)
215
220
```
@@ -218,7 +223,7 @@ repo/
218
223
219
224
## ⏰ Run time and machine specification
220
225
221
-
As this a template, it is not possible to provide an overall run time, as this will vary depending on how the template model is used. However, this information is provided from some example implementations, within the `.ipynb` files in `scripts`. These times were obtained on an Intel Core i7-12700H with 32GB RAM running Ubuntu 24.04.1 Linux.
226
+
As this a template, it is not possible to provide an overall run time, as this will vary depending on how the template model is used. However, this information is provided from some example implementations, within the `.ipynb` files in `notebooks`. These times were obtained on an Intel Core i7-12700H with 32GB RAM running Ubuntu 24.04.1 Linux.
222
227
223
228
<br>
224
229
@@ -312,8 +317,8 @@ Provide step-by-step instructions and examples.
312
317
313
318
Clearly indicate which files will create each figure in the paper. Hypothetical example:
314
319
315
-
* To generate **Figures 1 and 2**, execute `scripts/simulation/base_case.ipynb`
316
-
* To generate **Table 1** and **Figures 3 to 5**, execute `scripts/simulation/scenario_analysis.ipynb`
320
+
* To generate **Figures 1 and 2**, execute `notebooks/base_case.ipynb`
321
+
* To generate **Table 1** and **Figures 3 to 5**, execute `notebooks/scenario_analysis.ipynb`
Copy file name to clipboardExpand all lines: docs/nhs_rap.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ Meeting all of the above requirements, plus:
44
44
45
45
| Criteria | Completion | Further details |
46
46
| - | - | - |
47
-
| Code is fully [packaged](https://packaging.python.org/en/latest/). | ✅ |`__init__.py` (shows directory should be treated like package) and `pyproject.toml` (specifies package details). Based on src/package layout described by [PyOpenSci](https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-structure.html)|
47
+
| Code is fully [packaged](https://packaging.python.org/en/latest/). | ✅ |With thanks to [Joshua Cook](https://joshuacook.netlify.app/posts/2024-07-27_python-data-analysis-org/), whose blog post I used to help me structure this analysis as a package.|
48
48
| Repository automatically runs tests etc. via CI/CD or a different integration/deployment tool e.g. [GitHub Actions](https://docs.github.com/en/actions). | ✅ |`.github/workflows/tests.yaml`|
49
49
| Process runs based on event-based triggers (e.g., new data in database) or on a schedule. | N/A | - |
50
50
| Changes to the RAP are clearly signposted. E.g. a changelog in the package, releases etc. (See gov.uk info on [Semantic Versioning](https://github.com/alphagov/govuk-frontend/blob/main/docs/contributing/versioning.md)). | ✅ |`CHANGELOG.md` and GitHub releases |
0 commit comments