Skip to content

Commit

Permalink
update devnotes (#30)
Browse files Browse the repository at this point in the history
* update devnotes

* Update README.md

* Update devnotes.md

* updated notebooks and dependencies

---------

Co-authored-by: Thibaud Coroller <[email protected]>
Co-authored-by: corolth1 <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent b707d2f commit f69f163
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 137 deletions.
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,8 @@ or for local installation (from package root / clone of this git repository):
pip install -e .
```

If you use Conda, you can install requirements into a conda environment
using the `environment.yml` file included in the `dev` subfolder of the source repository.

Using the package has the following dependencies which will be installed automatically via pip:

* [torch](https://pytorch.org/): Consider pre-installing if you have specific system requirements (CPU / GPU / CUDA version).
* [scipy](https://scipy.org/): We use some statistical helper functions to calculate metrics.
* [torchmetrics](https://lightning.ai/docs/torchmetrics/stable/): We use some statistical helper functions to calculate metrics.

To run the tests and example notebooks, you need to install the following additional packages:

* [lifelines](https://lifelines.readthedocs.io/en/latest/)
* [scikit-survival](https://scikit-survival.readthedocs.io/en/stable/)
* [pytorch_lightning](https://lightning.ai/docs/pytorch/stable/) (and [lightning](https://lightning.ai/))

To build the documentation and for package development, please see [the development notes](https://opensource.nibr.com/torchsurv/devnotes.html) and
[dev/environment.yml](dev/environment.yml).
Additionally, to build the documentation (`notebooks`, `sphinx`) and for package development (`tests`), please see [the development notes](https://opensource.nibr.com/torchsurv/devnotes.html) and
[dev/environment.yml](dev/environment.yml). This step is **not required** to use `TorchSurv` in your projects but only for optional features.

## Getting started

Expand Down
56 changes: 55 additions & 1 deletion docs/devnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## Set up a development environment via conda

If you use Conda, you can install requirements into a conda environment
using the `environment.yml` file included in the `dev` subfolder of the source repository.

Using the package has the following dependencies which will be installed automatically via pip:

* [torch](https://pytorch.org/): Consider pre-installing if you have specific system requirements (CPU / GPU / CUDA version).
* [scipy](https://scipy.org/): We use some statistical helper functions to calculate metrics.
* [torchmetrics](https://lightning.ai/docs/torchmetrics/stable/): We use some statistical helper functions to calculate metrics.

To run the tests and example notebooks, you need to install the following additional packages:

* [lifelines](https://lifelines.readthedocs.io/en/latest/)
* [scikit-survival](https://scikit-survival.readthedocs.io/en/stable/)
* [pytorch_lightning](https://lightning.ai/docs/pytorch/stable/) (and [lightning](https://lightning.ai/))

To use conda to install all package dependencies locally and start development,
run the following commands in the root directory of the repository.

Expand All @@ -20,7 +35,7 @@ conda activate torchsurv

## Test and develop the package

To run all unit tests either use `dev/run-unittests.sh` or run the
To run all unit tests either use `dev/run-unittests.sh` or run the
following command from the repository root directory:

```bash
Expand Down Expand Up @@ -100,3 +115,42 @@ make latexpdf LATEXMKOPTS="-silent -f"
There are a few errors in the PDF build due to layout issues,
but the PDF can still be used to summarize the package in a single
file.

## Steps to create a new release

Follow the steps below, ensure each one is successful.

1. Update the version number in `pyproject.toml`.
2. Ensure [CHANGELOG.md](CHANGELOG.md) is up-to-date with the new version number and changes.
3. Ensure all PRs to be included are merged with `main`, pushed to Github and that all tests & checks have run successfully.
4. Build the release from the latest main branch: `git checkout main && git pull && rm -rf dist && python -m build`
5. Check the built package: `python -m twine check dist/*`
6. Upload the package to testPyPI: `python -m twine upload -r testpypi dist/*`
7. Check if the package can be installed (also check this installs the correct version):

```bash
rm -rf testenv # ensure a new test env is created
python -m virtualenv testenv
. ./testenv/bin/activate
# these don't simply install from testpypi
pip install torch torchmetrics scipy numpy
pip install -i https://test.pypi.org/simple/ torchsurv
python
>>> from torchsurv.loss import cox
>>> from torchsurv.metrics.cindex import ConcordanceIndex
```

8. Upload to pypi: `python -m twine upload -r pypi dist/*`
9. Check that the package can be installed:

```bash
rm -rf testenv # ensure a new test env is created
python -m virtualenv testenv
. ./testenv/bin/activate
pip install torchsurv
python
>>> from torchsurv.loss import cox
>>> from torchsurv.metrics.cindex import ConcordanceIndex
```

10. Create a new tag for the release, e.g. `git tag -a v0.1.2 -m "Version 0.1.2"`. Push the tag to Github: `git push origin v0.1.2`. Create a release on Github from the tag via <https://github.com/Novartis/torchsurv/releases>.
4 changes: 1 addition & 3 deletions docs/notebooks/helpers_momentum.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import pytorch_lightning as L
import lightning as L
import torch
from torch.utils.data import DataLoader, random_split
from torchvision.datasets import MNIST
from torchvision.transforms import v2

from torchsurv.loss.cox import neg_partial_log_likelihood
from torchsurv.loss.momentum import Momentum
from torchsurv.metrics.cindex import ConcordanceIndex


Expand Down
180 changes: 106 additions & 74 deletions docs/notebooks/introduction.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit f69f163

Please sign in to comment.