Whether you are an experienced open source developer or a first-time contributor, we welcome your contributions to the code and the documentation. Thank you for being part of our community!
This project and everyone participating in it is governed by the Layer Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to community@layer.ai.
This section guides you through submitting a bug report for Layer. Following these guidelines helps maintainers and the community understand your report, reproduce the behavior and find related reports.
Before creating bug reports, please check this list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible. Fill out the required template, the information it asks for helps us resolve issues faster.
Note: If you find a Closed issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
- Check our discourse for a list of common questions and problems.
- Perform a cursory search to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
Bugs are tracked as GitHub issues. Create an issue on the relevant repository and fill in the template.
Explain the problem and include additional details to help maintainers reproduce the problem:
- Use a clear and descriptive title for the issue to identify the problem.
- Describe the exact steps which reproduce the problem in as many details as possible
- Provide specific examples to demonstrate the steps. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use Markdown code blocks.
- Describe the behavior you observed after following the steps and point out what exactly is the problem with that behavior.
- Explain which behavior you expected to see instead and why.
- Include screenshots and animated GIFs which show you following the described steps and clearly demonstrate the problem. You can use this tool to record GIFs on macOS and Windows, and this tool or this tool on Linux.
- If the problem wasn't triggered by a specific action, describe what you were doing before the problem happened and share more information using the guidelines below.
Provide more context by answering these questions:
- Did the problem start happening recently (e.g. after updating to a new version of Layer) or was this always a problem?
- If the problem started happening recently, can you reproduce the problem in an older version of Layer? What's the most recent version in which the problem doesn't happen? You can install older versions of Layer with
pip install layer==<version>
. - Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens.
Include details about your configuration and environment:
- Which version of Layer are you using? You can get the exact version by running
pip show layer
in your terminal. - What's the name and version of the OS you're using?
This section guides you through submitting an enhancement suggestion for Layer, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions.
Before creating enhancement suggestions, please check this list as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please include as many details as possible. Fill in the template, including the steps that you imagine you would take if the feature you're requesting existed.
- Perform a cursory search to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
Enhancement suggestions are tracked as GitHub issues. Create an issue on the relevant repository and fill in the template.
- Use a clear and descriptive title for the issue to identify the suggestion.
- Provide a step-by-step description of the suggested enhancement in as many details as possible.
- Provide specific examples to demonstrate the steps. Include copy/pasteable snippets which you use in those examples, as Markdown code blocks.
- Describe the current behavior and explain which behavior you expected to see instead and why.
- Include screenshots and animated GIFs which help you demonstrate the steps or point out the part of Layer which the suggestion is related to. You can use this tool to record GIFs on macOS and Windows, and this tool or this tool on Linux.
- Explain why this enhancement would be useful to most Layer users and isn't something that can or should be implemented separately.
- List some other tools where this enhancement exists.
- Specify which version of Layer you're using. You can get the exact version by running
pip show layer
in your terminal. - Specify the name and version of the OS you're using.
If you'd like to go beyond reporting bugs and feature requests, you can follow the steps in How do I contribute code? to set up your local development environment and open a pull request yourself. Before you start writing code, we recommend you search existing issues to see if there is someone else already working the feature you'd like to add. If not, please create an issue and mention in the comments that you're planning to open a pull request yourself.
First, install these prerequisite tools on your development environment:
Then, run pyenv install $(cat .python-version)
in the root of this repo to ensure you have the preferred Python version installed.
This repo uses make
as the build system. The following targets can be used throughout your development lifecycle:
create-environment
creates a virtual environment wherelayer
will be installed into. It will be pyenv on Linux or conda on MacOS M1install
- prepares thepoetry
virtual environment. Most of the other tasks will do that automatically for youformat
- formats the codetest
- runs unit testscolab-test
- run colab tests with layerco/colab-lite image from dockerhublint
- runs linterscheck
- runstest
andlint
check-package-loads
- check that package loads without dev dependenciespublish
- publishes the project to PyPi. This is intended to be used in CI only.jupyter
- start a jupyter notebook with editable layer packageclean
- resets development environmentdeepclean
- cleans up the virtual environmenthelp
- prints all targets
We recommend using pyenv
Please run make create-environment
to setup the recommended python version.
If you are using an Apple M1 machine, we recommend using conda
via Miniforge3. After installing conda please run
# Create and activate conda environment
make create-environment
conda activate build/sdk
After that you should be able to run the rest of the make
targets as normal
You can install layerai/sdk
from the root of this repository with:
make install
Once this step completes successfully, you will be able to run Layer locally by opening a Python prompt from the Poetry virtual environment:
poetry shell
python
And importing Layer from a Python shell within this virtual environment:
import layer
...
The poetry
documentation about dependency management is here
Every time you change dependencies, you should expect a corresponding change to poetry.lock
. If you use poetry
directly, it will be done automatically for you. If you manually edit pyproject.toml
, you need to run poetry lock --no-update
after.
Here are a few tips to use poetry:
-
How to add a new dependency
poetry add foo # or poetry add foo=="1.2.3"
-
How to add a new dev dependency
poetry add foo --dev # or poetry add foo=="1.2.3" --dev
-
How to get an environment with this package and all dependencies
poetry shell
-
How to run something inside the poetry environment
poetry run <...>
-
How to update a dependency
poetry update foo
Once you have made your changes and validated them manually, it's important to run automated checks as well. You can do so with the following command:
make check
This will lint your code and run tests defined in test/
.
If you would like run linting and testing individually, you can also run the following:
# Runs unit tests
make test
# Runs all linters
make lint
All unit tests live under test/unit
. Please add unit tests for any new code that you contribute.
All e2e tests live under test/e2e
. Running these might incur cost so use sparingly
In order to run the tests, first you need to create an api key from https://app.layer.ai
. Then run:
make e2e-test
You will be asked for your key which will be stored for subsequent runs in .test-token
.
You can find the test logs under build/e2e-home/logs
and also the standard output generated during tests under build/e2e-home/stdout-logs
.
You can pass E2E_TEST_SELECTOR
to make e2e-test
to select a subset of the tests to run. Use the standard pytest syntax to specify which tests to invoke.
make e2e-test E2E_TEST_SELECTOR=test/e2e/test_guest_user_reads.py::test_guest_user_private_model_read
By default e2e-tests
run with 16x parallelism. You can pass E2E_TEST_PARALLELISM
to make e2e-test
to reduce the parallelism. This can be useful if you are on the free Tier and have limited parallelism. In this example we run the tests sequencially.
make e2e-test E2E_TEST_PARALLELISM=1
We provide an image that includes same requirements.txt
from Google Colab, you can test integration by running the command make colab-test
.
This test uses local sdk
package and runs a notebook that will login to layer.
To run this test you will need to generate an API KEY and provide via the terminal. To generate API_KEY access https://app.layer.ai/$USERNAME/settings/developer
- Run
make jupyter
- Browser window with the local jupyter notebook will popup
- Changes done to your local
SDK
will auto reflect on that jupyter notebook environment
- Run
poetry build
- Upload
dist/layer-0.10.0b1-py3-none-any.whl
to the Colab notebook after a runtime recreation (hint: you can do byfrom google.colab import files
andfiles.upload()
inside Colab) pip install layer-0.10.0b1-py3-none-any.whl
- Run the rest of the notebook as normal
This repo uses the following linters:
Set these up with your IDE to have a smoother development experience and fewer failed checks.
The final step after developing and testing your changes locally is to submit a pull request and get your contribution merged back into layerai/sdk
. Please follow the instructions in the GitHub template when creating your PR and fix any status checks that are failing.
To help debug E2E test issues, network logs are captured, zipped and available in the Summary page of each Check GitHub Action page after the E2E tests are executed.
When the PR passes all checks, a layerai/sdk
maintainer will review your PR. The maintainer may suggest changes to improve code style or clarity, or to add missing tests. When everything is satisfied, the PR can then be merged onto the main
branch.
That's it! We are looking forward to your contributions!
Thanks for the Atom team for their fantastic open source guidelines which we've adopted in our own guidelines.