diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 0000000..1510730 --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,18 @@ +name: Check Version Consistency + +on: + pull_request: + branches: [main] + +jobs: + version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Verify version matches tag + run: python scripts/check_version_match.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 4653cd4..500ee3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # CHANGELOG +## v1.0.0 (2025-06-06) + +### Misc + +- Align pyproject version with GitHub tag +- Add project Code of Conduct + ## v0.7.1 (2025-04-13) ### Bug Fixes diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f81908c --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,126 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and +expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances + of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail +address, posting via an official social media account, or acting as an +appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[diogo.debastos.ribeiro@gmail.com](mailto:diogo.debastos.ribeiro@gmail.com). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of +Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +their audience, for a specified period of time. This includes avoiding +interactions in community spaces as well as external channels like social +media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with their audience, is allowed during this period. Violating these terms may +lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..07dc4b6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing to gen_surv + +Thank you for taking the time to contribute to **gen_surv**! This document provides a brief overview of the recommended workflow for feature requests and pull requests. + +## Getting Started + +1. Fork the repository and create your feature branch from `main`. +2. Install dependencies with `poetry install`. +3. Ensure the test suite passes with `poetry run pytest`. +4. If you add a feature or fix a bug, update `CHANGELOG.md` accordingly. + +## Version Consistency + +Releases are tagged in Git. Before creating a release, verify that the version declared in `pyproject.toml` matches the latest Git tag: + +```bash +python scripts/check_version_match.py +``` + +The CI workflow `version-check.yml` runs this same script on pull requests to `main`. + +## Submitting Changes + +1. Commit your changes with clear messages. +2. Push to your branch and open a pull request. +3. Ensure your PR description explains the motivation and summarizes your changes. + +We appreciate your contributions and feedback! diff --git a/README.md b/README.md index f25fb81..2fc5bef 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,11 @@ poetry install ``` ## โœจ Features -- Consistent interface across models -- Censoring support (`uniform` or `exponential`) -- Easy integration with `pandas` and `NumPy` -- Suitable for benchmarking survival algorithms and teaching +- Consistent interface across models +- Censoring support (`uniform` or `exponential`) +- Easy integration with `pandas` and `NumPy` +- Suitable for benchmarking survival algorithms and teaching +- Accelerated Failure Time (Log-Normal) model generator ## ๐Ÿงช Example @@ -62,6 +63,7 @@ generate(model="thmm", n=100, qmat=[[0, 0.2, 0], [0.1, 0, 0.1], [0, 0.3, 0]], | `gen_cmm()` | Continuous-Time Multi-State Markov Model | | `gen_tdcm()` | Time-Dependent Covariate Model | | `gen_thmm()` | Time-Homogeneous Markov Model | +| `gen_aft_log_normal()` | Accelerated Failure Time Log-Normal | ```text @@ -95,3 +97,21 @@ genSurvPy/ ## ๐Ÿง  License MIT License. See [LICENSE](LICENSE) for details. + + +## ๐Ÿ”– Release Process + +This project uses Git tags to manage releases. A GitHub Actions workflow +(`version-check.yml`) verifies that the version declared in `pyproject.toml` +matches the latest Git tag. If they diverge, the workflow fails and prompts a +correction before merging. Run `python scripts/check_version_match.py` locally +before creating a tag to catch issues early. + +## ๐ŸŒŸ Code of Conduct + +Please read our [Code of Conduct](CODE_OF_CONDUCT.md) to learn about the +expectations for participants in this project. + +## ๐Ÿค Contributing + +Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on setting up your environment, running tests, and submitting pull requests. diff --git a/docs/source/index.md b/docs/source/index.md index bba60fd..69011e3 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -53,3 +53,4 @@ generate(model="thmm", n=100, qmat=[[0, 0.2, 0], [0.1, 0, 0.1], [0, 0.3, 0]], - [Source Code](https://github.com/DiogoRibeiro7/genSurvPy) - [License](https://github.com/DiogoRibeiro7/genSurvPy/blob/main/LICENSE) +- [Code of Conduct](https://github.com/DiogoRibeiro7/genSurvPy/blob/main/CODE_OF_CONDUCT.md) diff --git a/pyproject.toml b/pyproject.toml index 7130878..2b69108 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gen_surv" -version = "0.7.4" +version = "1.0.0" description = "A Python package for simulating survival data, inspired by the R package genSurv" authors = ["Diogo Ribeiro "] license = "MIT" diff --git a/scripts/check_version_match.py b/scripts/check_version_match.py new file mode 100755 index 0000000..6f5eacc --- /dev/null +++ b/scripts/check_version_match.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""Check that pyproject version matches the latest git tag.""" +from pathlib import Path +import subprocess +import sys +import tomllib + +ROOT = Path(__file__).resolve().parents[1] + + +def pyproject_version() -> str: + pyproject_path = ROOT / "pyproject.toml" + with pyproject_path.open("rb") as f: + data = tomllib.load(f) + return data["tool"]["poetry"]["version"] + + +def latest_tag() -> str | None: + try: + tag = subprocess.check_output( + ["git", "describe", "--tags", "--abbrev=0"], cwd=ROOT, text=True + ).strip() + return tag.lstrip("v") + except subprocess.CalledProcessError: + return None + + +def main() -> int: + tag = latest_tag() + version = pyproject_version() + + if not tag: + print("No git tag found", file=sys.stderr) + return 1 + + if version != tag: + print( + f"Version mismatch: pyproject.toml has {version} but latest tag is {tag}", + file=sys.stderr, + ) + return 1 + + print(f"Version matches latest tag: {version}") + return 0 + + +if __name__ == "__main__": + sys.exit(main())