Skip to content

Commit

Permalink
Allow latest ruff versions (#2487)
Browse files Browse the repository at this point in the history
* allow latest ruff

* Auto-update of Starter template

* Auto-update of E2E template

* Auto-update of NLP template

* Update pyproject.toml

* format

* ruff reformatting

* ruff reformatting

* Auto-update of Starter template

* fix deprecated commands

* Auto-update of E2E template

---------

Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: Safoine El Khabich <34200873+safoinme@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 1, 2024
1 parent dd12148 commit 12d68dd
Show file tree
Hide file tree
Showing 347 changed files with 547 additions and 411 deletions.
13 changes: 6 additions & 7 deletions examples/e2e/pipelines/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,12 @@ def e2e_use_case_training(
target=target,
)
########## Promotion stage ##########
(
latest_metric,
current_metric,
) = compute_performance_metrics_on_current_data(
dataset_tst=dataset_tst,
target_env=target_env,
after=["model_evaluator"],
latest_metric, current_metric = (
compute_performance_metrics_on_current_data(
dataset_tst=dataset_tst,
target_env=target_env,
after=["model_evaluator"],
)
)

promote_with_metric_compare(
Expand Down
18 changes: 9 additions & 9 deletions examples/e2e/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def main(
"configs",
"train_config.yaml",
)
pipeline_args[
"run_name"
] = f"e2e_use_case_training_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
pipeline_args["run_name"] = (
f"e2e_use_case_training_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
)
e2e_use_case_training.with_options(**pipeline_args)(**run_args_train)
logger.info("Training pipeline finished successfully!")

Expand All @@ -193,9 +193,9 @@ def main(
"configs",
"deployer_config.yaml",
)
pipeline_args[
"run_name"
] = f"e2e_use_case_deployment_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
pipeline_args["run_name"] = (
f"e2e_use_case_deployment_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
)
e2e_use_case_deployment.with_options(**pipeline_args)(**run_args_inference)

# Execute Batch Inference Pipeline
Expand All @@ -205,9 +205,9 @@ def main(
"configs",
"inference_config.yaml",
)
pipeline_args[
"run_name"
] = f"e2e_use_case_batch_inference_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
pipeline_args["run_name"] = (
f"e2e_use_case_batch_inference_run_{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
)
e2e_use_case_batch_inference.with_options(**pipeline_args)(
**run_args_inference
)
Expand Down
51 changes: 27 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ tox = { version = "^3.24.3", optional = true }
hypothesis = { version = "^6.43.1", optional = true }
typing-extensions = { version = ">=3.7.4", optional = true }
darglint = { version = "^1.8.1", optional = true }
ruff = { version = "0.1.7", optional = true }
ruff = { version = ">=0.1.7", optional = true }
yamlfix = { version = "^1.16.0", optional = true }

# pytest
Expand Down Expand Up @@ -305,8 +305,29 @@ exclude = [
'__init__.py',
'src/zenml/cli/version.py',
]

src = ["src", "test"]
# use Python 3.8 as the minimum version for autofixing
target-version = "py38"


[tool.ruff.format]
exclude = [
"*.git",
"*.hg",
".mypy_cache",
".tox",
".venv",
"_build",
"buck-out",
"build]",
]

[tool.ruff.lint]
# Disable autofix for unused imports (`F401`).
unfixable = ["F401"]
per-file-ignores = {}
select = ["D", "E", "F", "I", "I001", "Q"]
ignore-init-module-imports = true
ignore = [
"E501",
"F401",
Expand All @@ -323,37 +344,19 @@ ignore = [
"S106",
"S107",
]
src = ["src", "test"]
# use Python 3.8 as the minimum version for autofixing
target-version = "py38"
ignore-init-module-imports = true
# Disable autofix for unused imports (`F401`).
unfixable = ["F401"]

[tool.ruff.format]
exclude = [
"*.git",
"*.hg",
".mypy_cache",
".tox",
".venv",
"_build",
"buck-out",
"build]",
]

select = ["D", "E", "F", "I", "I001", "Q"]

[tool.ruff.flake8-import-conventions.aliases]
[tool.ruff.lint.flake8-import-conventions.aliases]
altair = "alt"
"matplotlib.pyplot" = "plt"
numpy = "np"
pandas = "pd"
seaborn = "sns"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 18

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"

Expand Down
4 changes: 2 additions & 2 deletions scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export ZENML_DEBUG=1
export ZENML_ANALYTICS_OPT_IN=false

# autoflake replacement: removes unused imports and variables
ruff $SRC --select F401,F841 --fix --exclude "__init__.py" --isolated
ruff check $SRC --select F401,F841 --fix --exclude "__init__.py" --isolated

# sorts imports
ruff $SRC --select I --fix --ignore D
ruff check $SRC --select I --fix --ignore D
ruff format $SRC

# standardises / formats CI yaml files
Expand Down
6 changes: 3 additions & 3 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ TESTS_EXAMPLES=${1:-"tests examples"}

export ZENML_DEBUG=1
export ZENML_ANALYTICS_OPT_IN=false
ruff $SRC_NO_TESTS
ruff check $SRC_NO_TESTS
# TODO: Fix docstrings in tests and examples and remove the `--extend-ignore D` flag
ruff $TESTS_EXAMPLES --extend-ignore D
ruff check $TESTS_EXAMPLES --extend-ignore D

# Flag check for skipping yamlfix
if [ "$OS" = "windows-latest" ]; then
Expand All @@ -34,7 +34,7 @@ if [ "$SKIP_YAMLFIX" = false ]; then
fi

# autoflake replacement: checks for unused imports and variables
ruff $SRC --select F401,F841 --exclude "__init__.py" --isolated
ruff check $SRC --select F401,F841 --exclude "__init__.py" --isolated

ruff format $SRC --check

Expand Down
1 change: 1 addition & 0 deletions scripts/verify_flavor_url_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Verify the current flavor implementations contains valid fields."""

import os.path
import tempfile
from typing import Type
Expand Down
1 change: 1 addition & 0 deletions src/zenml/_hub/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Client for the ZenML Hub."""

import os
from json import JSONDecodeError
from typing import Any, Dict, List, Optional
Expand Down
1 change: 0 additions & 1 deletion src/zenml/_hub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# permissions and limitations under the License.
"""Utility functions for the ZenML Hub."""


from typing import Optional, Tuple

from zenml._hub.constants import ZENML_HUB_ADMIN_USERNAME
Expand Down
1 change: 1 addition & 0 deletions src/zenml/actions/base_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Base implementation of actions."""

import json
from abc import ABC, abstractmethod
from typing import Any, ClassVar, Dict, Optional, Type
Expand Down
13 changes: 7 additions & 6 deletions src/zenml/actions/pipeline_run/pipeline_run_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Example file of what an action Plugin could look like."""

from typing import Any, ClassVar, Dict, Optional, Type
from uuid import UUID

Expand Down Expand Up @@ -205,11 +206,11 @@ class PipelineRunActionFlavor(BaseActionFlavor):

FLAVOR: ClassVar[str] = "builtin"
SUBTYPE: ClassVar[PluginSubType] = PluginSubType.PIPELINE_RUN
PLUGIN_CLASS: ClassVar[
Type[PipelineRunActionHandler]
] = PipelineRunActionHandler
PLUGIN_CLASS: ClassVar[Type[PipelineRunActionHandler]] = (
PipelineRunActionHandler
)

# EventPlugin specific
ACTION_CONFIG_CLASS: ClassVar[
Type[PipelineRunActionConfiguration]
] = PipelineRunActionConfiguration
ACTION_CONFIG_CLASS: ClassVar[Type[PipelineRunActionConfiguration]] = (
PipelineRunActionConfiguration
)
1 change: 1 addition & 0 deletions src/zenml/analytics/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
This module is based on the 'analytics-python' package created by Segment.
The base functionalities are adapted to work with the ZenML analytics server.
"""

from types import TracebackType
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
from uuid import UUID
Expand Down
1 change: 1 addition & 0 deletions src/zenml/analytics/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Collection of analytics events for ZenML."""

from enum import Enum


Expand Down
1 change: 1 addition & 0 deletions src/zenml/analytics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Helper models for ZenML analytics."""

from typing import Any, ClassVar, Dict, List

from pydantic import BaseModel
Expand Down
1 change: 1 addition & 0 deletions src/zenml/analytics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Utility functions and classes for ZenML analytics."""

import json
import os
from functools import wraps
Expand Down
1 change: 0 additions & 1 deletion src/zenml/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
slow down the CLI.
"""


from typing import Optional

from zenml.logger import get_logger
Expand Down
1 change: 1 addition & 0 deletions src/zenml/artifact_stores/base_artifact_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""The base interface to extend the ZenML artifact store."""

import textwrap
from abc import abstractmethod
from typing import (
Expand Down
1 change: 1 addition & 0 deletions src/zenml/artifacts/artifact_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Artifact Config classes to support Model Control Plane feature."""

from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from pydantic import BaseModel, root_validator
Expand Down
1 change: 1 addition & 0 deletions src/zenml/artifacts/external_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""External artifact definition."""

import os
from typing import Any, Dict, Optional, Type, Union
from uuid import UUID, uuid4
Expand Down
1 change: 1 addition & 0 deletions src/zenml/artifacts/external_artifact_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""External artifact definition."""

from typing import Any, Dict, Optional
from uuid import UUID

Expand Down
1 change: 0 additions & 1 deletion src/zenml/artifacts/unmaterialized_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# permissions and limitations under the License.
"""Unmaterialized artifact class."""


from zenml.models import (
ArtifactVersionResponse,
RunMetadataResponse,
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with artifacts."""

from functools import partial
from typing import Any, Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/authorized_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with authorized devices."""

from typing import Any

import click
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/code_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with code repositories."""

from typing import Any, List, Optional

import click
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with the ZenML Hub."""

import os
import shutil
import subprocess
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with Model Control Plane."""

from typing import Any, Dict, List, Optional

import click
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with pipelines."""

import json
import os
from typing import Any, Dict, Optional, Union
Expand Down
1 change: 1 addition & 0 deletions src/zenml/cli/service_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI functionality to interact with API keys."""

from typing import Any, Optional

import click
Expand Down
13 changes: 7 additions & 6 deletions src/zenml/cli/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""CLI for manipulating ZenML local and global config file."""

import getpass
import os
from pathlib import Path
Expand Down Expand Up @@ -248,13 +249,13 @@ def register_stack(
if step_operator:
components[StackComponentType.STEP_OPERATOR] = step_operator
if experiment_tracker:
components[
StackComponentType.EXPERIMENT_TRACKER
] = experiment_tracker
components[StackComponentType.EXPERIMENT_TRACKER] = (
experiment_tracker
)
if container_registry:
components[
StackComponentType.CONTAINER_REGISTRY
] = container_registry
components[StackComponentType.CONTAINER_REGISTRY] = (
container_registry
)

try:
created_stack = client.create_stack(
Expand Down
Loading

0 comments on commit 12d68dd

Please sign in to comment.