Skip to content

Commit

Permalink
Merge pull request #35 from pier-digital/f/update-dependencies
Browse files Browse the repository at this point in the history
comprehensive dependencies
  • Loading branch information
gabrielguarisa authored Oct 18, 2024
2 parents 69ba2b9 + 9f3936f commit 74ef947
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 47 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '**/*.md'
- '**/*.png'
- '**/*.json'
- "**/*.md"
- "**/*.png"
- "**/*.json"

jobs:
test:
Expand All @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9, 3.11]
python-version: [3.9, 3.12]
poetry-version: [1.4.2]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -63,4 +63,4 @@ jobs:
- name: Install dependencies
run: make init
- name: Run style checks
run: make check-formatting
run: make check-formatting
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.11]
python-version: [3.12]
poetry-version: [1.4.2]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
Expand All @@ -27,4 +27,4 @@ jobs:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
poetry publish --build
2 changes: 1 addition & 1 deletion examples/cpf_digit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Example of rule to get the eighth digit of a CPF."""
"""Example of rule to get the eighth digit of a CPF."""

import retrack
import pandas as pd
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "retrack"
version = "2.9.0"
version = "2.10.0"
description = "A business rules engine"
authors = ["Gabriel Guarisa <[email protected]>"]
license = "MIT"
Expand All @@ -11,16 +11,16 @@ keywords = ["rules", "models", "business", "node", "graph"]

[tool.poetry.dependencies]
python = ">=3.9,<4.0.0"
pandas = "^1.2.0"
numpy = "^1.19.5"
pydantic = "2.4.2"
networkx = "^2.6.3"
pandera = "^0.17.2"
pandas = ">=1.2.0,~2"
numpy = ">=1.19.5,<2"
pydantic = "~2"
networkx = "~3"
pandera = "~0.20"

[tool.poetry.dev-dependencies]
pytest = "*"
pytest-cov = "*"
ruff = "^0.1.2"
ruff = "*"
pytest-mock = "*"

[tool.pytest.ini_options]
Expand Down
4 changes: 3 additions & 1 deletion retrack/engine/request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def __create_model(
default=Ellipsis
if input_field.data.default is None
else input_field.data.default,
optional=input_field.data.default is not None,
json_schema_extra={
"optional": input_field.data.default is not None
},
validate_default=False,
),
)
Expand Down
12 changes: 6 additions & 6 deletions retrack/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class InputConnectionModel(pydantic.BaseModel):
class BaseNode(pydantic.BaseModel):
id: CastedToStringType
name: str
inputs: typing.Optional[
typing.Dict[CastedToStringType, InputConnectionModel]
] = None
outputs: typing.Optional[
typing.Dict[CastedToStringType, OutputConnectionModel]
] = None
inputs: typing.Optional[typing.Dict[CastedToStringType, InputConnectionModel]] = (
None
)
outputs: typing.Optional[typing.Dict[CastedToStringType, OutputConnectionModel]] = (
None
)

def run(self, **kwargs) -> typing.Dict[str, typing.Any]:
return {}
Expand Down
2 changes: 1 addition & 1 deletion retrack/nodes/dynamic/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(self, **kwargs) -> typing.Dict[str, typing.Any]:

def generate_input_nodes(self):
input_nodes = []
for component in rule_instance.components_registry.data.values():
for component in rule_instance.components_registry.memory.values():
input_nodes.extend(component.generate_input_nodes())
return input_nodes

Expand Down
2 changes: 1 addition & 1 deletion retrack/utils/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def validate_data(data: dict) -> dict:
def validate_with_validators(
graph_data: dict, edges: dict, validator_registry: Registry
):
for validator_name, validator in validator_registry.data.items():
for validator_name, validator in validator_registry.memory.items():
if not validator.validate(graph_data=graph_data, edges=edges):
raise ValueError(f"Invalid graph data: {validator_name}")

Expand Down
10 changes: 0 additions & 10 deletions retrack/utils/registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import typing
import warnings


class Registry:
Expand Down Expand Up @@ -33,15 +32,6 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any:

return self._memory.get(key, default)

@property
def data(self) -> typing.Dict[str, typing.Any]:
"""Return the registry memory."""
warnings.warn(
"The 'data' property is deprecated, use 'memory' instead.",
DeprecationWarning,
)
return self._memory

@property
def keys(self) -> typing.List[str]:
"""Return the registry keys."""
Expand Down
14 changes: 10 additions & 4 deletions tests/test_engine/test_conditional_connector_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import pandas as pd
import pytest

VALUES = {"qtd_sinistros_rcf": 1, "qtd_sinistros_indefinido": 10, "is_defendant_and_court_type": False}
VALUES = {
"qtd_sinistros_rcf": 1,
"qtd_sinistros_indefinido": 10,
"is_defendant_and_court_type": False,
}


def bureau_connector_factory(
Expand All @@ -24,11 +28,13 @@ def run(
raise ValueError(
f"Missing input {in_node_key} in BureauConnector node"
)

if node_inputs[in_node_key].empty:
return {"output_value": None}

parsed_inputs[self.data.headers[i]] = node_inputs[in_node_key].to_list()[0]
parsed_inputs[self.data.headers[i]] = node_inputs[
in_node_key
].to_list()[0]

return {"output_value": VALUES[self.data.resource]}

Expand Down Expand Up @@ -68,4 +74,4 @@ def test_bureau_connector_factory(

result = rule_executor.execute(df, raise_raw_exception=True)
assert result["output"].to_list()[0] == expected_result
assert result["message"].to_list()[0] == expected_message
assert result["message"].to_list()[0] == expected_message
18 changes: 9 additions & 9 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@

def test_create_registry():
registry = Registry()
assert registry.data == {}
assert registry.memory == {}


def test_register_model():
registry = Registry()
registry.register("test", str)
assert registry.data == {"test": str}
registry.register("test", "example")
assert registry.memory == {"test": "example"}


def test_get_model():
registry = Registry()
registry.register("test", str)
assert registry.get("test") == str
registry.register("test", "example")
assert registry.get("test") == "example"


def test_get_model_not_found():
registry = Registry()
registry.register("test", str)
registry.register("test", "example")
assert registry.get("test2") is None


def test_contains_model():
registry = Registry()
registry.register("test", str)
registry.register("test", "example")
assert "test" in registry


def test_model_already_registered():
registry = Registry()
registry.register("test", str)
registry.register("test", "example")
with pytest.raises(ValueError):
registry.register("test", str)
registry.register("test", "example")

0 comments on commit 74ef947

Please sign in to comment.