Skip to content

Commit e091dbf

Browse files
authored
Merge pull request #41 from dhruvdcoder/docs-for-creating-new-task
Use folder for each task
2 parents 94fb33c + cd3760d commit e091dbf

26 files changed

Lines changed: 549 additions & 173 deletions

File tree

CONTRIBUTING.md

Lines changed: 132 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,178 @@
1-
# Contributing to xLM
1+
# Contributing to XLM
22

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).
44

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.
126

7+
**Docs site (dev):** [https://dhruveshp.com/xlm-core/dev/](https://dhruveshp.com/xlm-core/dev/)
138

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
1710

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/) |
1819

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
2121

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.
2423

24+
### Good first issues
2525

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).
2727

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
2929

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).
3132

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
3634

37-
### Reporting a bug 🐞
35+
Open an issue and use the feature request template when available.
3836

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
4138

39+
You need **Python 3.11+** (see [`setup.py`](https://github.com/dhruvdcoder/xlm-core/blob/main/setup.py)).
4240

43-
### Feature request 🚀
41+
1. **Fork** the [repository](https://github.com/dhruvdcoder/xlm-core) and **clone your fork**:
4442

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+
```
4648

49+
2. Create a **branch** (do not commit directly on `main`):
4750

51+
```bash
52+
git checkout -b short-description-of-change
53+
```
4854

49-
## Contributing a new model
55+
3. Create a virtual environment and install **xlm-core** in editable mode, plus dev / test / docs / lint stacks:
5056

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+
```
5264

53-
There are two ways to contribute a new model:
65+
Optional: install the same extras as CI when you need optional task stacks:
5466

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+
```
5670

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):
5872

73+
```bash
74+
pip install -e ./xlm-models
75+
```
5976

77+
`pip install -e .` alone does not install `xlm-models` unless you already installed it from PyPI.
6078

61-
# Create a Pull Request
79+
## Running tests
6280

63-
You will need basic `git` proficiency to contribute.
81+
Details: [Running tests](https://dhruveshp.com/xlm-core/dev/developers/testing/running-tests/).
6482

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):**
6684

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+
```
7088

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):
7290

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+
```
7894

79-
3. Create a new branch to hold your development changes:
95+
**Focused runs:**
8096

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+
```
84102

85-
🚨 **Do not** work on the `main` branch!
103+
**Coverage** (configuration in `pyproject.toml`):
86104

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+
```
88109

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 |
96153

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.
97155

98-
5. Develop the features in your branch.
156+
**Checklist:**
99157

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.
103164

165+
## Contributing a new task or dataset
104166

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.
106168

107-
169+
## Opening a pull request
108170

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.
110175

176+
## License
111177

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

Comments
 (0)