Skip to content

Commit

Permalink
Code import
Browse files Browse the repository at this point in the history
Signed-off-by: Major Hayden <[email protected]>
  • Loading branch information
major committed Nov 11, 2024
1 parent 08b5ee9 commit b2a68b6
Show file tree
Hide file tree
Showing 24 changed files with 3,708 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/actions/setup-pdm-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "setup-pdm-env"
description: "Composite action to setup the Python and PDM environment."

inputs:
python-version:
required: false
description: "The python version to use"
default: "3.12"

runs:
using: "composite"
steps:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.9
cache: true

- name: Install dependencies
run: pdm install
shell: bash
71 changes: 71 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Main

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up the environment
uses: ./.github/actions/setup-pdm-env

- name: Run checks
run: make check

tox:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']
fail-fast: false
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.9
cache: true

- name: Install dependencies
run: pdm install
shell: bash

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox

check-docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-pdm-env

- name: Check if documentation can be built
run: pdm run mkdocs build -s
20 changes: 20 additions & 0 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release-main

on:
release:
types: [published]
branches: [main]

jobs:

deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-pdm-env

- name: Deploy documentation
run: pdm run mkdocs gh-deploy --force
15 changes: 15 additions & 0 deletions .github/workflows/validate-codecov-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: validate-codecov-config

on:
pull_request:
paths: [codecov.yaml]
push:
branches: [main]

jobs:
validate-codecov-config:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Validate codecov configuration
run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.230"
hooks:
- id: ruff

- repo: https://github.com/psf/black
rev: "22.8.0"
hooks:
- id: black
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
150 changes: 150 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
============
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
----------------------

Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/major/rlsrag/issues

If you are reporting a bug, please include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug"
and "help wanted" is open to whoever wants to implement a fix for it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

Cookiecutter PyPackage could always use more documentation, whether as part of
the official docs, in docstrings, or even on the web in blog posts, articles,
and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at
https://github.com/major/rlsrag/issues.

If you are proposing a new feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
------------

Ready to contribute? Here's how to set up `rlsrag` for local
development. Please note this documentation assumes you already have
`PDM` and `Git` installed and ready to go.

| 1. Fork the `rlsrag` repo on GitHub.
| 2. Clone your fork locally:
.. code-block:: bash
cd <directory_in_which_repo_should_be_created>
git clone [email protected]:YOUR_NAME/rlsrag.git
| 3. Now we need to install the environment. Navigate into the directory
.. code-block:: bash
cd rlsrag
If you are using ``pyenv``, select a version to use locally. (See installed versions with ``pyenv versions``)

.. code-block:: bash
pyenv local <x.y.z>
Then, install the environment with:

.. code-block:: bash
pdm install
| 4. Install pre-commit to run linters/formatters at commit time:
.. code-block:: bash
pdm run pre-commit install
| 5. Create a branch for local development:
.. code-block:: bash
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.


| 6. Don't forget to add test cases for your added functionality to the ``tests`` directory.
| 7. When you're done making changes, check that your changes pass the formatting tests.
.. code-block:: bash
make check
| 8. Now, validate that all unit tests are passing:
.. code-block:: bash
make test
| 9. Before raising a pull request you should also run tox. This will run the
tests across different versions of Python:
.. code-block:: bash
tox
This requires you to have multiple versions of python installed.
This step is also triggered in the CI/CD pipeline, so you could also choose to skip this
step locally.

| 10. Commit your changes and push your branch to GitHub:
.. code-block:: bash
git add .
git commit -m "Your detailed description of your changes."
git push origin name-of-your-bugfix-or-feature
| 11. Submit a pull request through the GitHub website.
Pull Request Guidelines
---------------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.

2. If the pull request adds functionality, the docs should be updated. Put your
new functionality into a function with a docstring, and add the feature to
the list in README.rst.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM registry.access.redhat.com/ubi9/python-312:latest AS builder
WORKDIR /project

RUN pip3 install --upgrade --quiet pip pdm
ENV PDM_CHECK_UPDATE=false

COPY pyproject.toml pdm.lock README.md /project/
COPY packages/ /project/packages
COPY rlsrag/ /project/rlsrag
RUN pdm install --check --prod --no-editable

RUN pdm run download-model

FROM registry.access.redhat.com/ubi9/python-312:latest
WORKDIR /project
COPY --from=builder /project/.venv/ /project/.venv
COPY --from=builder /project/embedding_model/ /project/embedding_model
ENV PATH="/project/.venv/bin:$PATH"
COPY rlsrag /project/rlsrag
CMD ["python", "rlsrag/quicktest.py"]
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.PHONY: install
install: ## Install the environment and install the pre-commit hooks
@echo "🚀 Creating virtual environment using PDM"
@pdm install
@pdm run pre-commit install

.PHONY: check
check: ## Run code quality tools.
@echo "🚀 Checking pdm lock file consistency with 'pyproject.toml': Running pdm lock --check"
@pdm lock --check
@echo "🚀 Linting code: Running pre-commit"
@pdm run pre-commit run -a
@echo "🚀 Static type checking: Running mypy"
@pdm run mypy

.PHONY: test
test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
@pdm run pytest --cov --cov-config=pyproject.toml --cov-report=xml --cov-report=term-missing

.PHONY: build
build: clean-build ## Build wheel file
@echo "🚀 Creating wheel file"
@pdm build

.PHONY: clean-build
clean-build: ## clean build artifacts
@rm -rf dist

.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@pdm run mkdocs build -s

.PHONY: docs
docs: ## Build and serve the documentation
@pdm run mkdocs serve

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
9 changes: 9 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
range: 70..100
round: down
precision: 1
status:
project:
default:
target: 90%
threshold: 0.5%
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# rlsrag

[![Release](https://img.shields.io/github/v/release/major/rlsrag)](https://img.shields.io/github/v/release/major/rlsrag)
[![Build status](https://img.shields.io/github/actions/workflow/status/major/rlsrag/main.yml?branch=main)](https://github.com/major/rlsrag/actions/workflows/main.yml?query=branch%3Amain)
[![Commit activity](https://img.shields.io/github/commit-activity/m/major/rlsrag)](https://img.shields.io/github/commit-activity/m/major/rlsrag)
[![License](https://img.shields.io/github/license/major/rlsrag)](https://img.shields.io/github/license/major/rlsrag)

RAG training for RHEL Lightspeed
1 change: 1 addition & 0 deletions docs/modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: rlsrag
Loading

0 comments on commit b2a68b6

Please sign in to comment.