|
1 | | -# Contributing to xLM |
| 1 | +# Contributing to XLM |
2 | 2 |
|
3 | | -We value and appreciate community contributions of all kinds, including: |
| 3 | +We value community contributions of all kinds, including code, documentation, bug reports, feature ideas, and helping others in [Discussions](https://github.com/dhruvdcoder/xlm-core/discussions). |
4 | 4 |
|
5 | | -* Code contributions |
6 | | -* Answering questions |
7 | | -* Helping others |
8 | | -* Improving the documentation |
9 | | -* Reporting bugs |
10 | | -* Suggesting new features |
11 | | -* Spreading the word through blogs and social media or simply by ⭐️ing the repository |
| 5 | +This guide was informed by the [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/main/CONTRIBUTING.md) and [Hugging Face Transformers](https://huggingface.co/docs/transformers/en/contributing) contributing guides. |
12 | 6 |
|
| 7 | +**Docs site (dev):** [https://dhruveshp.com/xlm-core/dev/](https://dhruveshp.com/xlm-core/dev/) |
13 | 8 |
|
14 | | -**This guide was adapted from existing open source projects:** |
15 | | -1. [scikit-learn guide to contributing](https://github.com/scikit-learn/scikit-learn/blob/main/CONTRIBUTING.md). |
16 | | -2. [Hugging Face Transformers guide to contributing](https://huggingface.co/docs/transformers/en/contributing). |
| 9 | +## Quick links |
17 | 10 |
|
| 11 | +| Topic | Where | |
| 12 | +|-------|--------| |
| 13 | +| Dependencies and requirement files | [Dependencies](https://dhruveshp.com/xlm-core/dev/developers/dependencies/) | |
| 14 | +| Running tests | [Running tests](https://dhruveshp.com/xlm-core/dev/developers/testing/running-tests/) | |
| 15 | +| Unit / integration testing | [Unit tests](https://dhruveshp.com/xlm-core/dev/developers/testing/unit-tests/), [Integration tests](https://dhruveshp.com/xlm-core/dev/developers/testing/integration-tests/) | |
| 16 | +| Model families (shared abstractions) | [Models overview](https://dhruveshp.com/xlm-core/dev/models/) | |
| 17 | +| External / fork models | [External models](https://dhruveshp.com/xlm-core/dev/guide/external-models/) | |
| 18 | +| New task or dataset | [Adding a task or dataset](https://dhruveshp.com/xlm-core/dev/guide/adding-a-task/) | |
18 | 19 |
|
19 | | -## Contributing to code or documentation |
20 | | -The best way to do that is to open a Pull Request and link it to the issue that you'd like to work on. |
| 20 | +## Contributing code or documentation |
21 | 21 |
|
22 | | -### Just want to start contributing? |
23 | | -If you don't know where to start, there is a special [Good First Issue](https://github.com/dhruvdcoder/xlm-core/issues?q=state%3Aopen%20label%3A%22good%20first%20issue%22) listing. |
| 22 | +The usual path is to **open an issue** (bug, feature, or design question) and then **open a pull request** that references it. |
24 | 23 |
|
| 24 | +### Good first issues |
25 | 25 |
|
26 | | -### Fixing outstanding issues |
| 26 | +If you want a small starter task, see [Good first issue](https://github.com/dhruvdcoder/xlm-core/issues?q=state%3Aopen+label%3A%22good+first+issue%22). |
27 | 27 |
|
28 | | -If you notice an issue with the existing code and have a fix in mind, feel free to create a new issue, [start a PR referencing the issue](#create-a-pull-request). |
| 28 | +### Reporting bugs |
29 | 29 |
|
30 | | -### Submitting an issue (bug or feature request) |
| 30 | +- Search existing [Issues](https://github.com/dhruvdcoder/xlm-core/issues) first. |
| 31 | +- If you are not sure whether something is a library bug or your setup, ask in [Q&A Discussions](https://github.com/dhruvdcoder/xlm-core/discussions/categories/q-a). |
31 | 32 |
|
32 | | -Please follow these guidelines when submitting a bug-related issue or a feature |
33 | | -request. |
34 | | -It will make it easier for us to come back to you quickly and with good |
35 | | -feedback. |
| 33 | +### Feature requests |
36 | 34 |
|
37 | | -### Reporting a bug 🐞 |
| 35 | +Open an issue and use the feature request template when available. |
38 | 36 |
|
39 | | -* Before you report an issue, we would really appreciate it if you could **make sure the bug was not already reported** (use the search bar on GitHub under Issues). |
40 | | -* Do your best to make sure your issue is related to bugs in the library itself, and not your code. If you're unsure whether the bug is in your code or the library, please ask in the [Discussions](https://github.com/dhruvdcoder/xlm-core/discussions/categories/q-a). |
| 37 | +## Environment setup |
41 | 38 |
|
| 39 | +You need **Python 3.11+** (see [`setup.py`](https://github.com/dhruvdcoder/xlm-core/blob/main/setup.py)). |
42 | 40 |
|
43 | | -### Feature request 🚀 |
| 41 | +1. **Fork** the [repository](https://github.com/dhruvdcoder/xlm-core) and **clone your fork**: |
44 | 42 |
|
45 | | -Please open an issue and follow the "Feature request" template. |
| 43 | + ```bash |
| 44 | + git clone git@github.com:<your-github-username>/xlm-core.git |
| 45 | + cd xlm-core |
| 46 | + git remote add upstream https://github.com/dhruvdcoder/xlm-core.git |
| 47 | + ``` |
46 | 48 |
|
| 49 | +2. Create a **branch** (do not commit directly on `main`): |
47 | 50 |
|
| 51 | + ```bash |
| 52 | + git checkout -b short-description-of-change |
| 53 | + ``` |
48 | 54 |
|
49 | | -## Contributing a new model |
| 55 | +3. Create a virtual environment and install **xlm-core** in editable mode, plus dev / test / docs / lint stacks: |
50 | 56 |
|
51 | | -We maintain a small library of models in a separate package called `xlm-models` in the same repository. |
| 57 | + ```bash |
| 58 | + pip install -e . |
| 59 | + pip install -r requirements/dev_requirements.txt |
| 60 | + pip install -r requirements/test_requirements.txt |
| 61 | + pip install -r requirements/docs_requirements.txt |
| 62 | + pip install -r requirements/lint_requirements.txt |
| 63 | + ``` |
52 | 64 |
|
53 | | -There are two ways to contribute a new model: |
| 65 | + Optional: install the same extras as CI when you need optional task stacks: |
54 | 66 |
|
55 | | -1. **Contribute an external model**: External models live in their own repository and are not part of the `xlm-models` package. This mechanism is great for reproducing models from research papers because it allows you considerable flexibility in terms of implementation as we don't require you to follow any strict structure. Please see [External Models Guide](https://dhruveshp.com/xlm-core/latest/guide/external-models/) for the detailed instructions. |
| 67 | + ```bash |
| 68 | + pip install -e ".[all]" |
| 69 | + ``` |
56 | 70 |
|
57 | | -2. **Contribute a model to the `xlm-models` package**: TODO: Add guide for this. |
| 71 | +4. If you change **model code** under `xlm-models/`, install that package in editable mode as well (it is a separate setuptools package in the same repo): |
58 | 72 |
|
| 73 | + ```bash |
| 74 | + pip install -e ./xlm-models |
| 75 | + ``` |
59 | 76 |
|
| 77 | + `pip install -e .` alone does not install `xlm-models` unless you already installed it from PyPI. |
60 | 78 |
|
61 | | -# Create a Pull Request |
| 79 | +## Running tests |
62 | 80 |
|
63 | | -You will need basic `git` proficiency to contribute. |
| 81 | +Details: [Running tests](https://dhruveshp.com/xlm-core/dev/developers/testing/running-tests/). |
64 | 82 |
|
65 | | -You'll need Python 3.11 or above to contribute to xLM. Follow the steps below to start contributing: |
| 83 | +**Fast loop (recommended while developing):** |
66 | 84 |
|
67 | | -1. Fork the [repository](https://github.com/dhruvdcoder/xlm-core) by |
68 | | - clicking on the **[Fork](https://github.com/dhruvdcoder/xlm-core/fork)** button on the repository's page. This creates a copy of the code |
69 | | - under your GitHub user account. |
| 85 | +```bash |
| 86 | +pytest -m "not slow and not cli" |
| 87 | +``` |
70 | 88 |
|
71 | | -2. Clone your fork to your local disk, and add the base repository as a remote: |
| 89 | +**Full suite** (includes slow and CLI subprocess tests; some tests skip if resources are missing): |
72 | 90 |
|
73 | | - ```bash |
74 | | - git clone git@github.com:dhruvdcoder/xlm-core.git |
75 | | - cd xlm-core |
76 | | - git remote add upstream https://github.com/dhruvdcoder/xlm-core.git |
77 | | - ``` |
| 91 | +```bash |
| 92 | +pytest |
| 93 | +``` |
78 | 94 |
|
79 | | -3. Create a new branch to hold your development changes: |
| 95 | +**Focused runs:** |
80 | 96 |
|
81 | | - ```bash |
82 | | - git checkout -b a-descriptive-name-for-my-changes |
83 | | - ``` |
| 97 | +```bash |
| 98 | +pytest tests/core/ |
| 99 | +pytest tests/models/mlm/ |
| 100 | +pytest tests/cli/test_smoke.py -m "cli and slow" -v |
| 101 | +``` |
84 | 102 |
|
85 | | - 🚨 **Do not** work on the `main` branch! |
| 103 | +**Coverage** (configuration in `pyproject.toml`): |
86 | 104 |
|
87 | | -4. Set up a development environment by running the following command in a virtual environment: |
| 105 | +```bash |
| 106 | +coverage run -m pytest -m "not slow and not cli" |
| 107 | +coverage report |
| 108 | +``` |
88 | 109 |
|
89 | | - ```bash |
90 | | - pip install -e . |
91 | | - pip install -r requirements/dev_requirements.txt |
92 | | - pip install -r requirements/test_requirements.txt |
93 | | - pip install -r requirements/docs_requirements.txt |
94 | | - pip install -r requirements/lint_requirements.txt |
95 | | - |
| 110 | +## Style and static checks |
| 111 | + |
| 112 | +There is no repo-wide Makefile; run tools from the activated environment. |
| 113 | + |
| 114 | +- **Format:** `black` is configured in `pyproject.toml` (line length 79). Example: |
| 115 | + |
| 116 | + ```bash |
| 117 | + black src xlm-models tests |
| 118 | + ``` |
| 119 | + |
| 120 | +- **Lint / types:** the lint requirements bundle includes `flake8`, `mypy`, and related plugins. Run them the same way you would in other Python projects (e.g. `flake8 src xlm-models tests`, `mypy` with your usual targets). Align with what CI enforces for the paths you touch. |
| 121 | + |
| 122 | +Fix new warnings in code you change; avoid drive-by mass reformatting of unrelated files. |
| 123 | + |
| 124 | +## Documentation |
| 125 | + |
| 126 | +- Sources live under [`docs/`](https://github.com/dhruvdcoder/xlm-core/tree/main/docs). The published site is built with MkDocs (see [`mkdocs.yml`](https://github.com/dhruvdcoder/xlm-core/blob/main/mkdocs.yml)). |
| 127 | +- **Local build:** |
| 128 | + |
| 129 | + ```bash |
| 130 | + mkdocs build |
| 131 | + ``` |
| 132 | + |
| 133 | +- Add new pages to the `nav:` in `mkdocs.yml` when they should appear in the sidebar. |
| 134 | + |
| 135 | +## Contributing a new model |
| 136 | + |
| 137 | +We ship reference implementations in the **`xlm-models`** package in this repository (sibling of `src/xlm/`). |
| 138 | + |
| 139 | +### External model (separate repo) |
| 140 | + |
| 141 | +For maximum flexibility (e.g. reproducing a paper with its own layout), use the **external models** mechanism. See the [External models guide](https://dhruveshp.com/xlm-core/dev/guide/external-models/). |
| 142 | + |
| 143 | +### Model inside `xlm-models` |
| 144 | + |
| 145 | +To add a **first-party** family under `xlm-models/<name>/`, follow the same component pattern as existing families: |
| 146 | + |
| 147 | +| Component | Role | |
| 148 | +|-----------|------| |
| 149 | +| **Model** | Architecture and forward pass | |
| 150 | +| **Loss** | Training objective | |
| 151 | +| **Predictor** | Inference / generation | |
| 152 | +| **Collator** | Batching | |
96 | 153 |
|
| 154 | +Conceptual comparison and batch contracts: [Models overview](https://dhruveshp.com/xlm-core/dev/models/). Per-family pages (ARLM, ILM, MDLM, MLM) show the expected module layout. |
97 | 155 |
|
98 | | -5. Develop the features in your branch. |
| 156 | +**Checklist:** |
99 | 157 |
|
100 | | - As you work on your code, you should make sure the test suite |
101 | | - passes. Run the tests impacted by your changes like this: |
102 | | - TODO: Add the commands to run the tests. |
| 158 | +1. Implement the family under `xlm-models/<family>/` (mirror `model_*`, `loss_*`, `predictor_*`, `datamodule_*`, `types_*`, `metrics_*`, etc., as appropriate). |
| 159 | +2. Add Hydra configs under `xlm-models/<family>/configs/` (datamodule, collator, experiment, …). |
| 160 | +3. Register the family in [`xlm-models/xlm_models.json`](https://github.com/dhruvdcoder/xlm-core/blob/main/xlm-models/xlm_models.json) if it should be discovered like existing tags. |
| 161 | +4. Add tests under `tests/models/<family>/` using the shared mixins in [`tests/models/_base.py`](https://github.com/dhruvdcoder/xlm-core/blob/main/tests/models/_base.py). See [Unit tests](https://dhruveshp.com/xlm-core/dev/developers/testing/unit-tests/). |
| 162 | +5. Extend **MkDocs** if you want a narrative family page: add `docs/models/<family>.md` and a nav entry in `mkdocs.yml`, and add the module path to `api-autonav` in `mkdocs.yml` if you want it in the API Reference section. |
| 163 | +6. Consider a CLI smoke entry in `tests/cli/test_smoke.py` once a minimal experiment config exists. |
103 | 164 |
|
| 165 | +## Contributing a new task or dataset |
104 | 166 |
|
105 | | - TODO: Create a single makefile for formatting and style checks. |
| 167 | +Wire preprocessing in `src/xlm/tasks/<your_task>/`, add dataset YAMLs under `src/xlm/configs/lightning_train/datasets/`, and align dataloader names with metrics and evaluators. Step-by-step: [Adding a task or dataset](https://dhruveshp.com/xlm-core/dev/guide/adding-a-task/), with background in the [Data pipeline](https://dhruveshp.com/xlm-core/dev/guide/data-pipeline/) and [Metrics](https://dhruveshp.com/xlm-core/dev/guide/metrics/) guides. |
106 | 168 |
|
107 | | - |
| 169 | +## Opening a pull request |
108 | 170 |
|
109 | | -6. When ready create a PR on for the main branch and add `dhruvdcoder, brozonoyer, sensai99, Durga-Prasad1` as a reviewers. |
| 171 | +1. Push your branch to **your fork** and open a PR against **`main`** on [dhruvdcoder/xlm-core](https://github.com/dhruvdcoder/xlm-core). |
| 172 | +2. Describe the change, link related issues, and note any new dependencies or optional extras. |
| 173 | +3. Ensure **tests** and **docs** you touched still build. |
| 174 | +4. Request review from maintainers (e.g. `dhruvdcoder`, `brozonoyer`, `sensai99`, `Durga-Prasad1`) when ready. |
110 | 175 |
|
| 176 | +## License |
111 | 177 |
|
| 178 | +By contributing, you agree that your contributions will be licensed under the same terms as the project ([MIT](https://github.com/dhruvdcoder/xlm-core/blob/main/LICENSE)). |
0 commit comments