|
| 1 | +## Contributing |
| 2 | + |
| 3 | +Contributions to 123D are highly encouraged! This guide will help you get started with the development process. |
| 4 | + |
| 5 | +### Getting Started |
| 6 | + |
| 7 | +#### 1. Clone the Repository |
| 8 | + |
| 9 | +```sh |
| 10 | +git clone [email protected]:autonomousvision/py123d.git |
| 11 | +cd py123d |
| 12 | +``` |
| 13 | + |
| 14 | +#### 2. Installation |
| 15 | + |
| 16 | +```sh |
| 17 | +conda create -n py123d_dev python=3.12 # Optional |
| 18 | +conda activate py123d_dev |
| 19 | +pip install -e .[dev] |
| 20 | +pre-commit install |
| 21 | +``` |
| 22 | + |
| 23 | +The above installation should also include linting, formatting, type-checking in the pre-commit. |
| 24 | +We use [`ruff`](https://docs.astral.sh/ruff/) as linter/formatter, for which you can run: |
| 25 | +```sh |
| 26 | +ruff check --fix . |
| 27 | +ruff format . |
| 28 | +``` |
| 29 | +Type checking is not strictly enforced, but ideally added with [`pyright`](https://github.com/microsoft/pyright). |
| 30 | + |
| 31 | + |
| 32 | +#### 3. Managing dependencies |
| 33 | + |
| 34 | +We try to keep dependencies minimal to ensure quick and easy installations. |
| 35 | +However, various datasets require dependencies in order to load or preprocess the dataset. |
| 36 | +In this case, you can add optional dependencies to the `pyproject.toml` install file. |
| 37 | +You can follow examples of nuPlan or nuScenes. These optional dependencies can be install with |
| 38 | + |
| 39 | +```sh |
| 40 | +pip install -e .[dev,nuplan,nuscenes] |
| 41 | +``` |
| 42 | +where you can combined the different optional dependencies. |
| 43 | + |
| 44 | +The optional dependencies should only be required for data pre-processing. |
| 45 | +When writing a dataset conversion method, you can check if the necessary dependencies are installed by calling with the `check_dependencies` function. |
| 46 | + |
| 47 | +```python |
| 48 | +from py123d.common.utils.dependencies import check_dependencies |
| 49 | + |
| 50 | +check_dependencies(["optional_package_a", "optional_package_b"], "optional_dataset") |
| 51 | +import optional_package_a |
| 52 | +import optional_package_b |
| 53 | + |
| 54 | +def load_camera_from_outdated_dataset(...) -> ...: |
| 55 | + optional_package_a.module(...) |
| 56 | + optional_package_b.module(...) |
| 57 | + pass |
| 58 | +``` |
| 59 | +This will notify the user if `optional_dataset` is not included in the 123D install. |
| 60 | + |
| 61 | +Also ensure that functions/modules that require optional installs are only imported when necessary, e.g: |
| 62 | + |
| 63 | +```python |
| 64 | +def load_camera_from_file(file_path: str, dataset: str) -> ...: |
| 65 | + ... |
| 66 | + if dataset == "optional_dataset": |
| 67 | + from py123d.some_module import load_camera_from_outdated_dataset |
| 68 | + |
| 69 | + return load_camera_from_outdated_dataset(...) |
| 70 | + ... |
| 71 | +``` |
| 72 | + |
| 73 | +#### 4. Other useful tools |
| 74 | + |
| 75 | +If you are using VSCode, it is recommended to install: |
| 76 | +- [autodocstring](https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring) - Creating docstrings (please set `"autoDocstring.docstringFormat": "sphinx-notypes"`). |
| 77 | +- [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - A basic spell checker. |
| 78 | + |
| 79 | +Or other similar plugins depending on your preference/editor. |
| 80 | + |
| 81 | +### Documentation Requirements |
| 82 | + |
| 83 | +#### Docstrings |
| 84 | +- **Development:** Docstrings are encouraged but not strictly required during active development |
| 85 | +- **Format:** Use [Sphinx-style docstrings](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html) |
| 86 | + |
| 87 | + |
| 88 | +#### Sphinx documentation |
| 89 | + |
| 90 | +All datasets should be included in the `/docs/datasets/` documentation. Please follow the documentation format of other datasets. |
| 91 | + |
| 92 | +You can install relevant dependencies for editing the public documentation via: |
| 93 | +```sh |
| 94 | +pip install -e .[docs] |
| 95 | +``` |
| 96 | + |
| 97 | +It is recommended to uses [sphinx-autobuild](https://github.com/sphinx-doc/sphinx-autobuild) (installed above) to edit and view the documentation. You can run: |
| 98 | +```sh |
| 99 | +sphinx-autobuild docs docs/_build/html |
| 100 | +``` |
| 101 | + |
| 102 | +### Adding new datasets |
| 103 | +TODO |
| 104 | + |
| 105 | + |
| 106 | +### Questions? |
| 107 | + |
| 108 | +If you have any questions about contributing, please open an issue or reach out to the maintainers. |
0 commit comments