Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Publish Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
- name: Publish to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
run: |
twine upload --repository testpypi dist/*

# Updated verification step with basic import test instead of pytest
- name: Verify package from TestPyPI
run: |
# Wait for TestPyPI to process the upload
sleep 60

# Create a new virtual environment for testing
python -m venv test_env
source test_env/bin/activate

# Install the package from TestPyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ patientflow

# Perform a basic import test (more reliable than requiring pytest)
python -c "import patientflow; print(f'Successfully installed patientflow version: {patientflow.__version__}')"

# Deactivate the virtual environment
deactivate

# Add a manual approval step before publishing to PyPI
- name: Request approval for PyPI publish
uses: trstringer/manual-approval@v1
with:
secret: ${{ secrets.GITHUB_TOKEN }}
approvers: zmek
minimum-approvals: 1
issue-title: "Approve PyPI Deployment for ${{ github.event.release.tag_name }}"
issue-body: "The package has been successfully published to TestPyPI and verified. Please approve to publish to PyPI."
exclude-workflow-initiator-as-approver: false

- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
[![Linting status][linting-badge]][linting-link]
[![Documentation status][documentation-badge]][documentation-link]
[![License][license-badge]](./LICENSE.md)

<!--
[![PyPI version][pypi-version]][pypi-link]
[![Conda-Forge][conda-badge]][conda-link]
[![PyPI platforms][pypi-platforms]][pypi-link]
-->

<!-- prettier-ignore-start -->
[tests-badge]: https://github.com/zmek/patientflow/actions/workflows/tests.yml/badge.svg
Expand All @@ -19,14 +15,11 @@
[linting-link]: https://github.com/zmek/patientflow/actions/workflows/linting.yml
[documentation-badge]: https://github.com/zmek/patientflow/actions/workflows/docs.yml/badge.svg
[documentation-link]: https://github.com/zmek/patientflow/actions/workflows/docs.yml
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/patientflow
[conda-link]: https://github.com/conda-forge/patientflow-feedstock
[license-badge]: https://img.shields.io/badge/License-MIT-yellow.svg
[![ORCID](https://img.shields.io/badge/ORCID-0000--0001--7389--1527-green.svg)](https://orcid.org/0000-0001-7389-1527)

<!-- [pypi-link]: https://pypi.org/project/patientflow/
[pypi-link]: https://pypi.org/project/patientflow/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/patientflow
[pypi-version]: https://img.shields.io/pypi/v/patientflow -->
[pypi-version]: https://img.shields.io/pypi/v/patientflow
[![ORCID](https://img.shields.io/badge/ORCID-0000--0001--7389--1527-green.svg)](https://orcid.org/0000-0001-7389-1527)
<!-- prettier-ignore-end -->

## Summary
Expand Down Expand Up @@ -90,18 +83,22 @@ This snapshot-based approach to predicting demand generalises to other aspects o

### Installation

To install the latest development version, clone it first (so that you have access to the synthetic data and the notebooks) and then install it.
You can install `patientflow` directly from PyPI:

```sh
git clone https://github.com/zmek/patientflow.git
cd patientflow
pip install -e ".[test]" #this will install the code in test mode
pip install patientflow
```

To access the example notebooks and synthetic data, clone the repository:

```sh
git clone https://github.com/ucl-coru/patientflow.git
cd patientflow
```

### Development Installation (optional)

If you plan to contribute to the project or run documentation locally, install the development and documentation dependencies:
If you want to contribute or modify the code, or run documentation locally, install the development and documentation dependencies:

```sh
# For development tools (linting, formatting, etc.)
Expand Down Expand Up @@ -208,8 +205,8 @@ Thank you for contributing!
## Roadmap

- [x] Initial Research
- [x] Minimum viable product <-- You are Here
- [ ] Alpha Release
- [x] Minimum viable product
- [x] Alpha Release (PyPI Package) <-- You are Here
- [ ] Feature-Complete Release

### Project Team
Expand Down
5 changes: 3 additions & 2 deletions docs/notebooks/0_Set_up_your_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ try:
import patientflow
print(f"✓ patientflow {patientflow.__version__} imported successfully")
except ImportError:
print("❌ patientflow not found - please check installation instructions in README")
print(" pip install -e '.[test]'")
print("❌ patientflow not found - please install using one of the following methods:")
print(" From PyPI: pip install patientflow")
print(" For development: pip install -e '.[test]'")
except Exception as e:
print(f"❌ Error: {e}")
```
Expand Down
10 changes: 9 additions & 1 deletion docs/notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ A set of notebooks follow, to show how we have used the functions in `patientflo

## Preparing your notebook environment

The `PATH_TO_PATIENTFLOW` environment variable needs to be set so notebooks know where the patientflow repository resides on your computer. You have various options:
### Installation

You can install the `patientflow` package directly from PyPI:

```bash
pip install patientflow
```

For development purposes or to run these notebooks with the latest code, you may still want to use the Github repository directly. In that case, the `PATH_TO_PATIENTFLOW` environment variable needs to be set so notebooks know where the patientflow repository resides on your computer. You have various options:

- use a virtual environment and set PATH_TO_PATIENTFLOW up within that
- set PATH_TO_PATIENTFLOW globally on your computer
Expand Down
5 changes: 3 additions & 2 deletions notebooks/0_Set_up_your_environment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
" import patientflow\n",
" print(f\"✓ patientflow {patientflow.__version__} imported successfully\")\n",
"except ImportError:\n",
" print(\"❌ patientflow not found - please check installation instructions in README\")\n",
" print(\" pip install -e '.[test]'\")\n",
" print(\"❌ patientflow not found - please install using one of the following methods:\")\n",
" print(\" From PyPI: pip install patientflow\")\n",
" print(\" For development: pip install -e '.[test]'\")\n",
"except Exception as e:\n",
" print(f\"❌ Error: {e}\")"
]
Expand Down
10 changes: 9 additions & 1 deletion notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ A set of notebooks follow, to show how we have used the functions in `patientflo

## Preparing your notebook environment

The `PATH_TO_PATIENTFLOW` environment variable needs to be set so notebooks know where the patientflow repository resides on your computer. You have various options:
### Installation

You can install the `patientflow` package directly from PyPI:

```bash
pip install patientflow
```

For development purposes or to run these notebooks with the latest code, you may still want to use the Github repository directly. In that case, the `PATH_TO_PATIENTFLOW` environment variable needs to be set so notebooks know where the patientflow repository resides on your computer. You have various options:

- use a virtual environment and set PATH_TO_PATIENTFLOW up within that
- set PATH_TO_PATIENTFLOW globally on your computer
Expand Down
6 changes: 5 additions & 1 deletion src/patientflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
making predictions about emergency demand, elective demand, and hospital discharges.
"""

__version__ = "0.2.0"
try:
from ._version import __version__
except ImportError:
__version__ = "0.0.0" # Fallback for when not installed

__author__ = "Zella King"
__email__ = "zella.king@ucl.ac.uk"
Loading