-
Notifications
You must be signed in to change notification settings - Fork 24
Introduce Rust guide #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Introduce Rust guide #732
Conversation
TallJimbo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two big-picture comments (some echoed in various line-comments):
- I think you need to mention
rubinoxideup front concretely and organize the discussion around that; only talking about organizing code in a purely abstract sense makes the actual guidelines a lot harder to follow. - There are a lot of start-of-section sentences here that just sound like software platitudes. I understand wanting to have some sort of introductory text for each section, but I think the audience (who is likely reading it as fast as they can so they can get back to writing code) will appreciate it if you just dive right in.
4955daf to
13c40dc
Compare
13c40dc to
2037adc
Compare
nealmcb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note a few typos
| 4. Code Organization | ||
| -------------------- | ||
|
|
||
| Unlike the package-centric organization often seen in Python, packages containing rust code should me monolithic and not depend on other lsst packages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Should "be" monolithic
| The de-facto location, and reference implementation, of rust within the lsst science pipelines is in a package called ``rubinoxide``. | ||
| This does not mean developers are not allowed to use rust in another dedicated package, but unless there is a compelling reason to do so rust code should be placed in ``rubinoxide``. | ||
| This guide assumes the package layout of ``rubinoxide``. | ||
| Any other Rust based packages that are written should adhear to this as best as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adhear => adhere
|
|
||
| * Rust packages should be built using maturin, which manages the complexities of compiling and bundling cargo products. | ||
| * Cargo additionally is to be used manage dependencies and run rust level tests. | ||
| * pip is used as the mechanism to locally depoly the wheels created by maturin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depoly => deploy
taranu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guide seems written for an audience that has decided to add new rust code. It needs content for developers who barely know anything about rust and:
- want to know what functionality is available and where/how it can/should be used
- might one day have to review a ticket with (slightly) non-trivial rust changes
Some of this is covered by the Introduction, Resources and Code Organization sections, but not entirely. For example, say I need some performant vectorized code for numpy arrays. Should I look to numpy first? If scipy/astropy has what I need, should I also check rubinoxide for relevant functions first and benchmark them?
Similarly, what does leverage its memory safety features mean? Writing only code without unsafe?
| These tests should be placed in the **tests** top level directory. | ||
| * pytest: Use pytest as the python testing framework. | ||
| * For functionality that does not have a public python api, or is not well covered by a python api, or is difficult to appropriately test with a python unit test rust unit tests may be written using the standard rust unit test infrastructure. | ||
| Genreally avoid a rust until test on any code that is wrapped with pyo3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typos: Generally, unit test
|
|
||
| Consistent code style improves readability and maintainability. | ||
|
|
||
| * `rustfmt`_: Use rustfmt to automatically format your Rust code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these recommendations or requirements?
|
|
||
| * Do not use implicit multithreading in rust | ||
| * Do not introduce any cross package rust bindings that transit through python aka how we use c++ now. | ||
| * As mentioned above, do not arange module structure according to lsst packages. Write modules by related functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: arrange
| * Cargo additionally is to be used manage dependencies and run rust level tests. | ||
| * pip is used as the mechanism to locally depoly the wheels created by maturin | ||
| * pytest is used to run python level unit tests | ||
| * coordinating these scripts for the developer is a Makefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is make really the best option here?
This is a first draft of the proposed rust developer guide. All comments and improvement welcome.