Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix_issues #11

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assignees: ''

---

**Is your feature request related to a problem? Please describe.**
**Is your feature request related to a problem? Please describe**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-cd-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
tags:
- '*' # Later: \b[0-9]\.[0-9]+\.[0-9]+[ab]?[0-9]?\b
pull_request:
types:
- opened
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
tags:
- '*' # Later: \b[0-9]\.[0-9]+\.[0-9]+[ab]?[0-9]?\b
pull_request:
types:
- opened
Expand Down Expand Up @@ -35,8 +37,11 @@ jobs:
run: pre-commit run --all-files
publish:
if: success() && startsWith(github.ref, 'refs/tags')
name: Publish to PyPI
name: Publish release to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -48,8 +53,5 @@ jobs:
run: |
python -m pip install --upgrade build
python -m build
- name: Publish package distributions to PyPI
- name: Upload package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.5
hooks:
- id: ruff
args: [ --fix ]
Expand All @@ -17,8 +17,13 @@ repos:
rev: v8.18.2
hooks:
- id: gitleaks
- repo: https://github.com/pypa/pip-audit
rev: v2.7.2
hooks:
- id: pip-audit
args: ["--skip-editable"]
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.1.0
rev: v3.2.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
10 changes: 2 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ All notable changes to this project will be documented in this file.

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).

## [0.7.0] - 2014-04-13
## [0.7.0] - April, 2024

### Added
### New Features
- Beta release implementing what you can find in its [documentation](https://pages.github.com/MAIF/arta).

### Changed
- Nothing.

### Removed
- Nothing.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This software is licensed under the Apache 2 license, quoted below.

Copyright 2019 MAIF and contributors
Copyright 2024 MAIF and contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ authors = [
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
]

dependencies = [
"omegaconf",
"pydantic",
"omegaconf>=2.0.0",
"pydantic>=1.0.0",
]

[project.optional-dependencies]
Expand All @@ -44,7 +44,7 @@ package-dir = {"" = "src"}
where = ["src"]

[tool.setuptools.package-data]
"*" = ["py.typed"]
"arta" = ["py.typed"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
3 changes: 1 addition & 2 deletions src/arta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from importlib.metadata import version

from arta._engine import RulesEngine
from arta.utils import ConditionExecutionError, RuleExecutionError

__all__ = ["RulesEngine", "ConditionExecutionError", "RuleExecutionError"]
__all__ = ["RulesEngine"]

__version__ = version("arta")
3 changes: 2 additions & 1 deletion src/arta/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, List, Optional, Set

from arta.utils import UPPERCASE_WORD_PATTERN, ConditionExecutionError, ParsingErrorStrategy, parse_dynamic_parameter
from arta.exceptions import ConditionExecutionError
from arta.utils import UPPERCASE_WORD_PATTERN, ParsingErrorStrategy, parse_dynamic_parameter


class BaseCondition(ABC):
Expand Down
13 changes: 13 additions & 0 deletions src/arta/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Custom exceptions."""


class RuleExecutionError(Exception):
"""Rule fails during its execution."""

pass


class ConditionExecutionError(Exception):
"""Condition fails during its execution."""

pass
3 changes: 1 addition & 2 deletions src/arta/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
from typing import Any, Callable, Dict, Optional, Set, Tuple, Type

from arta.condition import BaseCondition, StandardCondition
from arta.exceptions import ConditionExecutionError, RuleExecutionError
from arta.utils import (
ConditionExecutionError,
ParsingErrorStrategy,
RuleExecutionError,
parse_dynamic_parameter,
sanitize_regex,
)
Expand Down
12 changes: 0 additions & 12 deletions src/arta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
UPPERCASE_WORD_PATTERN: str = r"\b[A-Z_0-9]+\b"


class RuleExecutionError(Exception):
"""Exception raised when a Rule fails during its execution."""

pass


class ConditionExecutionError(Exception):
"""Exception raised when a Condition fails during its execution."""

pass


class ParsingErrorStrategy(str, Enum):
"""Define authorized error handling strategies when a key is missing in the input data."""

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_engine_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from arta import RulesEngine
from arta import ConditionExecutionError, RuleExecutionError
from arta.exceptions import ConditionExecutionError, RuleExecutionError

try:
from pydantic import v1 as pydantic
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_simple_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from arta import RulesEngine
from arta.utils import ConditionExecutionError, RuleExecutionError
from arta.exceptions import ConditionExecutionError, RuleExecutionError


@pytest.mark.parametrize(
Expand Down