Skip to content

Commit 3bcf4e6

Browse files
authored
Feature/config_dict (#28)
* feat: add config_dict and splitted rules capabilities Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com> * chore: fix pre-commit warnings Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com> * docs: add feature explanations Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com> * docs: typos Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com> * tests: typos Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com> --------- Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com>
1 parent 1eb503b commit 3bcf4e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+356
-140
lines changed

.github/ISSUE_TEMPLATE/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
blank_issues_enabled: false
2+
blank_issues_enabled: false

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ If needed, add some details here in order to verify the change (e.g., how to tes
1111

1212
## Linked issues: (optional)
1313
- Close ...
14-
- Close ...
14+
- Close ...

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
pip install .[dev,test]
3131
- name: Cache pre-commit hooks
3232
uses: actions/cache@v4
33-
with:
33+
with:
3434
path: ~/.cache/pre-commit
3535
key: ${{ runner.os }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
3636
- name: Run pre-commit hooks
@@ -47,7 +47,7 @@ jobs:
4747
- name: Checkout
4848
uses: actions/checkout@v4
4949
- name: Set up Python version
50-
uses: actions/setup-python@v5
50+
uses: actions/setup-python@v5
5151
with:
5252
python-version: '3.x'
5353
- name: Build package

.pre-commit-config.yaml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,44 @@
22
default_language_version:
33
python: python3
44
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.6.0
7+
hooks:
8+
- id: check-ast
9+
- id: check-byte-order-marker
10+
- id: check-case-conflict
11+
- id: check-docstring-first
12+
- id: check-json
13+
- id: check-yaml
14+
exclude: ^(docs/)
15+
- id: debug-statements
16+
- id: end-of-file-fixer
17+
exclude: ^(docs/)
18+
- id: pretty-format-json
19+
args: ['--autofix']
20+
- id: trailing-whitespace
21+
args: ['--markdown-linebreak-ext=md']
22+
exclude: ^(docs/)
23+
- id: mixed-line-ending
24+
args: ['--fix=lf']
25+
exclude: ^(docs/)
26+
- id: check-added-large-files
27+
args: ['--maxkb=500']
28+
- id: no-commit-to-branch
29+
args: ['--branch', 'main']
530
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.4.10
31+
rev: v0.5.4
732
hooks:
833
- id: ruff
934
args: [ --fix ]
1035
- id: ruff-format
1136
- repo: https://github.com/pre-commit/mirrors-mypy
12-
rev: 'v1.10.0'
37+
rev: v1.11.0
1338
hooks:
1439
- id: mypy
1540
args: [--config-file=pyproject.toml]
1641
files: src
42+
additional_dependencies: [pydantic~=2.0]
1743
- repo: https://github.com/gitleaks/gitleaks
1844
rev: v8.18.4
1945
hooks:
@@ -24,7 +50,7 @@ repos:
2450
- id: pip-audit
2551
args: ["--skip-editable"]
2652
- repo: https://github.com/compilerla/conventional-pre-commit
27-
rev: v3.2.0
53+
rev: v3.3.0
2854
hooks:
2955
- id: conventional-pre-commit
3056
stages: [commit-msg]

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.8.0] - July, 2024
8+
9+
### Features
10+
11+
* Add a new parameter `config_dict` in the `RulesEngine`'s constructor. It can be used when you have already loaded the YAML configuration in a dictionary and want to use it straightforward.
12+
* Split a rule set in two (or more) files (keep the rules organized by their file names [alphabetically sorted]).
13+
14+
### Fixes
15+
16+
* *Simple condition:* an error occurs when the right operand is a uppercase string (e.g., `input.text=="LABEL"`).
17+
18+
### Refactoring
19+
20+
* Function `sanitize_regex()` is converted to an instance method `get_sanitized_id()` of `BaseCondition` class.
721

822
## [0.7.1] - June, 2024
923

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ members of the project's leadership.
7070
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
7171
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
7272

73-
[homepage]: https://www.contributor-covenant.org
73+
[homepage]: https://www.contributor-covenant.org

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Explain the layout of your repo.
1111

1212
## Workflow
1313

14-
The steps below describe how to get a patch into a main development branch (e.g. `master`).
14+
The steps below describe how to get a patch into a main development branch (e.g. `master`).
1515
The steps are exactly the same for everyone involved in the project (be it core team, or first time contributor).
1616
We follow the standard GitHub [fork & pull](https://help.github.com/articles/using-pull-requests/#fork--pull) approach to pull requests. Just fork the official repo, develop in a branch, and submit a PR!
1717

@@ -20,22 +20,22 @@ We follow the standard GitHub [fork & pull](https://help.github.com/articles/usi
2020
1. [Fork the project](https://github.com/MAIF/arta#fork-destination-box) on GitHub. You'll need to create a feature-branch for your work on your fork, as this way you'll be able to submit a pull request against the mainline *Arta*.
2121
1. Create a branch on your fork and work on the feature. For example: `git checkout -b feature/awesome-new-feature`
2222
- Please make sure to follow the general quality guidelines (specified below) when developing your patch.
23-
- Please write additional tests covering your feature and adjust existing ones if needed before submitting your pull request.
23+
- Please write additional tests covering your feature and adjust existing ones if needed before submitting your pull request.
2424
1. Once your feature is complete, prepare the commit with a good commit message, for example: `Adding canary mode support for services #42` (note the reference to the ticket it aimed to resolve).
2525
1. If it's a new feature, or a change of behaviour, document it on the [Arta docs](https://maif.github.io/arta/home/), remember, an undocumented feature is not a feature.
2626
1. Now it's finally time to [submit the pull request](https://help.github.com/articles/using-pull-requests)!
2727
- Please make sure to include a reference to the issue you're solving *in the comment* for the Pull Request, this will cause the PR to be linked properly with the Issue. Examples of good phrases for this are: "Resolves #1234" or "Refs #1234".
2828
1. Now both committers and interested people will review your code. This process is to ensure the code we merge is of the best possible quality, and that no silly mistakes slip through. You're expected to follow-up these comments by adding new commits to the same branch. The commit messages of those commits can be more loose, for example: `Removed debugging using printline`, as they all will be squashed into one commit before merging into the main branch.
2929
- The community and team are eager to share, so don't be afraid to ask follow up questions if you didn't understand some comment, or would like clarification on how to continue with a given feature. We're here to help, so feel free to ask and discuss any kind of questions you might have during review!
30-
1. After the review you should fix the issues as needed (pushing a new commit for new review etc.), iterating until the reviewers give their thumbs up–which is signalled usually by a comment saying `LGTM`, which means "Looks Good To Me".
30+
1. After the review you should fix the issues as needed (pushing a new commit for new review etc.), iterating until the reviewers give their thumbs up–which is signalled usually by a comment saying `LGTM`, which means "Looks Good To Me".
3131
1. If the code change needs to be applied to other branches as well (for example a bugfix needing to be backported to a previous version), one of the team will either ask you to submit a PR with the same commit to the old branch, or do this for you.
3232
1. Once everything is said and done, your pull request gets merged. You've made it!
3333

3434
The TL;DR; of the above very precise workflow version is:
3535

3636
1. Fork arta
3737
2. Hack and test on your feature (on a branch)
38-
3. Document it
38+
3. Document it
3939
4. Submit a PR
4040
6. Keep polishing it until received thumbs up from the core team
4141
7. Profit!
@@ -74,4 +74,4 @@ pytest tests/
7474

7575
## Continuous integration
7676

77-
TODO
77+
TODO

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@
174174
incurred by, or claims asserted against, such Contributor by reason
175175
of your accepting any such warranty or additional liability.
176176

177-
END OF TERMS AND CONDITIONS
177+
END OF TERMS AND CONDITIONS

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ Unless required by applicable law or agreed to in writing, software
1212
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1313
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1414
License for the specific language governing permissions and limitations under
15-
the License.
15+
the License.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
</p>
77
<p align="center">
88
<img src="https://github.com/MAIF/arta/actions/workflows/ci-cd.yml/badge.svg?branch=main" alt="CI">
9-
<img src="https://img.shields.io/badge/coverage-97%25-dark_green" alt="Coverage">
9+
<img src="https://img.shields.io/badge/coverage-95%25-dark_green" alt="Coverage">
1010
<img src="https://img.shields.io/pypi/v/arta" alt="Versions">
1111
<img src="https://img.shields.io/pypi/pyversions/arta" alt="Python">
12-
<img src="https://img.shields.io/pypi/dm/arta" alt="Downloads">
12+
<img src="https://img.shields.io/pypi/implementation/arta" alt="Python implementation">
13+
<img src="https://img.shields.io/pepy/dt/arta" alt="Downloads">
1314
</p>
1415

1516
---
@@ -34,7 +35,7 @@ In other words, facilitate rules handling in our python apps.
3435

3536
The need of a python *rules engine* emerged when we were working on a new major release of our internal use of [Melusine](https://github.com/maif/melusine) (i.e., email qualification pipeline with ML capabilities).
3637

37-
We were looking for a python library to *centralize, manage and standardize* all the implemented **business rules** we had but didn't find the perfect fit.
38+
We were looking for a python library to *centralize, manage and standardize* all the implemented **business rules** we had but didn't find the perfect fit.
3839

3940
Therefore, we decided to create this package and by extension of the MAIF's values, we planned to share it to the community.
4041

@@ -139,4 +140,3 @@ and general hints on how to prepare your pull request. You can also ask for clar
139140
This project is Open Source and available under the Apache 2 License.
140141

141142
[![Alt MAIF Logo](https://static.maif.fr/resources/img/logo-maif.svg)](https://www.maif.fr/)
142-

0 commit comments

Comments
 (0)