Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
18 changes: 8 additions & 10 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.10"
enable-cache: true

- name: Install dependencies
run: |
pip install --upgrade pip
pip install build==0.7.0 pep517 setuptools wheel twine
- name: Set up Python
run: uv python install 3.10

- name: Build PyPI release
run: python -m build
run: uv build

- name: Check PyPI release
run: python -m twine check dist/*
run: uvx twine check dist/*

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
50 changes: 14 additions & 36 deletions .github/workflows/codeqc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,36 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
activate-environment: torchsurv
enable-cache: true

- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('dev/environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 1
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y pandoc

- name: Update conda environment
run:
conda env update -n torchsurv -f dev/environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Install dependencies
run: uv sync --group dev --extra docs

- name: Code QC
shell: bash -l {0}
run: |
conda activate torchsurv
./dev/codeqc.sh check
run: uv run ./dev/codeqc.sh check

- name: Tests
shell: bash -l {0}
run: |
conda activate torchsurv
./dev/run-doctests.sh
./dev/run-unittests.sh
uv run ./dev/run-doctests.sh
uv run pytest

- name: Test-build docs
shell: bash -l {0}
run: |
conda activate torchsurv
./dev/build-docs.sh
uv run ./dev/build-docs.sh
tar czvf docs.tar.gz -C docs/_build/html .

- name: 'Upload Docs Tarball'
Expand Down
45 changes: 14 additions & 31 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,24 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
auto-update-conda: true
miniconda-version: "latest"
python-version: 3.11
activate-environment: torchsurv

- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('dev/environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0

- name: Update conda environment
run:
conda env update -n torchsurv -f dev/environment.yml
if: steps.cache.outputs.cache-hit != 'true'
enable-cache: true

- name: Set up Python
run: uv python install 3.11

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y pandoc

- name: Install dependencies
run: uv sync --group dev --extra docs

- name: Build docs
shell: bash -l {0}
run: |
conda activate torchsurv
./dev/build-docs.sh
run: uv run ./dev/build-docs.sh

- name: Deploy to GitHub Pages
run: |
Expand Down
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ melodie/
# anything with -copy
*-copy.*

# LLMs
.claude/
.github/
.hypothesis/
# copilot
.github/**
.specify/**
.claude/**
specs/**
CLAUDE.md
specs/
.specify/

# hypothesis generated test artifacts
.hypothesis/
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
- id: ruff-format

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3.9009
rev: v0.4.3 # NOTE: was pinned to dev version v0.4.3.9009; update if a newer stable tag exists
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand All @@ -48,7 +48,16 @@ repos:
hooks:
- id: sphinx-lint


- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run --no-sync mypy
language: system
types: [python]
args: ["--config-file", "pyproject.toml", "src/"]
files: ^src/torchsurv/
pass_filenames: false

ci:
autofix_prs: true
Expand Down
5 changes: 5 additions & 0 deletions CODEOWNERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
* David Ohlssen (**Novartis**)
* Berkman Sahiner (**FDA**)
* Nicholas Petrick (**FDA**)


### Contributors

* Yao Chen (**Novartis**)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make the changes with the acknowledgments as we discussed?

12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ We welcome contributions from the community! Whether you're fixing bugs, adding

Before contributing, please ensure you can set up the development environment by following the instructions in our [developer notes](/docs/devnotes.md).

The quickest way to get started is with [uv](https://docs.astral.sh/uv/):

```bash
git clone https://github.com/Novartis/torchsurv.git
cd torchsurv
uv sync --group dev # creates .venv and installs everything
uv run pre-commit install # set up pre-commit hooks
uv run pytest # run the test suite
```

See the [developer notes](/docs/devnotes.md) for more details.

## How to Contribute

### Reporting Issues
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@ Deep survival analysis made easy
</h1>

[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Python](https://img.shields.io/pypi/pyversions/torchsurv?label=Python)](https://pypi.org/project/torchsurv/)
[![PyPI - Version](https://img.shields.io/pypi/v/torchsurv?color=green&label=PyPI)](https://pypi.org/project/torchsurv/)
[![Conda](https://img.shields.io/conda/v/conda-forge/torchsurv?label=Conda&color=green)](https://anaconda.org/conda-forge/torchsurv)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/torchsurv?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=brightgreen&left_text=PyPI%20downloads)](https://pepy.tech/projects/torchsurv)
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/torchsurv.svg?label=Conda%20downloads)](
https://anaconda.org/conda-forge/torchsurv)


![CodeQC](https://github.com/Novartis/torchsurv/actions/workflows/codeqc.yml/badge.svg?branch=main)
![Docs](https://github.com/Novartis/torchsurv/actions/workflows/docs.yml/badge.svg?branch=main)
[![CodeFactor](https://www.codefactor.io/repository/github/novartis/torchsurv/badge/main)](https://www.codefactor.io/repository/github/novartis/torchsurv/overview/main)
[![JOSS](https://joss.theoj.org/papers/02d7496da2b9cc34f9a6e04cabf2298d/status.svg)](https://joss.theoj.org/papers/02d7496da2b9cc34f9a6e04cabf2298d)
[![License](https://img.shields.io/badge/License-MIT-black)](https://opensource.org/licenses/MIT)
[![Documentation](https://img.shields.io/badge/GithubPage-Sphinx-blue)](https://opensource.nibr.com/torchsurv/)


`TorchSurv` is a Python package that serves as a companion tool to perform deep survival modeling within the `PyTorch` environment. Unlike existing libraries that impose specific parametric forms on users, `TorchSurv` enables the use of custom `PyTorch`-based deep survival models. With its lightweight design, minimal input requirements, full `PyTorch` backend, and freedom from restrictive survival model parameterizations, `TorchSurv` facilitates efficient survival model implementation, particularly beneficial for high-dimensional input data scenarios.

If you find this repository useful, please give us a star! 🌟 ⭐ 🌟

[![GitHub Stars](https://img.shields.io/github/stars/Novartis/torchsurv?label=GitHub%20stars&color=yellow)](https://github.com/Novartis/torchsurv/stargazers)

---

## TL;DR
Expand Down Expand Up @@ -99,17 +104,17 @@ pip install torchsurv
<details>
<summary><em>Other installation details </em></summary>
<br>
- Using for local installation (latest version for example)
- Using for local development (latest version)

```bash
git clone <repo>
cd <repo>
pip install -e .
git clone https://github.com/Novartis/torchsurv.git
cd torchsurv
uv sync --group dev # creates .venv with all dependencies
uv run pytest # run the test suite
```


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.
> [uv](https://docs.astral.sh/uv/) is the recommended tool for development.
> See the [development notes](https://opensource.nibr.com/torchsurv/devnotes.html) for full setup instructions.

</details>

Expand Down
Loading
Loading