- Install
poetry
[https://python-poetry.org/docs/]. It is recommended you use python virtual environment such asvenv
. - Clone this repo and perform
poetry install
from the root of the project i.e. where thepyproject.toml
file resides. This will install all the dependencies including Rhubarb. - Install
pre-commit
hooks usingpre-commit install
. This will setupruff
linter and formater checks before your changes are committed to the repo. (See below in case you see "Cowardly refusing to install" error) - Make changes to the core Rhubarb code, in case you are adding features, fixing bugs etc.
- Once you make changes perfrom
poetry build
and subsequentlypoetry install
. Or run the build script./build_install.sh
.
You may encounter Cowardly refusing to install
error with pre-commit
if you have git defender
installed. In that case run the following commands
git config --system --unset-all core.hookspath # if this shows permission denied, use sudo
pre-commit install
git defender --install
⚠️ You DO NOT have to perform this manually since thepre-commit
hook is set to run this prior to comitting into the repo. However, if you would like to run the linter and formatter before you get to the stage of committing your changes, then you can run the commands mentioned below manually.
We are striving to follow best practices with our codebase, as such this project uses ruff
for linter and re-formatter. ruff
can scan your code and find issues that you can easily address, and can help fix most of the common issues with code.
- Run
poetry run ruff check
to ensure best practices. If everything is good you should seeAll checks passed!
, else go to next step. - You can run
poetry run ruff check --fix
which will perform some of the code formatting issues found. It's not perfect but it will get you there almost to a very good code rating. Some of the common things it does- Checks and fixes long lines of code
- Checks and fixes unused variables
- Checks and flags unused imports
- Sorts and groups imports etc.
You may receive error when comitting your changes.
ruff.....................................................................Passed
ruff-format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook
X files reformatted
command error
This simply means that the pre-commit hook with ruff
did it's job and re-formatted some of the new files/lines of code you added. If this happens, simply perform git add
and git commit
again the commit the changes.
You can test your changes using the Python notebooks found in cookbooks directory. To efficiently do that, we recommend using Python virtual environment such as venv
. If you're using venv
here are are the general steps.
python -m venv rhubarb # rhubarb is the name of your venv
source rhubarb/bin/activate # activate the venv
./build_install # Build the project and install the library in your venv
If you wish to use the cookbok Python notebooks then install jupyter
and ipykernel
in the virtual environment as well.
pip install ipykernel jupyter
Once you follow the above steps, you should be able to select rhubarb
virtual environment as the Kernel for your notebook. You will also need to have AWS credentials setup with aws configure
in your dev environment for the notebooks to work. See this documentation for setting up AWS CLI. Ideally, you should have a named profile setup with AWS configure, for your AWS credentials. If you have all of it setup correctly then in the notebook you can pass profile_name=<your-profile-name>
everywhere boto3.Session
is used, for example-
import boto3
session = boto3.Session(profile_name="<your-profile-name>")
If you add new project dependencies you might want to scan the dependencies for vulnerabilities. Install pip-audit
in the python venv
.
pip install pip-audit
Once done, run the following command to generate requirements.txt
. Since the project uses Poetry, you will need to instead generate requirements.txt
and scan that with pip-audit
.
poetry export -f requirements.txt --output requirements.txt --without-hashes
Once the requirements.txt
is generated (or updated), run the pip-audit
command below-
pip-audit -r requirements.txt
To bump up the Library version.
poetry version 0.X.X
Then add the changes to repo, create a tag and push to Github. Make sure that version 0.X.X
is consistent across the new Poetry version created above and the for Github Tag.
git add -A
git commit -m "Release v0.X.X"
git tag -a v0.X.X -m "Release 0.X.X"
git push --tags
git push origin main