| [ Web Proxy ] |
| Viewing: https://docs.docarray.org/API_reference/array/../../../data_types/../../CONTRIBUTING/ | [Back] [Original] |
Thanks for your interest in contributing to DocArray. We're grateful for your initiative!
In this guide, we're going to go through the steps for each kind of contribution, and good and bad examples of what to do. We look forward to your contributions!
We love to get issue reports. But we love it even more if they're in the right format. For any bugs you encounter, we need you to:
There are also a couple of nice to haves:
fix-docarray-typo-1.Note: If you're just fixing a typo or grammatical issue, you can go straight to a pull request.
git checkout YOUR-WORKED-BRANCH
git commit --amend --author="YOUR-GITHUB-NAME <YOUR-GITHUB-EMAIL>" --no-edit
git log # to confirm the change is effective
git push --force
We use Poetry to manage our dependencies.
To get stared with DocArray development you should do:
pip install poetry
poetry install --all-extras # this will install all of the dependency needed for development
This will automatically create a virtual environment and install all the dependency from the lockfile of Poetry.
To run your code you need to either activate the environment:
or usepoetry run:
In DocArray we use git's pre-commit hooks in order to make sure the code matches our standards of quality and documentation. It's easy to configure it:
pip install pre-commitpre-commit installNow you will be automatically reminded to add docstrings to your code. black will take care that your code will match our style. Note that black will fail your commit but reformat your code, so you just need to add the files again and commit again.
Run git config blame.ignoreRevsFile .github/.git-blame-ignore-revs
Most of our codebase is written in Python.
We comply to the official PEP: E9, F63, F7, F82 code style and required every contribution to follow it. This is enforced by using ruff in our CI and in our pre-commit hooks.
DocArray is compatible with Python 3.7 and above, therefore we can't accept contribution that used features from the newest Python versions without ensuring compatibility with python 3.7
All of our Python codebase follows formatting standard. We are following the PEP8 standard, and we require that every code contribution is formatted using black with the default configurations. If you have installed the pre-commit hooks the formatting should be automatic on every commit. Moreover, our CI will block contributions that do not respect these conventions.
Python is not a strongly typed programming language. Nevertheless, the use of type hints
contributes to a better codebase, especially when reading, reviewing and refactoring. Therefore, we require every contribution
to use type hints, unless there are strong reasons for not using them.
Further, DocArray is type checked using mypy, and all contributions will have to pass this type check.
Note: Example code in the documentation should also follow our code style conventions.
For branches, commits, and PRs we follow some basic naming conventions:
Type is an important prefix in PR, commit message. For each branch, commit, or PR, we need you to specify the type to help us keep things organized. For example,
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: build, ci, chore, docs, feat, fix, refactor, style, or test.
ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)docs: Documentation only changesfeat: A new featurefix: A bug fixperf: A code change that improves performancerefactor: A code change that neither fixes a bug nor adds a featuretest: Adding missing tests or correcting existing testschore: updating grunt tasks etc.; no production code changeA good commit message helps us track DocArray's development. A pull request with a bad commit message will be rejected automatically in the CI pipeline.
Commit messages should stick to our naming conventions outlined above, and use the format type(scope?): subject:
type is one of the types above.scope is optional, and represents the module your commit is working on.subject explains the commit, without an ending period.For example, a commit that fixes a bug in the executor module should be phrased as: fix(executor): fix the bad naming in init function
Good examples:
Bad examples:
| Commit message | Feedback |
|---|---|
doc(101): improved 101 document |
Should be docs(101) |
tests(flow): add unit test to document array |
Should be test(array) |
DOC(101): Improved 101 Documentation |
All letters should be in lowercase |
fix(pea): i fix this issue and this looks really awesome and everything should be working now |
Too long |
fix(array):fix array serialization |
Missing space after : |
hello: add hello-world |
Type hello is not allowed |
Commits need to be signed. Indeed, the DocArray repo enforces the Developer Certificate of Origin via the DCO GitHub app.
To sign your commits you need to use the -s argument when committing:
We all make mistakes. GitHub has a guide on rewriting commit messages so they can adhere to our standards.
You can also install commitlint onto your own machine and check your commit message by running:
We don't enforce naming of PRs and branches, but we recommend you follow the same style. It can simply be one of your commit messages, just copy/paste it, e.g. fix(readme): improve the readability and move sections.
To add a dependency to DocArray, edit pyproject.toml and add your dependency in the [tool.poetry.dependencies] section.
Always overwrite poetry default version number (if you used poetry add XYZ):
- Pick an appropriate version number. Don't pick the latest version, but rather the oldest that is still compatible.
- Use the >= notation instead of ~ to not lock upper limit.
If appropriate, make the dependency optional. For example if it is a new library for a new modality or new vector database.
mylib = {version = ">=X.y.z", optional = true }
You will also need to add an extra:
Note: Manual editing of pyproject.toml is equivalent to poetry add "mylib>=3.9" -E new_modalities
Locally you can run the tests via:
poetry install --all-extras
poetry run pip install protobuf==3.19.0
poetry run pip install tensorflow
poetry run pytest -v -s tests
For local development we suggest using the following command to run the tests:
This only take a couple of seconds.
Every contribution that adds or modifies the behavior of a feature must include a suite of tests that validates that the feature works as expected.
This allows:
If you need to monitor and debug your code, you can enable docarray logging:
Some changes to the code base require also changing the .proto files that describe how DocArray serializes to and from
protobuf messages.
Changes to the .proto definitions should be kept to a minimum, in order to avoid breaking changes.
If you do make modification in a .proto file, you need to recompile the protobuf definitions.
In order to maintain compatibility with most of the Python ecosystem, in DocArray we compile to two different protobuf
versions. Therefore, compilation is a two-step process:
protoc version 3.19protoc executable: chmod +x bin/protocpb2 directory. From docarray/proto/ run path/to/v-3-19/bin/protoc -I . --python_out="pb2" docarray.proto.protoc version 3.21pb directory. From docarray/proto/ run path/to/v-3-21/bin/protoc -I . --python_out="pb" docarray.proto.Good docs make developers happy, and we love happy developers! We've got a few different types of docs:
Data Types section. Make sure it fits its section.backticks for direct references to code elements.First install the documentation dependency
Note: if you need to install extra (proto, database, ...) you need to specify those as well.
Then build the documentation:
The docs website will be generated in site.
To serve it, run:
You can now see docs website on http://localhost:8000 on your browser. Note: You may have to change the port from 8000 to something else if you already have a server running on that port.
Once again, thanks so much for your interest in contributing to DocArray. We're excited to see your contributions!
| Web Proxy Viewer | New URL | Original Page |