Thank you for your interest in contributing to the Instill AI Cookbook! This guide will help you get started with contributing to the project by explaining the process for submitting your code, guidelines for code quality, and best practices for writing Jupyter notebooks.
- How to Contribute
- Code Quality Standards
- Best Practices for Jupyter Notebooks
- Updating the Repository README
If you encounter a bug, have a suggestion, or want to request a new notebook, please open an issue in the instill-core repository. When submitting an issue:
- Select an appropriate template.
- Provide a clear, descriptive title.
- Include as much detail as possible (steps to reproduce, screenshots, etc.).
- Suggest possible solutions if applicable.
To contribute code to the Instill AI Cookbook, follow these steps:
-
Fork the Repository:
- Navigate to the Instill AI Cookbook GitHub repository.
- Click the "Fork" button to create your own copy of the repository.
-
Clone the Fork:
- Open your terminal and run:
git clone https://github.com/YOUR-USERNAME/cookbook.git cd cookbook
- Open your terminal and run:
-
Create a New Branch:
- Create a new branch with a descriptive name:
git checkout -b <your-github-username>/<what-your-pr-about>
- Create a new branch with a descriptive name:
-
Make and Commit Changes:
- Implement your changes and commit them following these best practices:
- Adhere to the conventional commits guidelines for meaningful commit messages.
- Follow the 7 rules of commit messages for well-structured and informative commits.
- Rearrange commits to squash trivial changes together using git rebase.
- Implement your changes and commit them following these best practices:
-
Push to Your Branch:
- Push your branch to your GitHub repository:
git push origin <your-branch-name>
- Push your branch to your GitHub repository:
-
Open a Pull Request:
- Initiate a pull request to our repository. Our team will review your changes and collaborate with you on any necessary refinements.
A repository maintainer will review your pull request. Please be patient, as they may request changes or clarifications. Once your pull request is approved, it will be merged into the main branch.
We expect contributions to follow these guidelines:
-
Ensure your code is clean, and well formatted:
- Whilst we do not enforce the use of PEP 8 (Python Style Guide), we do encourage the code to be clear, concise and well-formatted. See the current notebooks for examples.
-
Ensure Notebooks Run from Start to Finish:
- Each notebook should run from the first to the last cell without errors, both locally and in Google Colab.
- Use
tqdm
or other progress indicators for long-running cells, if necessary.
-
Write Descriptive Comments:
- Explain complex sections of your code.
- Use Markdown cells in notebooks to describe each step clearly.
- Interweave markdown cells with code blocks to tell a clear, coherent story, providing explanations and links to external references where necessary.
-
Include Installation Commands:
- At the top of the notebook, include commands to install any required non-default Python packages, specifying the exact versions. For example:
!pip install pandas==1.3.0 numpy==1.21.0
- At the top of the notebook, include commands to install any required non-default Python packages, specifying the exact versions. For example:
-
Keep Data Files Lightweight:
- Where possible, keep necessary data files small, and add them to the
cookbook/data/
folder to avoid unnecessarily large files in the repository.
- Where possible, keep necessary data files small, and add them to the
-
Protect API Tokens:
- Ensure that your API tokens are not exposed in your notebooks or commits. Use environment variables or
.env
files to manage sensitive information securely.
- Ensure that your API tokens are not exposed in your notebooks or commits. Use environment variables or
-
Keep Notebooks Modular:
- Each notebook should demonstrate a specific use case or feature of the Instill AI product stack.
- Avoid overly complex notebooks that cover too many topics at once.
-
Use Markdown for Documentation:
- Explain the purpose of the notebook, assumptions, and any external links to documentation.
- Break down code blocks with clear explanations in Markdown cells.
-
Keep Outputs Clean:
- Avoid saving large outputs or unnecessary debug prints in the notebook.
-
Embedding Pipelines for Observability:
- Whenever pipelines on Instill Cloud are called, consider embedding the preview page as an IFrame for enhanced observability and explainability, for example:
from IPython.display import IFrame IFrame('https://instill.tech/instill-ai/pipelines/structured-web-insights-from-url/preview', width=1000, height=700)
- Whenever pipelines on Instill Cloud are called, consider embedding the preview page as an IFrame for enhanced observability and explainability, for example:
-
Ensure Readability:
- Organize code into sections and use consistent naming conventions.
When contributing a new notebook, it is mandatory to update the repository's README file to reflect your addition. Here's how:
Update the Notebook Table:
- Add a new entry to the table under the
## Notebooks
section for your notebook. - Each entry must include:
- A title that links to the notebook in the
examples
folder. - A Google Colab link to launch the notebook.
- A brief description summarizing the notebook.
- A title that links to the notebook in the
Example entry:
[Your Notebook Title](https://github.com/instill-ai/cookbook/tree/main/examples/Your_Notebook.ipynb) | [![Open in Google Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/instill-ai/cookbook/blob/main/examples/Your_Notebook.ipynb) | Short description of what your notebook does.
We look forward to your contributions! If you have any questions, feel free to reach out by opening an issue or joining our community discussions on Discord. 🚀