Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-kumar-pilla committed Oct 30, 2024
2 parents 5ccafb6 + 31b0492 commit 57f6ddf
Show file tree
Hide file tree
Showing 109 changed files with 2,923 additions and 2,979 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ make pytest
make e2e-tests
```

#### Linting tests (`isort`, `black`, `pylint`, `flake8` and `mypy`)
#### Linting tests (`ruff` linter and formatter, and `mypy`)

```bash
make lint
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ e2e-tests:
lint: format-fix lint-check

format-fix:
isort package/kedro_viz package/tests package/features
black package/kedro_viz package/tests package/features
ruff check --fix
ruff format

format-check:
isort --check package/kedro_viz package/tests package/features
black --check package/kedro_viz package/tests package/features
ruff check
ruff format --check

lint-check:
pylint --rcfile=package/.pylintrc -j 0 package/kedro_viz
pylint --rcfile=package/.pylintrc -j 0 --disable=protected-access,missing-docstring,redefined-outer-name,invalid-name,too-few-public-methods,no-member,unused-argument,duplicate-code,abstract-class-instantiated package/tests
pylint --rcfile=package/.pylintrc -j 0 --disable=missing-docstring,no-name-in-module,unused-argument package/features
flake8 --config=package/.flake8 package
ruff check
mypy --config-file=package/mypy.ini package/kedro_viz package/features
mypy --disable-error-code abstract --config-file=package/mypy.ini package/tests

Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Please follow the established format:
- Fix unserializable parameters value (#2122)
- Display full dataset type with library prefix in metadata panel (#2136)
- Enable SQLite WAL mode for Azure ML to fix database locking issues (#2131)
- Replace `flake8`, `isort`, `pylint` and `black` by `ruff` (#2149)


# Release 10.0.0
Expand Down
30 changes: 5 additions & 25 deletions demo-project/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,11 @@ repos:
- id: check-json # Checks json files for parseable syntax.
- id: check-case-conflict # Check for files that would conflict in case-insensitive filesystems
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: debug-statements # Check for debugger imports and py37+ `breakpoint()` calls in python source.
- id: requirements-txt-fixer # Sorts entries in requirements.txt
- id: flake8
args:
- "--max-line-length=100"
- "--max-complexity=18"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"
- "--ignore=E203,E266,E501,W503"

- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: isort
name: "Sort imports"
language: system
types: [file, python]
entry: isort
- id: black
name: "Black"
language: system
types: [file, python]
entry: black
- id: kedro lint
name: "Kedro lint"
language: python_venv
types: [file, python]
entry: kedro lint
stages: [commit]
- id: ruff
args: [--fix]
- id: ruff-format
1 change: 1 addition & 0 deletions demo-project/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from kedro.framework.cli.utils import find_stylesheets
from recommonmark.transform import AutoStructify

from demo_project import __version__ as release

# -- Project information -----------------------------------------------------
Expand Down
8 changes: 0 additions & 8 deletions demo-project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ package_name = "demo_project"
project_name = "modular-spaceflights"
kedro_init_version = "0.19.0"

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88
known_third_party = "kedro"

[tool.pytest.ini_options]
addopts = """
--cov-report term-missing \
Expand Down
5 changes: 5 additions & 0 deletions demo-project/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extend = "../ruff.toml"

[lint.isort]
known-first-party = ["demo_project"]
known-third-party = ["kedro"]
3 changes: 0 additions & 3 deletions demo-project/setup.cfg

This file was deleted.

3 changes: 1 addition & 2 deletions demo-project/src/demo_project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""demo-project
"""
"""demo-project"""

__version__ = "0.1"
1 change: 1 addition & 0 deletions demo-project/src/demo_project/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""demo-project file for ensuring the package is executable
as `demo-project` and `python -m demo_project`
"""

from pathlib import Path

from kedro.framework.project import configure_project
Expand Down
1 change: 1 addition & 0 deletions demo-project/src/demo_project/hooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Project hooks."""

import logging
import time
from typing import Any
Expand Down
4 changes: 3 additions & 1 deletion demo-project/src/demo_project/pipeline_registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Project pipelines."""

from typing import Dict

from kedro.pipeline import Pipeline
Expand All @@ -8,6 +9,7 @@
from demo_project.pipelines import modelling as mod
from demo_project.pipelines import reporting as rep


def register_pipelines() -> Dict[str, Pipeline]:
"""Register the project's pipelines.
Expand All @@ -24,7 +26,7 @@ def register_pipelines() -> Dict[str, Pipeline]:
)

reporting_pipeline = rep.create_pipeline()

return {
"__default__": (
ingestion_pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ def create_pipeline(**kwargs) -> Pipeline:
func=apply_types_to_companies,
inputs="companies",
outputs="int_typed_companies",
name='apply_types_to_companies',
tags='companies'
name="apply_types_to_companies",
tags="companies",
),
node(
func=apply_types_to_shuttles,
inputs="shuttles",
outputs="int_typed_shuttles@pandas1",
name='apply_types_to_shuttles',
tags='shuttles'
name="apply_types_to_shuttles",
tags="shuttles",
),
node(
func=apply_types_to_reviews,
inputs=["reviews", "params:typing.reviews.columns_as_floats"],
outputs="int_typed_reviews",
name='apply_types_to_reviews'
name="apply_types_to_reviews",
),
node(
func=aggregate_company_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
generated using Kedro 0.18.1
"""


from kedro.pipeline import Pipeline, node
from kedro.pipeline.modular_pipeline import pipeline

Expand Down
10 changes: 3 additions & 7 deletions demo-project/src/demo_project/pipelines/modelling/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,11 @@ def evaluate_model(
"""
y_pred = regressor.predict(X_test)
score = r2_score(y_test, y_pred)
a2_score = random.randint(0,100)*0.1
b2_score = random.randint(0,100)*0.1
a2_score = random.randint(0, 100) * 0.1
b2_score = random.randint(0, 100) * 0.1
logger = logging.getLogger(__name__)
logger.info(
f"Model has a coefficient R^2 of {score:.3f} on test data using a "
f"regressor of type '{type(regressor)}'"
)
return {
"r2_score": score,
"a2_score":a2_score,
"b2_score":b2_score
}
return {"r2_score": score, "a2_score": a2_score, "b2_score": b2_score}
6 changes: 3 additions & 3 deletions demo-project/src/demo_project/pipelines/modelling/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def new_train_eval_template() -> Pipeline:
func=train_model,
inputs=["X_train", "y_train", "params:dummy_model_options"],
outputs=["regressor", "experiment_params"],
tags="train"
tags="train",
),
node(
func=evaluate_model,
inputs=["regressor", "X_test", "y_test"],
outputs="r2_score",
tags="evaluate"
tags="evaluate",
),
]
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def create_pipeline(model_types: List[str]) -> Pipeline:
pipeline(
pipe=new_train_eval_template(),
parameters={"dummy_model_options": f"model_options.{model_type}"},
inputs={k: k for k in test_train_refs},
inputs={k: k for k in test_train_refs},
namespace=model_type,
)
for model_type in model_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self, _df: pd.DataFrame, x: int = 500, y: int = 200):
self._populate(_df)

def _draw_grid(self):

width, height = self.image.size
row_step = (height - self.border * 2) / (self.rows)
col_step = (width - self.border * 2) / (self.cols)
Expand Down
5 changes: 4 additions & 1 deletion demo-project/src/demo_project/pipelines/reporting/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
This is a boilerplate pipeline 'reporting'
generated using Kedro 0.18.1
"""

from typing import Dict

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import PIL
import plotly.express as px
import seaborn as sn
from plotly import graph_objects as go
from typing import Dict

from .image_utils import DrawTable


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from demo_project.pipelines.reporting.nodes import (
create_feature_importance_plot,
create_matplotlib_chart,
get_top_shuttles_data,
make_cancel_policy_bar_chart,
make_price_analysis_image,
make_price_histogram,
get_top_shuttles_data,
)


Expand Down
4 changes: 1 addition & 3 deletions demo-project/src/demo_project/requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
black~=22.0
flake8>=3.7.9, <4.0
ipython~=7.0
isort~=5.0
jupyter~=1.0
jupyter_client>=5.1, <7.0
jupyterlab~=3.0
Expand All @@ -16,4 +13,5 @@ wheel>=0.35, <0.37
pillow~=9.0
matplotlib==3.5.0
pre-commit~=1.17
ruff==0.7.0
seaborn>=0.13.0
1 change: 1 addition & 0 deletions demo-project/src/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
To run the tests, run ``kedro test``.
"""

from pathlib import Path

import pytest
Expand Down
7 changes: 0 additions & 7 deletions package/.flake8

This file was deleted.

9 changes: 0 additions & 9 deletions package/.isort.cfg

This file was deleted.

Loading

0 comments on commit 57f6ddf

Please sign in to comment.