diff --git a/.darglint b/.darglint deleted file mode 100644 index 68a1086042b..00000000000 --- a/.darglint +++ /dev/null @@ -1,2 +0,0 @@ -[darglint] -docstring_style=google diff --git a/.github/workflows/ci-fast.yml b/.github/workflows/ci-fast.yml index 23ed8009c4e..fce1474f1a1 100644 --- a/.github/workflows/ci-fast.yml +++ b/.github/workflows/ci-fast.yml @@ -14,23 +14,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - docstring-check: - if: github.event.pull_request.draft == false - runs-on: arc-runner-set - steps: - - name: Checkout code - uses: actions/checkout@v4.1.1 - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: '3.10' - - name: Install darglint using uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - source $HOME/.cargo/env - uv pip install --system darglint - - name: Check docstrings - run: bash scripts/docstring.sh sqlite-db-migration-testing-random: runs-on: arc-runner-set env: diff --git a/.github/workflows/ci-slow.yml b/.github/workflows/ci-slow.yml index 592c8466dd3..5fa05320efb 100644 --- a/.github/workflows/ci-slow.yml +++ b/.github/workflows/ci-slow.yml @@ -39,23 +39,6 @@ jobs: run: | echo "Please add the 'run-slow-ci' label to this PR before merging." exit 1 - docstring-check: - if: github.event.pull_request.draft == false - needs: run-slow-ci-label-is-set - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.1.1 - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: '3.10' - - name: Install current package as editable - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - source $HOME/.cargo/env - uv pip install --system darglint - - name: Check docstrings - run: bash scripts/docstring.sh mysql-db-migration-testing-full: if: github.event.pull_request.draft == false needs: run-slow-ci-label-is-set diff --git a/pyproject.toml b/pyproject.toml index e019e7b4532..1a76aa1d2c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,7 +131,7 @@ pyment = { version = "^0.3.3", optional = true } 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 } +pydoclint = { version = "^0.5.7", optional = true } ruff = { version = ">=0.1.7", optional = true } yamlfix = { version = "^1.16.0", optional = true } maison = { version = "<2.0", optional = true } @@ -225,7 +225,7 @@ dev = [ "tox", "hypothesis", "typing-extensions", - "darglint", + "pydoclint", "pytest-randomly", "pytest-mock", "pytest-clarity", @@ -374,6 +374,14 @@ max-complexity = 18 # Use Google-style docstrings. convention = "google" +[tool.pydoclint] +style = 'google' +arg-type-hints-in-docstring = false +check-return-types = false +check-arg-order = false +allow-init-docstring = true +check-class-attributes = false + [tool.mypy] plugins = ["pydantic.mypy"] diff --git a/scripts/docstring.sh b/scripts/docstring.sh deleted file mode 100755 index 8ec0e99f337..00000000000 --- a/scripts/docstring.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -e -set -x - -DOCSTRING_SRC=${1:-"src/zenml tests/harness"} - -export ZENML_DEBUG=1 -export ZENML_ANALYTICS_OPT_IN=false - -darglint -v 2 $DOCSTRING_SRC diff --git a/scripts/install-zenml-dev.sh b/scripts/install-zenml-dev.sh index 1f8e8b338ca..b0de377d837 100755 --- a/scripts/install-zenml-dev.sh +++ b/scripts/install-zenml-dev.sh @@ -70,6 +70,17 @@ install_integrations() { uv pip install $PIP_ARGS -r integration-requirements.txt rm integration-requirements.txt + + # TODO: remove after testing this in the CI + # shows what is installing docstring-parser + uv pip install $PIP_ARGS pipdeptree + pipdeptree -r -p docstring-parser + uv pip uninstall $PIP_ARGS pipdeptree -y + + # to avoid conflicts with the one installed + # by pydoclint (i.e. docstring-parser-fork) + uv pip uninstall docstring-parser -y + } set -x diff --git a/scripts/lint.sh b/scripts/lint.sh index 26bbcdaa3ed..c318006b238 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -38,5 +38,8 @@ ruff check $SRC --select F401,F841 --exclude "__init__.py" --exclude "*.ipynb" - ruff format $SRC --check +# pydoclint docstring linter +pydoclint -q $SRC_NO_TESTS + # check type annotations mypy $SRC_NO_TESTS diff --git a/scripts/run-ci-checks.sh b/scripts/run-ci-checks.sh index 9df05f8ecae..59044e1549f 100755 --- a/scripts/run-ci-checks.sh +++ b/scripts/run-ci-checks.sh @@ -7,4 +7,3 @@ export ZENML_ANALYTICS_OPT_IN=false scripts/lint.sh scripts/check-spelling.sh -scripts/docstring.sh diff --git a/src/zenml/analytics/utils.py b/src/zenml/analytics/utils.py index 7e4c30bc0f5..4ee08411e8e 100644 --- a/src/zenml/analytics/utils.py +++ b/src/zenml/analytics/utils.py @@ -232,6 +232,8 @@ def __exit__( value: The instance of the exception traceback: The traceback of the exception + Returns: + None """ if traceback is not None: self.metadata.update({"event_success": False}) diff --git a/src/zenml/artifact_stores/base_artifact_store.py b/src/zenml/artifact_stores/base_artifact_store.py index 57a4bf5aa27..09a23c4d449 100644 --- a/src/zenml/artifact_stores/base_artifact_store.py +++ b/src/zenml/artifact_stores/base_artifact_store.py @@ -54,14 +54,6 @@ class _sanitize_paths: Extra decoration layer is needed to pass in fixed artifact store root path for static methods that are called on filesystems directly. - - Args: - func: The function to decorate. - fixed_root_path: The fixed artifact store root path. - is_static: Whether the function is static or not. - - Returns: - Function that calls the input function with sanitized path inputs. """ def __init__(self, func: Callable[..., Any], fixed_root_path: str) -> None: diff --git a/src/zenml/artifacts/external_artifact_config.py b/src/zenml/artifacts/external_artifact_config.py index 1cc0842b4bf..8bfdc5cb163 100644 --- a/src/zenml/artifacts/external_artifact_config.py +++ b/src/zenml/artifacts/external_artifact_config.py @@ -61,9 +61,8 @@ def get_artifact_version_id(self) -> UUID: Raises: RuntimeError: If the artifact store of the referenced artifact - is not the same as the one in the active stack. - RuntimeError: If neither the ID nor the name of the artifact was - provided. + is not the same as the one in the active stack or if neither the + ID nor the name of the artifact was provided. """ from zenml.client import Client diff --git a/src/zenml/artifacts/utils.py b/src/zenml/artifacts/utils.py index 7912f568400..eeea40ea4b5 100644 --- a/src/zenml/artifacts/utils.py +++ b/src/zenml/artifacts/utils.py @@ -773,7 +773,7 @@ def _load_file_from_artifact_store( Raises: DoesNotExistException: If the file does not exist in the artifact store. NotImplementedError: If the artifact store cannot open the file. - IOError: If the artifact store rejects the request. + e: If the artifact store rejects the request. """ try: with artifact_store.open(uri, mode) as text_file: diff --git a/src/zenml/cli/cli.py b/src/zenml/cli/cli.py index baa29bafbe5..8eb26b0401e 100644 --- a/src/zenml/cli/cli.py +++ b/src/zenml/cli/cli.py @@ -51,7 +51,7 @@ def __init__( name: The name of the group. tag: The tag of the group. commands: The commands of the group. - kwargs: Additional keyword arguments. + **kwargs: Additional keyword arguments. """ super(TagGroup, self).__init__(name, commands, **kwargs) self.tag = tag or CliCategories.OTHER_COMMANDS diff --git a/src/zenml/cli/formatter.py b/src/zenml/cli/formatter.py index 2c536237437..c2499dc4e78 100644 --- a/src/zenml/cli/formatter.py +++ b/src/zenml/cli/formatter.py @@ -47,7 +47,7 @@ def iter_rows( col_count: The number of columns in the table. Yields: - An iterator over the rows of the table. + Tuple[str, ...]: A row of the table, padded with empty strings if necessary. """ for row in rows: yield row + ("",) * (col_count - len(row)) diff --git a/src/zenml/cli/secret.py b/src/zenml/cli/secret.py index 098d56db896..8805fb83e2b 100644 --- a/src/zenml/cli/secret.py +++ b/src/zenml/cli/secret.py @@ -170,7 +170,7 @@ def list_secrets(**kwargs: Any) -> None: """List all secrets that fulfill the filter criteria. Args: - kwargs: Keyword arguments to filter the secrets. + **kwargs: Keyword arguments to filter the secrets. """ client = Client() with console.status("Listing secrets..."): diff --git a/src/zenml/cli/service_accounts.py b/src/zenml/cli/service_accounts.py index b4dabc41191..cf86a5c7306 100644 --- a/src/zenml/cli/service_accounts.py +++ b/src/zenml/cli/service_accounts.py @@ -188,11 +188,11 @@ def describe_service_account(service_account_name_or_id: str) -> None: @list_options(ServiceAccountFilter) @click.pass_context def list_service_accounts(ctx: click.Context, **kwargs: Any) -> None: - """List all users. + """List service accounts. Args: - ctx: The click context object - kwargs: Keyword arguments to filter the list of users. + ctx: The click context. + **kwargs: Keyword arguments to filter the service accounts. """ client = Client() with console.status("Listing service accounts...\n"): diff --git a/src/zenml/cli/service_connectors.py b/src/zenml/cli/service_connectors.py index 69bec86ea92..f59c22b2351 100644 --- a/src/zenml/cli/service_connectors.py +++ b/src/zenml/cli/service_connectors.py @@ -985,7 +985,7 @@ def list_service_connectors( Args: ctx: The click context object labels: Labels to filter by. - kwargs: Keyword arguments to filter the components. + **kwargs: Keyword arguments to filter the components. """ client = Client() @@ -1432,8 +1432,7 @@ def update_service_connector( auth_method_spec = connector_type_spec.auth_method_dict[auth_method] # If the authentication method has changed, we need to reconfigure - # the connector from scratch; otherwise, we ask the user if they - # want to update the existing configuration + # the connector or update the existing configuration if auth_method != connector.auth_method: confirm = True else: diff --git a/src/zenml/cli/stack.py b/src/zenml/cli/stack.py index 96b47847b5b..f351dfa044a 100644 --- a/src/zenml/cli/stack.py +++ b/src/zenml/cli/stack.py @@ -32,6 +32,7 @@ from uuid import UUID import click +from click import Abort, BadParameter from rich.console import Console from rich.markdown import Markdown from rich.prompt import Confirm @@ -960,12 +961,15 @@ def rename_stack( @stack.command("list") @list_options(StackFilter) @click.pass_context -def list_stacks(ctx: click.Context, **kwargs: Any) -> None: +def list_stacks( + ctx: click.Context, + **kwargs: Any, +) -> None: """List all stacks that fulfill the filter requirements. Args: ctx: the Click context - kwargs: Keyword arguments to filter the stacks. + **kwargs: Keyword arguments to filter the stacks. """ client = Client() with console.status("Listing stacks...\n"): @@ -1604,12 +1608,12 @@ def validate_name(ctx: click.Context, param: str, value: str) -> str: return value if not re.match(r"^[a-zA-Z0-9-]*$", value): - raise click.BadParameter( + raise BadParameter( "Stack name must contain only alphanumeric characters and hyphens." ) if len(value) > 16: - raise click.BadParameter( + raise BadParameter( "Stack name must have a maximum length of 16 characters." ) @@ -1754,7 +1758,7 @@ def deploy( f"automatically redirected to " f"{deployment_config.deployment_url_text} in your browser.", ): - raise click.Abort() + raise Abort() date_start = datetime.utcnow() @@ -2130,8 +2134,9 @@ def deploy_mlstack( @stack.command( + "destroy", help="Destroy stack components created previously with " - "`zenml stack deploy`" + "`zenml stack deploy`", ) @click.argument("stack_name", required=True) @click.option( @@ -2393,8 +2398,7 @@ def _get_stack_component_info( The info model of the stack component. Raises: - ValueError: If the cloud provider is not supported. - ValueError: If the component type is not supported. + ValueError: If the cloud provider or component type is not supported. """ from rich.prompt import Prompt diff --git a/src/zenml/cli/stack_components.py b/src/zenml/cli/stack_components.py index d0dd557c3ac..973f13bf1fa 100644 --- a/src/zenml/cli/stack_components.py +++ b/src/zenml/cli/stack_components.py @@ -175,8 +175,8 @@ def list_stack_components_command( """Prints a table of stack components. Args: - ctx: The click context object - kwargs: Keyword arguments to filter the components. + ctx: The click context object. + **kwargs: Keyword arguments to filter the components. """ client = Client() with console.status(f"Listing {component_type.plural}..."): @@ -2019,7 +2019,7 @@ def connect_stack_component_with_service_connector( f"'{component_model.name}' {display_name} in your " f"workspace. {additional_info}You can create a new " "connector using the 'zenml service-connector register' " - "command or list the compatible resources using the " + f"command or list the compatible resources using the " f"'zenml service-connector list-resources{command_args}' " "command." ) diff --git a/src/zenml/cli/text_utils.py b/src/zenml/cli/text_utils.py index 534c8b4e140..33acf51089f 100644 --- a/src/zenml/cli/text_utils.py +++ b/src/zenml/cli/text_utils.py @@ -13,7 +13,7 @@ # permissions and limitations under the License. """Utilities for CLI output.""" -from typing import List +from typing import Generator, List from rich.console import Console, ConsoleOptions, RenderResult from rich.markdown import Heading, Markdown @@ -91,15 +91,15 @@ class OldSchoolMarkdownHeading(Heading): def __rich_console__( self, console: Console, options: ConsoleOptions - ) -> RenderResult: - """Render the heading. + ) -> Generator[RenderResult, None, None]: + """Render the heading to the console. Args: - console: The console rendering the content. + console: The console to render to. options: The console options. Yields: - RenderResult: The rendered content. + RenderResult: The rendered heading. """ text = self.text text.justify = "left" diff --git a/src/zenml/cli/user_management.py b/src/zenml/cli/user_management.py index a7861c6f259..b01adcf735f 100644 --- a/src/zenml/cli/user_management.py +++ b/src/zenml/cli/user_management.py @@ -84,7 +84,7 @@ def list_users(ctx: click.Context, **kwargs: Any) -> None: Args: ctx: The click context object - kwargs: Keyword arguments to filter the list of users. + **kwargs: Keyword arguments to filter the list of users. """ client = Client() with console.status("Listing stacks...\n"): diff --git a/src/zenml/cli/utils.py b/src/zenml/cli/utils.py index c0679853fe4..0b6223ab8b8 100644 --- a/src/zenml/cli/utils.py +++ b/src/zenml/cli/utils.py @@ -42,6 +42,7 @@ import click import pkg_resources import yaml +from click import ClickException from pydantic import BaseModel, SecretStr from rich import box, table from rich.console import Console @@ -163,7 +164,7 @@ def error(text: str) -> NoReturn: Raises: ClickException: when called. """ - raise click.ClickException(message=click.style(text, fg="red", bold=True)) + raise ClickException(message=click.style(text, fg="red", bold=True)) def warning( @@ -222,7 +223,7 @@ def print_table( obj: A List containing dictionaries. title: Title of the table. caption: Caption of the table. - columns: Optional column configurations to be used in the table. + **columns: Optional column configurations to be used in the table. """ column_keys = {key: None for dict_ in obj for key in dict_} column_names = [columns.get(key, key.upper()) for key in column_keys] @@ -2635,7 +2636,7 @@ def temporary_active_stack( this contextmanager will not do anything. Yields: - The active stack. + Stack: The active stack. """ from zenml.client import Client diff --git a/src/zenml/client.py b/src/zenml/client.py index cb5eaa2bdd8..36056b735fc 100644 --- a/src/zenml/client.py +++ b/src/zenml/client.py @@ -4309,7 +4309,7 @@ def _delete_artifact_from_artifact_store( artifact_version: The artifact version to delete. Raises: - Exception: If the artifact store is inaccessible. + e: If the artifact store is inaccessible. """ from zenml.artifact_stores.base_artifact_store import BaseArtifactStore from zenml.stack.stack_component import StackComponent @@ -5791,7 +5791,7 @@ def login_service_connector( equivalent to the one requested, a `ValueError` exception is raised. May be omitted for connectors and resource types that do not support multiple resource instances. - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Returns: diff --git a/src/zenml/client_lazy_loader.py b/src/zenml/client_lazy_loader.py index 24816b4923e..939d67085fa 100644 --- a/src/zenml/client_lazy_loader.py +++ b/src/zenml/client_lazy_loader.py @@ -60,8 +60,8 @@ def __call__(self, *args: Any, **kwargs: Any) -> "ClientLazyLoader": """Call mocked attribute. Args: - args: Positional arguments. - kwargs: Keyword arguments. + *args: Positional arguments. + **kwargs: Keyword arguments. Returns: self diff --git a/src/zenml/config/global_config.py b/src/zenml/config/global_config.py index a2c924947b7..b4e70257e6f 100644 --- a/src/zenml/config/global_config.py +++ b/src/zenml/config/global_config.py @@ -137,7 +137,7 @@ def __init__(self, **data: Any) -> None: instance. Args: - data: Custom configuration options. + **data: Custom configuration options. """ config_values = self._read_config() config_values.update(data) diff --git a/src/zenml/data_validators/base_data_validator.py b/src/zenml/data_validators/base_data_validator.py index 53a4ac669c4..0529ab54d3f 100644 --- a/src/zenml/data_validators/base_data_validator.py +++ b/src/zenml/data_validators/base_data_validator.py @@ -109,6 +109,9 @@ def data_profiling( profiles to be generated. **kwargs: Implementation specific keyword arguments. + Returns: + The data profile object. + Raises: NotImplementedError: if data profiling is not supported by this data validator. @@ -155,6 +158,9 @@ def data_validation( be performed. **kwargs: Implementation specific keyword arguments. + Returns: + The data validation object. + Raises: NotImplementedError: if data validation is not supported by this data validator. @@ -205,6 +211,9 @@ def model_validation( be performed. **kwargs: Implementation specific keyword arguments. + Returns: + The model validation object. + Raises: NotImplementedError: if model validation is not supported by this data validator. diff --git a/src/zenml/entrypoints/base_entrypoint_configuration.py b/src/zenml/entrypoints/base_entrypoint_configuration.py index 85101ed4614..2e4c980a760 100644 --- a/src/zenml/entrypoints/base_entrypoint_configuration.py +++ b/src/zenml/entrypoints/base_entrypoint_configuration.py @@ -150,10 +150,6 @@ def _parse_arguments(cls, arguments: List[str]) -> Dict[str, Any]: Returns: Dictionary of the parsed arguments. - - # noqa: DAR402 - Raises: - ValueError: If the arguments are not valid. """ class _CustomParser(argparse.ArgumentParser): diff --git a/src/zenml/event_sources/base_event_source.py b/src/zenml/event_sources/base_event_source.py index 30e36ce074e..5a0d6a4a354 100644 --- a/src/zenml/event_sources/base_event_source.py +++ b/src/zenml/event_sources/base_event_source.py @@ -197,7 +197,8 @@ def create_event_source( Returns: The created event source. - # noqa: DAR401 + Raises: + Exception: when it fails to create the event source. """ # Validate and instantiate the configuration from the request config = self.validate_event_source_configuration( @@ -258,7 +259,8 @@ def update_event_source( Returns: The updated event source. - # noqa: DAR401 + Raises: + Exception: when it fails to update the event source. """ # Validate and instantiate the configuration from the original event # source @@ -339,7 +341,8 @@ def delete_event_source( even if the event source handler fails to delete the event source. - # noqa: DAR401 + Raises: + Exception: when it fails to delete the event source. """ # Validate and instantiate the configuration from the original event # source diff --git a/src/zenml/event_sources/webhooks/base_webhook_event_source.py b/src/zenml/event_sources/webhooks/base_webhook_event_source.py index 5db1964df63..36dd6456721 100644 --- a/src/zenml/event_sources/webhooks/base_webhook_event_source.py +++ b/src/zenml/event_sources/webhooks/base_webhook_event_source.py @@ -116,7 +116,7 @@ def _interpret_event(self, event: Dict[str, Any]) -> BaseEvent: Args: event: The generic event body - Return: + Returns: An instance of the event source specific pydantic model. """ @@ -133,7 +133,7 @@ def _get_webhook_secret( Args: event_source: The event source to retrieve the secret for. - Return: + Returns: The webhook secret associated with the event source, or None if a secret is not applicable. """ diff --git a/src/zenml/integrations/airflow/orchestrators/airflow_orchestrator.py b/src/zenml/integrations/airflow/orchestrators/airflow_orchestrator.py index adb95c2e003..8d0543f634b 100644 --- a/src/zenml/integrations/airflow/orchestrators/airflow_orchestrator.py +++ b/src/zenml/integrations/airflow/orchestrators/airflow_orchestrator.py @@ -201,6 +201,8 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The DAG object. """ pipeline_settings = cast( AirflowOrchestratorSettings, self.get_settings(deployment) diff --git a/src/zenml/integrations/aws/service_connectors/aws_service_connector.py b/src/zenml/integrations/aws/service_connectors/aws_service_connector.py index f0579ab8e50..2c668555e17 100644 --- a/src/zenml/integrations/aws/service_connectors/aws_service_connector.py +++ b/src/zenml/integrations/aws/service_connectors/aws_service_connector.py @@ -1380,7 +1380,7 @@ def _connect_to_resource( in question. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -1449,7 +1449,7 @@ def _configure_local_client( connector's UUID in the form 'zenml-'. If a profile with the given or generated name already exists, the profile is overwritten. - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -1551,7 +1551,7 @@ def _auto_configure( role_arn: The ARN of the AWS role to assume. Applicable only if the IAM role authentication method is specified or long-term credentials are discovered. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: An AWS connector instance configured with authentication credentials diff --git a/src/zenml/integrations/azure/artifact_stores/azure_artifact_store.py b/src/zenml/integrations/azure/artifact_stores/azure_artifact_store.py index be2bad1ece1..48512dd65c5 100644 --- a/src/zenml/integrations/azure/artifact_stores/azure_artifact_store.py +++ b/src/zenml/integrations/azure/artifact_stores/azure_artifact_store.py @@ -345,9 +345,10 @@ def walk( onerror: Unused argument to conform to interface. Yields: - An Iterable of Tuples, each of which contain the path of the current - directory path, a list of directories inside the current directory - and a list of files inside the current directory. + Tuple[PathType, List[PathType], List[PathType]]: A tuple containing: + - The path of the current directory (PathType) + - A list of directories inside the current directory (List[PathType]) + - A list of files inside the current directory (List[PathType]) """ # TODO [ENG-153]: Additional params prefix, _ = self._split_path(top) diff --git a/src/zenml/integrations/azure/flavors/azureml.py b/src/zenml/integrations/azure/flavors/azureml.py index 9db7fcc223b..ae8e0d727a0 100644 --- a/src/zenml/integrations/azure/flavors/azureml.py +++ b/src/zenml/integrations/azure/flavors/azureml.py @@ -89,10 +89,6 @@ def azureml_settings_validator(self) -> "AzureMLComputeSettings": Returns: the instance itself. - - Raises: - AssertionError: if a name is not provided when working with - instances and clusters. """ viable_configuration_fields = { AzureMLComputeTypes.SERVERLESS: {"mode"}, diff --git a/src/zenml/integrations/azure/service_connectors/azure_service_connector.py b/src/zenml/integrations/azure/service_connectors/azure_service_connector.py index 515efb4671e..2ede4f19364 100644 --- a/src/zenml/integrations/azure/service_connectors/azure_service_connector.py +++ b/src/zenml/integrations/azure/service_connectors/azure_service_connector.py @@ -920,7 +920,7 @@ def _connect_to_resource( in question. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -985,7 +985,7 @@ def _configure_local_client( client or SDK installed on the localhost for the indicated resource. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -1080,7 +1080,7 @@ def _auto_configure( restrict the scope of Azure Blob storage containers. If not specified, ZenML will retrieve blob containers from all storage accounts accessible with the discovered credentials. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: An Azure connector instance configured with authentication diff --git a/src/zenml/integrations/bentoml/services/bentoml_deployment.py b/src/zenml/integrations/bentoml/services/bentoml_deployment.py index 2a826fb5077..d836732bb75 100644 --- a/src/zenml/integrations/bentoml/services/bentoml_deployment.py +++ b/src/zenml/integrations/bentoml/services/bentoml_deployment.py @@ -162,7 +162,7 @@ def __init__( Args: config: service configuration - attrs: additional attributes to set on the service + **attrs: additional attributes to set on the service """ # ensure that the endpoint is created before the service is initialized # TODO [ENG-700]: implement a service factory or builder for BentoML diff --git a/src/zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py b/src/zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py index 24b873af205..a4be16d9812 100644 --- a/src/zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +++ b/src/zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py @@ -121,9 +121,6 @@ def branch(self) -> Optional[str]: def event_type(self) -> Union[BitbucketEventType, str]: """The type of Bitbucket event. - Args: - The type of the event based on Bitbucket specific fields. - Returns: The type of the event. """ diff --git a/src/zenml/integrations/databricks/orchestrators/databricks_orchestrator.py b/src/zenml/integrations/databricks/orchestrators/databricks_orchestrator.py index 7707090f1f6..48e31395439 100644 --- a/src/zenml/integrations/databricks/orchestrators/databricks_orchestrator.py +++ b/src/zenml/integrations/databricks/orchestrators/databricks_orchestrator.py @@ -226,6 +226,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The Databricks job id. + Raises: ValueError: If the schedule is not set or if the cron expression is not set. @@ -418,8 +421,8 @@ def _upload_and_run_pipeline( settings: The settings for the Databricks orchestrator. Raises: - ValueError: If the `Job Compute` policy is not found. - ValueError: If the `schedule_timezone` is not set when passing + ValueError: If the `Job Compute` policy is not found or if the + `schedule_timezone` is not set when passing a `cron_expression`. """ databricks_client = self._get_databricks_client() diff --git a/src/zenml/integrations/databricks/services/databricks_deployment.py b/src/zenml/integrations/databricks/services/databricks_deployment.py index 71b4163d363..d464264a07c 100644 --- a/src/zenml/integrations/databricks/services/databricks_deployment.py +++ b/src/zenml/integrations/databricks/services/databricks_deployment.py @@ -113,7 +113,7 @@ def __init__(self, config: DatabricksDeploymentConfig, **attrs: Any): Args: config: service configuration - attrs: additional attributes to set on the service + **attrs: additional attributes to set on the service """ super().__init__(config=config, **attrs) @@ -362,7 +362,10 @@ def get_logs( tail: only retrieve the last NUM lines of log output. Yields: - A generator that can be accessed to get the service logs. + str: Each line of the service logs. + + Returns: + Generator[str, bool, None]: A generator that yields log lines. """ logger.info( "Databricks Endpoints provides access to the logs of your Endpoints through the UI in the `Logs` tab of your Endpoint" diff --git a/src/zenml/integrations/deepchecks/data_validators/deepchecks_data_validator.py b/src/zenml/integrations/deepchecks/data_validators/deepchecks_data_validator.py index 7fde074d4fb..027e505cd2c 100644 --- a/src/zenml/integrations/deepchecks/data_validators/deepchecks_data_validator.py +++ b/src/zenml/integrations/deepchecks/data_validators/deepchecks_data_validator.py @@ -354,7 +354,7 @@ def data_validation( check enum value as dictionary keys. run_kwargs: Additional keyword arguments to be passed to the Deepchecks Suite `run` method. - kwargs: Additional keyword arguments (unused). + **kwargs: Additional keyword arguments (unused). Returns: A Deepchecks SuiteResult with the results of the validation. @@ -429,7 +429,7 @@ def model_validation( check enum value as dictionary keys. run_kwargs: Additional keyword arguments to be passed to the Deepchecks Suite `run` method. - kwargs: Additional keyword arguments (unused). + **kwargs: Additional keyword arguments (unused). Returns: A Deepchecks SuiteResult with the results of the validation. diff --git a/src/zenml/integrations/evidently/metrics.py b/src/zenml/integrations/evidently/metrics.py index 3e5cc66fceb..4f91ef07068 100644 --- a/src/zenml/integrations/evidently/metrics.py +++ b/src/zenml/integrations/evidently/metrics.py @@ -192,7 +192,7 @@ def metric_generator( takes. skip_id_column: Whether to skip the ID column when applying the generator. - parameters: Additional optional parameters needed to instantiate the + **parameters: Additional optional parameters needed to instantiate the Evidently Metric. These will be passed to the Evidently `generate_column_metrics` function. @@ -271,7 +271,7 @@ def metric( Args: metric: The Evidently Metric or MetricPreset class, class name or class path. - parameters: Additional optional parameters needed to instantiate the + **parameters: Additional optional parameters needed to instantiate the Evidently Metric or MetricPreset. Returns: diff --git a/src/zenml/integrations/evidently/steps/evidently_test.py b/src/zenml/integrations/evidently/steps/evidently_test.py index 1449fd0c51d..c475a3a4857 100644 --- a/src/zenml/integrations/evidently/steps/evidently_test.py +++ b/src/zenml/integrations/evidently/steps/evidently_test.py @@ -55,9 +55,8 @@ def evidently_test_step( A tuple containing the TestSuite in JSON and HTML formats. Raises: - ValueError: If ignored_cols is an empty list - ValueError: If column is not found in reference or comparison - dataset + ValueError: If ignored_cols is an empty list or if any column in + ignored_cols is not found in the reference or comparison dataset. """ if not tests: tests = EvidentlyTestConfig.default_tests() diff --git a/src/zenml/integrations/evidently/tests.py b/src/zenml/integrations/evidently/tests.py index 94b881108a0..daf353bb30c 100644 --- a/src/zenml/integrations/evidently/tests.py +++ b/src/zenml/integrations/evidently/tests.py @@ -186,7 +186,7 @@ def test_generator( columns: The columns to apply the generator to. Takes the same values that the Evidently `generate_column_tests` function takes. - parameters: Additional optional parameters needed to instantiate the + **parameters: Additional optional parameters needed to instantiate the Evidently Test. These will be passed to the Evidently `generate_column_tests` function. @@ -264,7 +264,7 @@ def test( Args: test: The Evidently Test or TestPreset class, class name or class path. - parameters: Additional optional parameters needed to instantiate the + **parameters: Additional optional parameters needed to instantiate the Evidently Test or TestPreset. Returns: diff --git a/src/zenml/integrations/gcp/artifact_stores/gcp_artifact_store.py b/src/zenml/integrations/gcp/artifact_stores/gcp_artifact_store.py index 9d8a47f1ae8..a9c6fbc7bbd 100644 --- a/src/zenml/integrations/gcp/artifact_stores/gcp_artifact_store.py +++ b/src/zenml/integrations/gcp/artifact_stores/gcp_artifact_store.py @@ -315,9 +315,10 @@ def walk( onerror: Unused argument to conform to interface. Yields: - An Iterable of Tuples, each of which contain the path of the current - directory path, a list of directories inside the current directory - and a list of files inside the current directory. + Tuple[PathType, List[PathType], List[PathType]]: A tuple containing: + - The path of the current directory (PathType) + - A list of directories inside the current directory (List[PathType]) + - A list of files inside the current directory (List[PathType]) """ # TODO [ENG-153]: Additional params for ( diff --git a/src/zenml/integrations/gcp/image_builders/gcp_image_builder.py b/src/zenml/integrations/gcp/image_builders/gcp_image_builder.py index b597813974a..342bf16f9c4 100644 --- a/src/zenml/integrations/gcp/image_builders/gcp_image_builder.py +++ b/src/zenml/integrations/gcp/image_builders/gcp_image_builder.py @@ -116,8 +116,8 @@ def build( The Docker image name with digest. Raises: - RuntimeError: If no container registry is passed. - RuntimeError: If the Cloud Build build fails. + RuntimeError: If no container registry is passed, or if the Cloud + Build build fails. """ if not container_registry: raise RuntimeError( diff --git a/src/zenml/integrations/gcp/orchestrators/vertex_orchestrator.py b/src/zenml/integrations/gcp/orchestrators/vertex_orchestrator.py index 423a63d7bfb..b273363f389 100644 --- a/src/zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +++ b/src/zenml/integrations/gcp/orchestrators/vertex_orchestrator.py @@ -336,13 +336,8 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. - Raises: - ValueError: If the attribute `pipeline_root` is not set and it - can be not generated using the path of the artifact store in the - stack because it is not a - `zenml.integrations.gcp.artifact_store.GCPArtifactStore`. Also gets - raised if attempting to schedule pipeline run without using the - `zenml.integrations.gcp.artifact_store.GCPArtifactStore`. + Returns: + The pipeline run id. """ orchestrator_run_name = get_orchestrator_run_name( pipeline_name=deployment.pipeline_configuration.name diff --git a/src/zenml/integrations/gcp/service_connectors/gcp_service_connector.py b/src/zenml/integrations/gcp/service_connectors/gcp_service_connector.py index 53e432fe3ee..a7f3187f2ff 100644 --- a/src/zenml/integrations/gcp/service_connectors/gcp_service_connector.py +++ b/src/zenml/integrations/gcp/service_connectors/gcp_service_connector.py @@ -1544,7 +1544,7 @@ def _connect_to_resource( in question. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -1599,7 +1599,7 @@ def _configure_local_client( client or SDK installed on the localhost for the indicated resource. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -1750,7 +1750,7 @@ def _auto_configure( implementation may choose to either require or ignore this parameter if it does not support or detect an resource type that supports multiple instances. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: A GCP connector instance configured with authentication credentials diff --git a/src/zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py b/src/zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py index a2cd5e774ca..943ce8cca62 100644 --- a/src/zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py +++ b/src/zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py @@ -131,9 +131,6 @@ def branch(self) -> Optional[str]: def event_type(self) -> Union[GithubEventType, str]: """The type of github event. - Args: - The type of the event based on github specific fields. - Returns: The type of the event. """ diff --git a/src/zenml/integrations/great_expectations/data_validators/ge_data_validator.py b/src/zenml/integrations/great_expectations/data_validators/ge_data_validator.py index 0eb8f7a590c..8967f140064 100644 --- a/src/zenml/integrations/great_expectations/data_validators/ge_data_validator.py +++ b/src/zenml/integrations/great_expectations/data_validators/ge_data_validator.py @@ -360,7 +360,7 @@ def data_profiling( the profiler. overwrite_existing_suite: Whether to overwrite an existing expectation suite, if one exists with that name. - kwargs: Additional keyword arguments (unused). + **kwargs: Additional keyword arguments (unused). Returns: The inferred Expectation Suite. @@ -466,7 +466,7 @@ def data_validation( dataset in the Great Expectations docs. action_list: A list of additional Great Expectations actions to run after the validation check. - kwargs: Additional keyword arguments (unused). + **kwargs: Additional keyword arguments (unused). Returns: The Great Expectations validation (checkpoint) result. diff --git a/src/zenml/integrations/great_expectations/ge_store_backend.py b/src/zenml/integrations/great_expectations/ge_store_backend.py index 6a5f2d89bfb..a90c9552672 100644 --- a/src/zenml/integrations/great_expectations/ge_store_backend.py +++ b/src/zenml/integrations/great_expectations/ge_store_backend.py @@ -48,7 +48,7 @@ def __init__( Args: prefix: Subpath prefix to use for this store backend. - kwargs: Additional keyword arguments passed by the Great Expectations + **kwargs: Additional keyword arguments passed by the Great Expectations core. These are transparently passed to the `TupleStoreBackend` constructor. """ @@ -145,6 +145,9 @@ def _get(self, key: Tuple[str, ...]) -> str: # type: ignore[override] def _get_all(self) -> List[Any]: """Get all objects in the store. + Returns: + A list of all objects in the store. + Raises: NotImplementedError: if the method is not implemented for this store backend. @@ -159,7 +162,7 @@ def _set(self, key: Tuple[str, ...], value: str, **kwargs: Any) -> str: # type: Args: key: object key identifier. value: object value to set. - kwargs: additional keyword arguments (ignored). + **kwargs: additional keyword arguments (ignored). Returns: The file path where the object was stored. @@ -187,7 +190,7 @@ def _move( Args: source_key: current object key identifier. dest_key: new object key identifier. - kwargs: additional keyword arguments (ignored). + **kwargs: additional keyword arguments (ignored). """ source_path = self._build_object_path(source_key) dest_path = self._build_object_path(dest_key) diff --git a/src/zenml/integrations/huggingface/services/huggingface_deployment.py b/src/zenml/integrations/huggingface/services/huggingface_deployment.py index ed12e9954d1..96bb230739f 100644 --- a/src/zenml/integrations/huggingface/services/huggingface_deployment.py +++ b/src/zenml/integrations/huggingface/services/huggingface_deployment.py @@ -73,7 +73,7 @@ def __init__(self, config: HuggingFaceServiceConfig, **attrs: Any): Args: config: service configuration - attrs: additional attributes to set on the service + **attrs: additional attributes to set on the service """ super().__init__(config=config, **attrs) diff --git a/src/zenml/integrations/huggingface/steps/accelerate_runner.py b/src/zenml/integrations/huggingface/steps/accelerate_runner.py index c1cabc4a0f9..b8e2bbd435d 100644 --- a/src/zenml/integrations/huggingface/steps/accelerate_runner.py +++ b/src/zenml/integrations/huggingface/steps/accelerate_runner.py @@ -60,7 +60,7 @@ def training_pipeline(some_param: int, ...): Args: step_function_top_level: The step function to run with accelerate [optional]. Used in functional calls like `run_with_accelerate(some_func,foo=bar)()`. - accelerate_launch_kwargs: A dictionary of arguments to pass along to the + **accelerate_launch_kwargs: A dictionary of arguments to pass along to the `accelerate launch` command, including hardware selection, resource allocation, and training paradigm options. Visit https://huggingface.co/docs/accelerate/en/package_reference/cli#accelerate-launch diff --git a/src/zenml/integrations/hyperai/orchestrators/hyperai_orchestrator.py b/src/zenml/integrations/hyperai/orchestrators/hyperai_orchestrator.py index dceaac0f22c..2b2d6cc1add 100644 --- a/src/zenml/integrations/hyperai/orchestrators/hyperai_orchestrator.py +++ b/src/zenml/integrations/hyperai/orchestrators/hyperai_orchestrator.py @@ -183,6 +183,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The pipeline run id. + Raises: RuntimeError: If a step fails. """ diff --git a/src/zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py b/src/zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py index 8f68470cacc..1b7d318b39e 100644 --- a/src/zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py +++ b/src/zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py @@ -276,7 +276,7 @@ def _connect_to_resource( """Connect to a HyperAI instance. Returns an authenticated SSH client. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -295,7 +295,7 @@ def _configure_local_client( """There is no local client for the HyperAI connector, so it does nothing. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Raises: @@ -327,7 +327,11 @@ def _auto_configure( implementation may choose to either require or ignore this parameter if it does not support or detect an resource type that supports multiple instances. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to + use. + + Returns: + The configured connector. Raises: NotImplementedError: If the connector auto-configuration fails or diff --git a/src/zenml/integrations/kaniko/image_builders/kaniko_image_builder.py b/src/zenml/integrations/kaniko/image_builders/kaniko_image_builder.py index 1a4aaac3ad8..0d6809a339d 100644 --- a/src/zenml/integrations/kaniko/image_builders/kaniko_image_builder.py +++ b/src/zenml/integrations/kaniko/image_builders/kaniko_image_builder.py @@ -120,8 +120,8 @@ def build( The Docker image repo digest. Raises: - RuntimeError: If no container registry is passed. - RuntimeError: If the upload to the artifact store has failed. + RuntimeError: If no container registry is passed, or if the upload + to the artifact store has failed. """ self._check_prerequisites() if not container_registry: @@ -345,7 +345,7 @@ def _delete_pod(self, pod_name: str) -> None: pod_name: Name of the Pod to delete. Raises: - subprocess.CalledProcessError: If the kubectl call to delete + e: If the kubectl call to delete the Pod failed. """ command = [ @@ -363,7 +363,7 @@ def _delete_pod(self, pod_name: str) -> None: subprocess.run(command, stdout=subprocess.PIPE, check=True) except subprocess.CalledProcessError as e: logger.error(e.output) - raise + raise e logger.info("Deleted Kaniko build Pod %s.", pod_name) diff --git a/src/zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py b/src/zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py index 2f8a83dea57..43db04306c3 100644 --- a/src/zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py +++ b/src/zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py @@ -104,8 +104,8 @@ def __init__( Args: client: pre-configured Kubernetes client. - args: standard KFP client positional arguments. - kwargs: standard KFP client keyword arguments. + *args: standard KFP client positional arguments. + **kwargs: standard KFP client keyword arguments. """ self._k8s_client = client super().__init__(*args, **kwargs) @@ -116,8 +116,8 @@ def _load_config(self, *args: Any, **kwargs: Any) -> Any: Initializes the KFP configuration from the Kubernetes client. Args: - args: standard KFP client positional arguments. - kwargs: standard KFP client keyword arguments. + *args: standard KFP client positional arguments. + **kwargs: standard KFP client keyword arguments. Returns: The KFP configuration. @@ -502,6 +502,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The pipeline run id. + Raises: RuntimeError: If trying to run a pipeline in a notebook environment. diff --git a/src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py b/src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py index 0c5e43ec65e..0d4923095e5 100644 --- a/src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py +++ b/src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py @@ -342,6 +342,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The pipeline run id. + Raises: RuntimeError: If the Kubernetes orchestrator is not configured. """ diff --git a/src/zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py b/src/zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py index 5ae64a7e7ca..78244c238b7 100644 --- a/src/zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py +++ b/src/zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py @@ -254,7 +254,7 @@ def _connect_to_resource( """Authenticate and connect to a Kubernetes cluster. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -314,7 +314,7 @@ def _configure_local_client( Kubernetes client (kubectl). Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -472,7 +472,7 @@ def _auto_configure( supports multiple instances. kubernetes_context: The name of the Kubernetes context to use. If not specified, the active context will be used. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: A configured Kubernetes connector instance. diff --git a/src/zenml/integrations/label_studio/annotators/label_studio_annotator.py b/src/zenml/integrations/label_studio/annotators/label_studio_annotator.py index 77d0b38fc56..2f3a0402f1c 100644 --- a/src/zenml/integrations/label_studio/annotators/label_studio_annotator.py +++ b/src/zenml/integrations/label_studio/annotators/label_studio_annotator.py @@ -167,6 +167,7 @@ def _get_client(self) -> Client: Raises: ValueError: when unable to access the Label Studio API key. + RuntimeError: when unable to access the Label Studio API key. """ try: settings = cast( diff --git a/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator.py b/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator.py index 778ad4ecbd4..45c576ab9be 100644 --- a/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator.py +++ b/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator.py @@ -215,6 +215,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The pipeline run id. + Raises: ValueError: If the schedule is not set or if the cron expression is not set. @@ -445,7 +448,7 @@ def _upload_and_run_pipeline( env_file_path: The path to the environment file. Raises: - Exception: If an error occurs while running the pipeline. + e: If an error occurs while running the pipeline. """ logger.info("Setting up Lightning AI client") self._set_lightning_env_vars(deployment) diff --git a/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator_entrypoint.py b/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator_entrypoint.py index e6624f04d77..8f89a5a8c55 100644 --- a/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator_entrypoint.py +++ b/src/zenml/integrations/lightning/orchestrators/lightning_orchestrator_entrypoint.py @@ -193,7 +193,7 @@ def run_step_on_lightning_studio(step_name: str) -> None: step_name: Name of the step. Raises: - Exception: If an error occurs while running the step on the STUDIO. + e: If an error occurs while running the step on the STUDIO. """ step_args = StepEntrypointConfiguration.get_entrypoint_arguments( step_name=step_name, diff --git a/src/zenml/integrations/mlflow/mlflow_utils.py b/src/zenml/integrations/mlflow/mlflow_utils.py index 8eff4044abc..eb66f2f1f68 100644 --- a/src/zenml/integrations/mlflow/mlflow_utils.py +++ b/src/zenml/integrations/mlflow/mlflow_utils.py @@ -45,10 +45,11 @@ def get_missing_mlflow_experiment_tracker_error() -> ValueError: def get_tracking_uri() -> str: """Gets the MLflow tracking URI from the active experiment tracking stack component. - # noqa: DAR401 - Returns: MLflow tracking URI. + + Raises: + get_missing_mlflow_experiment_tracker_error: If no MLflow experiment tracker is registered in the active stack. """ from zenml.integrations.mlflow.experiment_trackers.mlflow_experiment_tracker import ( MLFlowExperimentTracker, diff --git a/src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py b/src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py index f73058943e0..3c23ba71a1a 100644 --- a/src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py +++ b/src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py @@ -146,6 +146,7 @@ def register_model( Raises: RuntimeError: If the model already exists. + KeyError: If the model does not exist. Returns: The registered model. @@ -575,7 +576,7 @@ def list_model_versions( created_before: The maximum creation time of the model versions. order_by_date: The order of the model versions by creation time, either ascending or descending. - kwargs: Additional keyword arguments. + **kwargs: Additional keyword arguments. Returns: The model versions. @@ -666,7 +667,7 @@ def load_model_version( Args: name: The name of the model. version: The version of the model. - kwargs: Additional keyword arguments. + **kwargs: Additional keyword arguments. Returns: The model version. diff --git a/src/zenml/integrations/mlflow/services/mlflow_deployment.py b/src/zenml/integrations/mlflow/services/mlflow_deployment.py index d010ec1af77..a8a8e276d44 100644 --- a/src/zenml/integrations/mlflow/services/mlflow_deployment.py +++ b/src/zenml/integrations/mlflow/services/mlflow_deployment.py @@ -167,7 +167,7 @@ def __init__( Args: config: service configuration - attrs: additional attributes to set on the service + **attrs: additional attributes to set on the service """ # ensure that the endpoint is created before the service is initialized # TODO [ENG-700]: implement a service factory or builder for MLflow diff --git a/src/zenml/integrations/mlflow/steps/mlflow_deployer.py b/src/zenml/integrations/mlflow/steps/mlflow_deployer.py index f3075e9b47c..67f9f085831 100644 --- a/src/zenml/integrations/mlflow/steps/mlflow_deployer.py +++ b/src/zenml/integrations/mlflow/steps/mlflow_deployer.py @@ -219,9 +219,8 @@ def mlflow_model_registry_deployer_step( Raises: ValueError: if neither registry_model_version nor registry_model_stage - is not provided - ValueError: if No MLflow experiment tracker is found in the current - active stack + is not provided or if No MLflow experiment tracker is found in the + current active stack LookupError: if no model version is found in the MLflow model registry. """ if not registry_model_version and not registry_model_stage: diff --git a/src/zenml/integrations/mlflow/steps/mlflow_registry.py b/src/zenml/integrations/mlflow/steps/mlflow_registry.py index 479ef90f1d5..c86cd769e19 100644 --- a/src/zenml/integrations/mlflow/steps/mlflow_registry.py +++ b/src/zenml/integrations/mlflow/steps/mlflow_registry.py @@ -62,12 +62,12 @@ def mlflow_register_model_step( run_name: Name of the run to be created. run_id: ID of the run to be used. description: A description of the model version. - metadata: A list of metadata to associate with the model version + metadata: A dictionary of metadata to associate with the model version. Raises: - ValueError: If the model registry is not an MLflow model registry. - ValueError: If the experiment tracker is not an MLflow experiment tracker. - RuntimeError: If no model source URI is provided and no model is found. + ValueError: If the model registry is not an MLflow model registry, + if the experiment tracker is not an MLflow experiment tracker, + or if no model source URI is provided and no model is found. RuntimeError: If no run ID is provided and no run is found. """ # get the experiment tracker and check if it is an MLflow experiment tracker. diff --git a/src/zenml/integrations/pigeon/annotators/pigeon_annotator.py b/src/zenml/integrations/pigeon/annotators/pigeon_annotator.py index f24343300d4..a79578131fb 100644 --- a/src/zenml/integrations/pigeon/annotators/pigeon_annotator.py +++ b/src/zenml/integrations/pigeon/annotators/pigeon_annotator.py @@ -54,6 +54,9 @@ def config(self) -> PigeonAnnotatorConfig: def get_url(self) -> str: """Get the URL of the Pigeon annotator. + Returns: + The URL of the Pigeon annotator. + Raises: NotImplementedError: Pigeon annotator does not have a URL. """ @@ -65,6 +68,9 @@ def get_url_for_dataset(self, dataset_name: str) -> str: Args: dataset_name: Name of the dataset (annotation file). + Returns: + The URL of the Pigeon annotator for the given dataset. + Raises: NotImplementedError: Pigeon annotator does not have a URL. """ @@ -243,6 +249,9 @@ def add_dataset(self, **kwargs: Any) -> Any: Args: **kwargs: keyword arguments. + Returns: + This method does not return anything as it raises an exception. + Raises: NotImplementedError: Pigeon annotator does not support adding datasets. """ @@ -322,6 +331,9 @@ def get_unlabeled_data(self, **kwargs: Any) -> Any: Args: **kwargs: keyword arguments. + Returns: + The unlabeled examples from the dataset. + Raises: NotImplementedError: Pigeon annotator does not support retrieving unlabeled data. """ diff --git a/src/zenml/integrations/prodigy/annotators/prodigy_annotator.py b/src/zenml/integrations/prodigy/annotators/prodigy_annotator.py index 035d5775c58..2410b2541ea 100644 --- a/src/zenml/integrations/prodigy/annotators/prodigy_annotator.py +++ b/src/zenml/integrations/prodigy/annotators/prodigy_annotator.py @@ -265,7 +265,11 @@ def get_unlabeled_data(self, **kwargs: str) -> Any: """Gets the unlabeled data for the given dataset. Args: - **kwargs: Additional keyword arguments to pass to the Prodigy client. + **kwargs: Additional keyword arguments to pass to the Prodigy + client. + + Returns: + Any: This method does not return anything as it raises an exception. Raises: NotImplementedError: Prodigy doesn't allow fetching unlabeled data. diff --git a/src/zenml/integrations/s3/artifact_stores/s3_artifact_store.py b/src/zenml/integrations/s3/artifact_stores/s3_artifact_store.py index 205076d7886..e384f505b21 100644 --- a/src/zenml/integrations/s3/artifact_stores/s3_artifact_store.py +++ b/src/zenml/integrations/s3/artifact_stores/s3_artifact_store.py @@ -415,9 +415,10 @@ def walk( onerror: Unused argument to conform to interface. Yields: - An Iterable of Tuples, each of which contain the path of the current - directory path, a list of directories inside the current directory - and a list of files inside the current directory. + Tuple[PathType, List[PathType], List[PathType]]: A tuple containing: + - The path of the current directory (PathType) + - A list of directories inside the current directory (List[PathType]) + - A list of files inside the current directory (List[PathType]) """ # TODO [ENG-153]: Additional params for directory, subdirectories, files in self.filesystem.walk(path=top): diff --git a/src/zenml/integrations/seldon/model_deployers/seldon_model_deployer.py b/src/zenml/integrations/seldon/model_deployers/seldon_model_deployer.py index d71ad614923..15416a0a0f6 100644 --- a/src/zenml/integrations/seldon/model_deployers/seldon_model_deployer.py +++ b/src/zenml/integrations/seldon/model_deployers/seldon_model_deployer.py @@ -528,14 +528,6 @@ def perform_deploy_model( Returns: The ZenML Seldon Core deployment service object that can be used to interact with the remote Seldon Core server. - - Raises: - SeldonClientError: if a Seldon Core client error is encountered - while provisioning the Seldon Core deployment server. - RuntimeError: if `timeout` is set to a positive value that is - exceeded while waiting for the Seldon Core deployment server - to start, or if an operational failure is encountered before - it reaches a ready state. """ with track_handler(AnalyticsEvent.MODEL_DEPLOYED) as analytics_handler: config = cast(SeldonDeploymentConfig, config) @@ -582,6 +574,10 @@ def perform_stop_model( timeout: timeout in seconds to wait for the service to stop. force: if True, force the service to stop. + Returns: + The SeldonDeploymentService object that can be used to interact + with the remote Seldon Core server. + Raises: NotImplementedError: stopping Seldon Core model servers is not supported. @@ -605,6 +601,10 @@ def perform_start_model( provisioning the service, without waiting for it to become active. + Returns: + The SeldonDeploymentService object that can be used to interact + with the remote Seldon Core server. + Raises: NotImplementedError: since we don't support starting Seldon Core model servers diff --git a/src/zenml/integrations/seldon/seldon_client.py b/src/zenml/integrations/seldon/seldon_client.py index 8e040096104..abd36d9c35d 100644 --- a/src/zenml/integrations/seldon/seldon_client.py +++ b/src/zenml/integrations/seldon/seldon_client.py @@ -944,9 +944,6 @@ def get_deployment_logs( Returns: A generator that can be accessed to get the service logs. - Yields: - The next log line. - Raises: SeldonClientError: if an unknown error occurs while fetching the logs. @@ -1032,7 +1029,6 @@ def create_or_update_secret( Raises: SeldonClientError: if an unknown error occurs during the creation of the secret. - k8s_client.rest.ApiException: unexpected error. """ try: logger.debug(f"Creating Secret resource: {name}") diff --git a/src/zenml/integrations/seldon/steps/seldon_deployer.py b/src/zenml/integrations/seldon/steps/seldon_deployer.py index 9a77da9a6f5..39a1976dede 100644 --- a/src/zenml/integrations/seldon/steps/seldon_deployer.py +++ b/src/zenml/integrations/seldon/steps/seldon_deployer.py @@ -205,9 +205,9 @@ def seldon_custom_model_deployer_step( timeout: the timeout in seconds to wait for the deployment to start Raises: - ValueError: if the custom deployer is not defined - ValueError: if predict function path is not valid - TypeError: if predict function path is not a callable function + ValueError: if the custom deployer is not defined or if the predict + function path is not valid + TypeError: if the predict function path is not a callable function DoesNotExistException: if an entity does not exist raise an exception RuntimeError: if the build is missing for the pipeline run @@ -363,11 +363,9 @@ def seldon_mlflow_registry_deployer_step( Seldon Core deployment service Raises: - ValueError: if registry_model_name is not provided - ValueError: if neither registry_model_version nor - registry_model_stage is provided - ValueError: if the MLflow experiment tracker is not available in the - active stack + ValueError: if registry_model_name is not provided or if neither + registry_model_version nor registry_model_stage is provided or if + the MLflow experiment tracker is not available in the active stack LookupError: if no model version is found in the MLflow model registry. """ # import here to avoid failing the pipeline if the step is not used diff --git a/src/zenml/integrations/skypilot/orchestrators/skypilot_base_vm_orchestrator.py b/src/zenml/integrations/skypilot/orchestrators/skypilot_base_vm_orchestrator.py index e6765c4c85a..14679ef1509 100644 --- a/src/zenml/integrations/skypilot/orchestrators/skypilot_base_vm_orchestrator.py +++ b/src/zenml/integrations/skypilot/orchestrators/skypilot_base_vm_orchestrator.py @@ -158,6 +158,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The Skypilot run id. + Raises: Exception: If the pipeline run fails. RuntimeError: If the code is running in a notebook. diff --git a/src/zenml/integrations/slack/alerters/slack_alerter.py b/src/zenml/integrations/slack/alerters/slack_alerter.py index 2edd713a472..1657a751e9b 100644 --- a/src/zenml/integrations/slack/alerters/slack_alerter.py +++ b/src/zenml/integrations/slack/alerters/slack_alerter.py @@ -281,7 +281,7 @@ def post_initial_message(**payload: Any) -> None: """Post an initial message in a channel and start listening. Args: - payload: payload of the received Slack event. + **payload: payload of the received Slack event. """ web_client = payload["web_client"] blocks = self._create_blocks(message, params) @@ -294,7 +294,7 @@ def handle(**payload: Any) -> None: """Listen / handle messages posted in the channel. Args: - payload: payload of the received Slack event. + **payload: payload of the received Slack event. """ event = payload["data"] if event["channel"] == slack_channel_id: diff --git a/src/zenml/integrations/tekton/orchestrators/tekton_orchestrator.py b/src/zenml/integrations/tekton/orchestrators/tekton_orchestrator.py index c81f546120d..9aef6220ba4 100644 --- a/src/zenml/integrations/tekton/orchestrators/tekton_orchestrator.py +++ b/src/zenml/integrations/tekton/orchestrators/tekton_orchestrator.py @@ -77,8 +77,8 @@ def __init__( Args: client: pre-configured Kubernetes client. - args: standard KFP client positional arguments. - kwargs: standard KFP client keyword arguments. + *args: standard KFP client positional arguments. + **kwargs: standard KFP client keyword arguments. """ self._k8s_client = client super().__init__(*args, **kwargs) @@ -89,8 +89,8 @@ def _load_config(self, *args: Any, **kwargs: Any) -> Any: Initializes the KFP configuration from the Kubernetes client. Args: - args: standard KFP client positional arguments. - kwargs: standard KFP client keyword arguments. + *args: standard KFP client positional arguments. + **kwargs: standard KFP client keyword arguments. Returns: The KFP configuration. @@ -472,6 +472,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The Tekton run id. + Raises: RuntimeError: If you try to run the pipelines in a notebook environment. diff --git a/src/zenml/io/local_filesystem.py b/src/zenml/io/local_filesystem.py index 4d1e7394c98..f4af71de76a 100644 --- a/src/zenml/io/local_filesystem.py +++ b/src/zenml/io/local_filesystem.py @@ -225,7 +225,7 @@ def walk( topdown: bool = True, onerror: Optional[Callable[..., None]] = None, ) -> Iterable[Tuple[PathType, List[PathType], List[PathType]]]: - """Return an iterator that walks the contents of the given directory. + """Yield the contents of the given directory. Args: top: Path of directory to walk. @@ -233,10 +233,10 @@ def walk( onerror: Callable that gets called if an error occurs. Yields: - An Iterable of Tuples, each of which contain the path of the - current directory path, a list of directories inside the - current directory and a list of files inside the current - directory. + Tuple[PathType, List[PathType], List[PathType]]: A tuple containing: + - The path of the current directory (PathType) + - A list of directories inside the current directory (List[PathType]) + - A list of files inside the current directory (List[PathType]) """ yield from os.walk( # type: ignore[type-var, misc] top, topdown=topdown, onerror=onerror diff --git a/src/zenml/materializers/built_in_materializer.py b/src/zenml/materializers/built_in_materializer.py index 92429e78353..aa1552f3e1f 100644 --- a/src/zenml/materializers/built_in_materializer.py +++ b/src/zenml/materializers/built_in_materializer.py @@ -159,7 +159,7 @@ def _all_serializable(iterable: Iterable[Any]) -> bool: """For an iterable, check whether all of its elements are JSON-serializable. Args: - iterable (Iterable): The iterable to check. + iterable: The iterable to check. Returns: True if all elements are JSON-serializable, else False. @@ -363,7 +363,7 @@ def save(self, data: Any) -> None: data: The built-in container object to materialize. Raises: - Exception: If any exception occurs, it is raised after cleanup. + e: If any exception occurs, it is raised after cleanup. """ # tuple and set: handle as list. if isinstance(data, tuple) or isinstance(data, set): diff --git a/src/zenml/model/model.py b/src/zenml/model/model.py index b8c66974d12..69658a85215 100644 --- a/src/zenml/model/model.py +++ b/src/zenml/model/model.py @@ -675,7 +675,7 @@ def _get_or_create_model_version( The model version based on configuration. Raises: - RuntimeError: if the model version needs to be created, but + KeyError: if the model version needs to be created, but provided name is reserved. RuntimeError: if the model version cannot be created. """ diff --git a/src/zenml/model_deployers/base_model_deployer.py b/src/zenml/model_deployers/base_model_deployer.py index 40a65128f26..02284fca180 100644 --- a/src/zenml/model_deployers/base_model_deployer.py +++ b/src/zenml/model_deployers/base_model_deployer.py @@ -382,6 +382,9 @@ def perform_stop_model( set to 0, the method will return immediately after deprovisioning the service, without waiting for it to stop. force: if True, force the service to stop. + + Returns: + The stopped service. """ def stop_model_server( @@ -437,6 +440,9 @@ def perform_start_model( set to 0, the method will return immediately after provisioning the service, without waiting for it to become active. + + Returns: + The started service. """ def start_model_server( diff --git a/src/zenml/model_registries/base_model_registry.py b/src/zenml/model_registries/base_model_registry.py index 578d97d396c..21200b54ce4 100644 --- a/src/zenml/model_registries/base_model_registry.py +++ b/src/zenml/model_registries/base_model_registry.py @@ -244,6 +244,9 @@ def update_model( Raises: KeyError: If the model does not exist. RuntimeError: If update fails. + + Returns: + The updated registered model. """ @abstractmethod @@ -379,7 +382,7 @@ def list_model_versions( created_before: The timestamp before which to list model versions. order_by_date: Whether to sort by creation time, this can be "asc" or "desc". - kwargs: Additional keyword arguments. + **kwargs: Additional keyword arguments. Returns: A list of model versions. diff --git a/src/zenml/models/v2/base/base.py b/src/zenml/models/v2/base/base.py index e9529a22c86..74990bf2675 100644 --- a/src/zenml/models/v2/base/base.py +++ b/src/zenml/models/v2/base/base.py @@ -220,6 +220,9 @@ def get_hydrated_version( ) -> "BaseResponse[AnyBody, AnyMetadata, AnyResources]": """Abstract method to fetch the hydrated version of the model. + Returns: + The hydrated version of the model. + Raises: NotImplementedError: in case the method is not implemented. """ @@ -405,6 +408,9 @@ def get_hydrated_version( ) -> "BaseIdentifiedResponse[AnyDatedBody, AnyMetadata, AnyResources]": """Abstract method to fetch the hydrated version of the model. + Returns: + The hydrated version of the model. + Raises: NotImplementedError: in case the method is not implemented. """ diff --git a/src/zenml/models/v2/base/filter.py b/src/zenml/models/v2/base/filter.py index 10788c0d7ce..52a4658cb8d 100644 --- a/src/zenml/models/v2/base/filter.py +++ b/src/zenml/models/v2/base/filter.py @@ -416,7 +416,7 @@ def configure_rbac( Args: authenticated_user_id: ID of the authenticated user. All entities owned by this user will be included. - column_allowed_ids: Set of IDs per column to limit the query to. + **column_allowed_ids: Set of IDs per column to limit the query to. If given, the remaining filters will be applied to entities within this set only. If `None`, the remaining filters will be applied to all entries in the table. diff --git a/src/zenml/models/v2/core/artifact_version.py b/src/zenml/models/v2/core/artifact_version.py index 5d3133537dc..04be0f83030 100644 --- a/src/zenml/models/v2/core/artifact_version.py +++ b/src/zenml/models/v2/core/artifact_version.py @@ -107,10 +107,6 @@ def str_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < STR_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " @@ -168,10 +164,6 @@ def str_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < STR_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " diff --git a/src/zenml/models/v2/core/logs.py b/src/zenml/models/v2/core/logs.py index 81afc5da272..2b4b49c8eca 100644 --- a/src/zenml/models/v2/core/logs.py +++ b/src/zenml/models/v2/core/logs.py @@ -50,10 +50,6 @@ def text_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < TEXT_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " @@ -71,10 +67,6 @@ def str_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < STR_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " @@ -129,10 +121,6 @@ def str_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < STR_FIELD_MAX_LENGTH return value diff --git a/src/zenml/models/v2/core/run_metadata.py b/src/zenml/models/v2/core/run_metadata.py index cdfe826277c..b2c4015d2d3 100644 --- a/src/zenml/models/v2/core/run_metadata.py +++ b/src/zenml/models/v2/core/run_metadata.py @@ -80,10 +80,6 @@ def str_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < STR_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " @@ -101,10 +97,6 @@ def text_field_max_length_check(cls, value: Any) -> Any: Returns: the value itself. - - Raises: - AssertionError: if the length of the field is longer than the - maximum threshold. """ assert len(str(value)) < TEXT_FIELD_MAX_LENGTH, ( "The length of the value for this field can not " diff --git a/src/zenml/new/pipelines/pipeline.py b/src/zenml/new/pipelines/pipeline.py index 38f9b991299..b3e68ab971a 100644 --- a/src/zenml/new/pipelines/pipeline.py +++ b/src/zenml/new/pipelines/pipeline.py @@ -1135,9 +1135,9 @@ def add_step_invocation( ID. Raises: - RuntimeError: If the method is called on an inactive pipeline. - RuntimeError: If the invocation was called with an artifact from - a different pipeline. + RuntimeError: If the method is called on an inactive pipeline or if + the invocation was called with an artifact from a different + pipeline. Returns: The step invocation ID. @@ -1189,8 +1189,7 @@ def _compute_invocation_id( Raises: RuntimeError: If no ID suffix is allowed and an invocation for the - same ID already exists. - RuntimeError: If no unique invocation ID can be found. + same ID already exists or if no unique invocation ID can be found. Returns: The invocation ID. diff --git a/src/zenml/new/pipelines/pipeline_context.py b/src/zenml/new/pipelines/pipeline_context.py index ae1f8f7cc12..5610cb0cfdc 100644 --- a/src/zenml/new/pipelines/pipeline_context.py +++ b/src/zenml/new/pipelines/pipeline_context.py @@ -31,8 +31,7 @@ def get_pipeline_context() -> "PipelineContext": The context of the current pipeline. Raises: - RuntimeError: If no active pipeline is found. - RuntimeError: If inside a running step. + RuntimeError: If no active pipeline is found or if inside a running step. """ from zenml.new.pipelines.pipeline import Pipeline diff --git a/src/zenml/new/pipelines/run_utils.py b/src/zenml/new/pipelines/run_utils.py index e9efbf4d902..6963a6096e2 100644 --- a/src/zenml/new/pipelines/run_utils.py +++ b/src/zenml/new/pipelines/run_utils.py @@ -128,7 +128,7 @@ def deploy_pipeline( will be deleted in case the pipeline deployment failed. Raises: - Exception: Any exception that happened while deploying or running + e: Any exception that happened while deploying or running (in case it happens synchronously) the pipeline. """ stack.prepare_pipeline_deployment(deployment=deployment) diff --git a/src/zenml/orchestrators/local/local_orchestrator.py b/src/zenml/orchestrators/local/local_orchestrator.py index e769c83f0ae..53bb5b1257b 100644 --- a/src/zenml/orchestrators/local/local_orchestrator.py +++ b/src/zenml/orchestrators/local/local_orchestrator.py @@ -54,6 +54,9 @@ def prepare_or_run_pipeline( stack: The stack on which the pipeline is deployed. environment: Environment variables to set in the orchestration environment. + + Returns: + The pipeline run object. """ if deployment.schedule: logger.warning( diff --git a/src/zenml/orchestrators/local_docker/local_docker_orchestrator.py b/src/zenml/orchestrators/local_docker/local_docker_orchestrator.py index 49f2a7aafe3..432c83d2816 100644 --- a/src/zenml/orchestrators/local_docker/local_docker_orchestrator.py +++ b/src/zenml/orchestrators/local_docker/local_docker_orchestrator.py @@ -105,6 +105,9 @@ def prepare_or_run_pipeline( environment: Environment variables to set in the orchestration environment. + Returns: + The pipeline run object. + Raises: RuntimeError: If a step fails. """ diff --git a/src/zenml/orchestrators/step_launcher.py b/src/zenml/orchestrators/step_launcher.py index eaefa3558fd..304170a8954 100644 --- a/src/zenml/orchestrators/step_launcher.py +++ b/src/zenml/orchestrators/step_launcher.py @@ -470,6 +470,9 @@ def _run_step( step_run: The model of the current step run. force_write_logs: The context for the step logs. last_retry: Whether this is the last retry of the step. + + Raises: + Exception: If the step run information could not be prepared. """ # Prepare step run information. step_run_info = StepRunInfo( @@ -504,11 +507,11 @@ def _run_step( output_artifact_uris=output_artifact_uris, last_retry=last_retry, ) - except: # noqa: E722 + except Exception as e: output_utils.remove_artifact_dirs( artifact_uris=list(output_artifact_uris.values()) ) - raise + raise Exception("Failed to run step") from e duration = time.time() - start_time logger.info( diff --git a/src/zenml/orchestrators/wheeled_orchestrator.py b/src/zenml/orchestrators/wheeled_orchestrator.py index 76d60e00b8c..d88ea0fac4e 100644 --- a/src/zenml/orchestrators/wheeled_orchestrator.py +++ b/src/zenml/orchestrators/wheeled_orchestrator.py @@ -82,7 +82,7 @@ def create_wheel(self, temp_dir: str) -> str: """Create a wheel for the package in the given temporary directory. Args: - temp_dir (str): Path to the temporary directory containing the package. + temp_dir: Path to the temporary directory containing the package. Raises: RuntimeError: If the wheel file could not be created. diff --git a/src/zenml/pipelines/base_pipeline.py b/src/zenml/pipelines/base_pipeline.py index 861427b3f88..76fff932477 100644 --- a/src/zenml/pipelines/base_pipeline.py +++ b/src/zenml/pipelines/base_pipeline.py @@ -98,6 +98,9 @@ def connect(self, *args: BaseStep, **kwargs: BaseStep) -> None: Args: *args: Connect method arguments. **kwargs: Connect method keyword arguments. + + Raises: + NotImplementedError: If the connect method is not implemented. """ raise NotImplementedError diff --git a/src/zenml/plugins/base_plugin_flavor.py b/src/zenml/plugins/base_plugin_flavor.py index bbbbb5c8419..16b2bc7ec3b 100644 --- a/src/zenml/plugins/base_plugin_flavor.py +++ b/src/zenml/plugins/base_plugin_flavor.py @@ -85,4 +85,7 @@ def get_flavor_response_model( Args: hydrate: Whether the model should be hydrated. + + Returns: + The flavor response model. """ diff --git a/src/zenml/service_connectors/docker_service_connector.py b/src/zenml/service_connectors/docker_service_connector.py index b156843bfcb..c7764bd01b5 100644 --- a/src/zenml/service_connectors/docker_service_connector.py +++ b/src/zenml/service_connectors/docker_service_connector.py @@ -253,7 +253,7 @@ def _connect_to_resource( Initialize, authenticate and return a python-docker client. Args: - kwargs: Additional implementation specific keyword arguments to pass + **kwargs: Additional implementation specific keyword arguments to pass to the session or client constructor. Returns: @@ -274,7 +274,7 @@ def _configure_local_client( """Configure the local Docker client to authenticate to a Docker/OCI registry. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -329,7 +329,11 @@ def _auto_configure( implementation may choose to either require or ignore this parameter if it does not support or detect an resource type that supports multiple instances. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to + use. + + Returns: + The auto-configured Docker service connector. Raises: NotImplementedError: If the connector auto-configuration fails or diff --git a/src/zenml/service_connectors/service_connector.py b/src/zenml/service_connectors/service_connector.py index b2de590a460..4ea73574288 100644 --- a/src/zenml/service_connectors/service_connector.py +++ b/src/zenml/service_connectors/service_connector.py @@ -190,7 +190,7 @@ def __init__(self, **kwargs: Any) -> None: """Initialize a new service connector instance. Args: - kwargs: Additional keyword arguments to pass to the base class + **kwargs: Additional keyword arguments to pass to the base class constructor. """ super().__init__(**kwargs) @@ -259,6 +259,9 @@ def _get_default_resource_id(self, resource_type: str) -> str: for. Only called with resource types that do not support multiple instances. + Returns: + The default resource ID for the resource type. + Raises: RuntimeError: If the resource type does not support multiple instances and the connector implementation did not provide a @@ -290,7 +293,7 @@ def _connect_to_resource( be used. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Returns: @@ -317,7 +320,7 @@ def _configure_local_client( be used. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: @@ -354,7 +357,7 @@ def _auto_configure( implementation may choose to either require or ignore this parameter if it does not support or detect a resource type that supports multiple instances. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: A connector instance configured with authentication credentials @@ -885,7 +888,7 @@ def validate_runtime_args( canonical form. require_resource_type: Whether the resource type is required. require_resource_id: Whether the resource ID is required. - kwargs: Additional runtime arguments. + **kwargs: Additional runtime arguments. Returns: The validated resource type and resource ID. @@ -987,7 +990,7 @@ def connect( Args: verify: Whether to verify that the connector can access the configured resource before connecting to it. - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Returns: @@ -1048,7 +1051,7 @@ def auto_configure( connector implementation may choose to either require or ignore this parameter if it does not support or detect a resource type that supports multiple instances. - kwargs: Additional implementation specific keyword arguments to use. + **kwargs: Additional implementation specific keyword arguments to use. Returns: A connector instance configured with authentication credentials @@ -1115,7 +1118,7 @@ def configure_local_client( main service connector. Args: - kwargs: Additional implementation specific keyword arguments to use + **kwargs: Additional implementation specific keyword arguments to use to configure the client. Raises: diff --git a/src/zenml/services/container/container_service.py b/src/zenml/services/container/container_service.py index fc5b9afbe43..cf5f14dcb1f 100644 --- a/src/zenml/services/container/container_service.py +++ b/src/zenml/services/container/container_service.py @@ -495,9 +495,6 @@ def get_logs( Args: follow: if True, the logs will be streamed as they are written tail: only retrieve the last NUM lines of log output. - - Yields: - A generator that can be accessed to get the service logs. """ if not self.status.log_file or not os.path.exists( self.status.log_file diff --git a/src/zenml/services/local/local_service.py b/src/zenml/services/local/local_service.py index 78ca3141be1..6da3123c237 100644 --- a/src/zenml/services/local/local_service.py +++ b/src/zenml/services/local/local_service.py @@ -454,9 +454,6 @@ def get_logs( Args: follow: if True, the logs will be streamed as they are written tail: only retrieve the last NUM lines of log output. - - Yields: - A generator that can be accessed to get the service logs. """ if not self.status.log_file or not os.path.exists( self.status.log_file diff --git a/src/zenml/stack/stack.py b/src/zenml/stack/stack.py index 4625fec0899..3695550fc86 100644 --- a/src/zenml/stack/stack.py +++ b/src/zenml/stack/stack.py @@ -189,8 +189,6 @@ def from_components( ) -> "Stack": """Creates a stack instance from a dict of stack components. - # noqa: DAR402 - Args: id: Unique ID of the stack. name: The name of the stack. @@ -198,10 +196,6 @@ def from_components( Returns: A stack instance consisting of the given components. - - Raises: - TypeError: If a required component is missing or a component - doesn't inherit from the expected base class. """ from zenml.alerter import BaseAlerter from zenml.annotators import BaseAnnotator @@ -607,10 +601,6 @@ def _validate_secrets(self, raise_exception: bool) -> None: Args: raise_exception: If `True`, raises an exception if a secret is missing. Otherwise a warning is logged. - - # noqa: DAR402 - Raises: - StackValidationError: If a secret is missing. """ env_value = os.getenv( ENV_ZENML_SECRET_VALIDATION_LEVEL, diff --git a/src/zenml/steps/entrypoint_function_utils.py b/src/zenml/steps/entrypoint_function_utils.py index 2ed6c53f5fc..58d807933a2 100644 --- a/src/zenml/steps/entrypoint_function_utils.py +++ b/src/zenml/steps/entrypoint_function_utils.py @@ -163,9 +163,9 @@ def validate_input(self, key: str, value: Any) -> None: Raises: KeyError: If the function has no input for the given key. RuntimeError: If a parameter is passed for an input that is - annotated as an `UnmaterializedArtifact`. - RuntimeError: If the input value is not valid for the type - annotation provided for the function parameter. + annotated as an `UnmaterializedArtifact` or if the input value + is not valid for the type annotation provided for the function + parameter. StepInterfaceError: If the input is a parameter and not JSON serializable. """ @@ -259,11 +259,9 @@ def validate_entrypoint_function( Raises: StepInterfaceError: If the entrypoint function has variable arguments - or keyword arguments. - StepInterfaceError: If the entrypoint function has multiple - `BaseParameter` arguments. - StepInterfaceError: If the entrypoint function has multiple - `StepContext` arguments. + or keyword arguments or if the entrypoint function has multiple + `BaseParameter` arguments, or if the entrypoint function has + multiple `StepContext` arguments. RuntimeError: If type annotations should be enforced and a type annotation is missing. diff --git a/src/zenml/steps/utils.py b/src/zenml/steps/utils.py index b763db74b68..706aa3e6b97 100644 --- a/src/zenml/steps/utils.py +++ b/src/zenml/steps/utils.py @@ -102,9 +102,8 @@ def parse_return_type_annotations( Raises: RuntimeError: If the output annotation has variable length or contains - duplicate output names. - RuntimeError: If type annotations should be enforced and a type - annotation is missing. + duplicate output names or if type annotations should be enforced + and annotation is missing. Returns: - A dictionary mapping output names to their output signatures. @@ -504,6 +503,7 @@ def run_as_single_step_pipeline( that was used to store them. Args: + __step: The step to run. *args: Entrypoint function arguments. **kwargs: Entrypoint function keyword arguments. diff --git a/src/zenml/utils/daemon.py b/src/zenml/utils/daemon.py index d7eff1452e4..daa26c02542 100644 --- a/src/zenml/utils/daemon.py +++ b/src/zenml/utils/daemon.py @@ -160,8 +160,8 @@ def run_as_daemon( redirected to. working_directory: Working directory for the daemon process, defaults to the root directory. - args: Positional arguments to pass to the daemon function. - kwargs: Keyword arguments to pass to the daemon function. + *args: Positional arguments to pass to the daemon function. + **kwargs: Keyword arguments to pass to the daemon function. Raises: FileExistsError: If the PID file already exists. diff --git a/src/zenml/utils/deprecation_utils.py b/src/zenml/utils/deprecation_utils.py index cc42aaa4c4c..eb87e969731 100644 --- a/src/zenml/utils/deprecation_utils.py +++ b/src/zenml/utils/deprecation_utils.py @@ -73,8 +73,6 @@ def _deprecation_validator( data: All values passed at model initialization. Raises: - AssertionError: If either the deprecated or replacement attribute - don't exist. TypeError: If the deprecated attribute is a required attribute. ValueError: If the deprecated attribute and replacement attribute contain different values. diff --git a/src/zenml/utils/filesync_model.py b/src/zenml/utils/filesync_model.py index 7cd677ac127..27c8c586591 100644 --- a/src/zenml/utils/filesync_model.py +++ b/src/zenml/utils/filesync_model.py @@ -69,8 +69,6 @@ def config_validator( ValidationError: if you try to validate through a JSON string. You need to provide a config_file path when you create a FileSyncModel. - AssertionError: if the raw input does not include a config_file - path for the configuration file. """ # Disable json validation if info.mode == "json": diff --git a/src/zenml/utils/function_utils.py b/src/zenml/utils/function_utils.py index a82dfd1432e..9be15f2ed32 100644 --- a/src/zenml/utils/function_utils.py +++ b/src/zenml/utils/function_utils.py @@ -213,7 +213,7 @@ def create_cli_wrapped_script( flavor: The flavor to use. Yields: - The paths of the script and the output. + Tuple[Path, Path]: The paths of the script and the output. Raises: ValueError: If the function is not defined in a module. diff --git a/src/zenml/utils/io_utils.py b/src/zenml/utils/io_utils.py index 5346b43507f..83da8d54ae0 100644 --- a/src/zenml/utils/io_utils.py +++ b/src/zenml/utils/io_utils.py @@ -16,7 +16,7 @@ import fnmatch import os from pathlib import Path -from typing import TYPE_CHECKING, Iterable +from typing import TYPE_CHECKING, Iterator import click @@ -124,7 +124,7 @@ def copy_dir( copy(str(source_path), str(destination_path), overwrite) -def find_files(dir_path: "PathType", pattern: str) -> Iterable[str]: +def find_files(dir_path: "PathType", pattern: str) -> Iterator[str]: """Find files in a directory that match pattern. Args: @@ -132,7 +132,7 @@ def find_files(dir_path: "PathType", pattern: str) -> Iterable[str]: pattern: pattern like *.png. Yields: - All matching filenames in the directory. + str: All matching filenames in the directory. """ for root, _, files in walk(dir_path): for basename in files: diff --git a/src/zenml/utils/mlstacks_utils.py b/src/zenml/utils/mlstacks_utils.py index 0570af3a304..dacb5678959 100644 --- a/src/zenml/utils/mlstacks_utils.py +++ b/src/zenml/utils/mlstacks_utils.py @@ -69,7 +69,7 @@ def get_stack_spec_file_path(stack_name: str) -> str: The path to the stack spec file for the given stack name. Raises: - KeyError: If the stack does not exist. + e: If the stack does not exist. """ try: stack = Client().get_stack( diff --git a/src/zenml/utils/pipeline_docker_image_builder.py b/src/zenml/utils/pipeline_docker_image_builder.py index c0295ffc4f9..492caea13fe 100644 --- a/src/zenml/utils/pipeline_docker_image_builder.py +++ b/src/zenml/utils/pipeline_docker_image_builder.py @@ -114,8 +114,7 @@ def build_docker_image( RuntimeError: If the stack does not contain an image builder. ValueError: If no Dockerfile and/or custom parent image is specified and the Docker configuration doesn't require an - image build. - ValueError: If the specified Dockerfile does not exist. + image build or if the specified Dockerfile does not exist. """ requirements: Optional[str] = None dockerfile: Optional[str] = None diff --git a/src/zenml/utils/source_utils.py b/src/zenml/utils/source_utils.py index f1a5c6389d7..092b2882a0d 100644 --- a/src/zenml/utils/source_utils.py +++ b/src/zenml/utils/source_utils.py @@ -429,9 +429,6 @@ def prepend_python_path(path: str) -> Iterator[None]: Args: path: Path that will be prepended to sys.path for the duration of the context manager. - - Yields: - None """ try: sys.path.insert(0, path) diff --git a/src/zenml/zen_server/feature_gate/feature_gate_interface.py b/src/zenml/zen_server/feature_gate/feature_gate_interface.py index df4a5d3fc70..3c5455fb233 100644 --- a/src/zenml/zen_server/feature_gate/feature_gate_interface.py +++ b/src/zenml/zen_server/feature_gate/feature_gate_interface.py @@ -30,7 +30,7 @@ def check_entitlement(self, resource: ResourceType) -> None: resource: The resource the user wants to create Raises: - UpgradeRequiredError in case a subscription limit is reached + UpgradeRequiredError: in case a subscription limit is reached """ @abstractmethod diff --git a/src/zenml/zen_server/rate_limit.py b/src/zenml/zen_server/rate_limit.py index afef9530015..652836790b5 100644 --- a/src/zenml/zen_server/rate_limit.py +++ b/src/zenml/zen_server/rate_limit.py @@ -138,14 +138,11 @@ def _get_ipaddr(self, request: Request) -> str: @contextmanager def limit_failed_requests( self, request: Request - ) -> Generator[None, Any, Any]: + ) -> Generator[None, None, None]: """Limits the number of failed requests. Args: request: Request object. - - Yields: - None """ self.hit_limiter(request) diff --git a/src/zenml/zen_server/rbac/endpoint_utils.py b/src/zenml/zen_server/rbac/endpoint_utils.py index 1f8abe8d6ea..90d4c0c4b8a 100644 --- a/src/zenml/zen_server/rbac/endpoint_utils.py +++ b/src/zenml/zen_server/rbac/endpoint_utils.py @@ -106,7 +106,7 @@ def verify_permissions_and_get_entity( Args: id: The ID of the entity to fetch. get_method: The method to fetch the entity. - get_method_kwargs: Keyword arguments to pass to the get method. + **get_method_kwargs: Keyword arguments to pass to the get method. Returns: A model of the fetched entity. @@ -128,7 +128,7 @@ def verify_permissions_and_list_entities( filter_model: The entity filter model. resource_type: The resource type of the entities to list. list_method: The method to list the entities. - list_method_kwargs: Keyword arguments to pass to the list method. + **list_method_kwargs: Keyword arguments to pass to the list method. Returns: A page of entity models. @@ -199,7 +199,7 @@ def verify_permissions_and_prune_entities( Args: resource_type: The resource type of the entities to prune. prune_method: The method to prune the entities. - kwargs: Keyword arguments to pass to the prune method. + **kwargs: Keyword arguments to pass to the prune method. """ verify_permission(resource_type=resource_type, action=Action.PRUNE) prune_method(**kwargs) diff --git a/src/zenml/zen_server/routers/service_connectors_endpoints.py b/src/zenml/zen_server/routers/service_connectors_endpoints.py index 5eb80e91266..b48f5ea1a1d 100644 --- a/src/zenml/zen_server/routers/service_connectors_endpoints.py +++ b/src/zenml/zen_server/routers/service_connectors_endpoints.py @@ -422,8 +422,8 @@ def get_resources_based_on_service_connector_info( access to and consumable from UI/CLI. Raises: - ValueError: If both connector_info and connector_uuid are provided. - ValueError: If neither connector_info nor connector_uuid are provided. + ValueError: If both connector_info and connector_uuid are provided or + if neither connector_info nor connector_uuid are provided. """ if connector_info is not None and connector_uuid is not None: raise ValueError( diff --git a/src/zenml/zen_stores/rest_zen_store.py b/src/zenml/zen_stores/rest_zen_store.py index d049b55ff3b..a46f508a685 100644 --- a/src/zenml/zen_stores/rest_zen_store.py +++ b/src/zenml/zen_stores/rest_zen_store.py @@ -2488,7 +2488,7 @@ def _populate_connector_type( are updated accordingly. Args: - connector_models: The service connector or resource models to + *connector_models: The service connector or resource models to populate. """ for service_connector in connector_models: @@ -4150,7 +4150,7 @@ def _request( url: The URL to request. params: The query parameters to pass to the endpoint. timeout: The request timeout in seconds. - kwargs: Additional keyword arguments to pass to the request. + **kwargs: Additional keyword arguments to pass to the request. Returns: The parsed response. @@ -4213,7 +4213,7 @@ def get( path: The path to the endpoint. params: The query parameters to pass to the endpoint. timeout: The request timeout in seconds. - kwargs: Additional keyword arguments to pass to the request. + **kwargs: Additional keyword arguments to pass to the request. Returns: The response body. @@ -4240,7 +4240,7 @@ def delete( path: The path to the endpoint. params: The query parameters to pass to the endpoint. timeout: The request timeout in seconds. - kwargs: Additional keyword arguments to pass to the request. + **kwargs: Additional keyword arguments to pass to the request. Returns: The response body. @@ -4269,7 +4269,7 @@ def post( body: The body to send. params: The query parameters to pass to the endpoint. timeout: The request timeout in seconds. - kwargs: Additional keyword arguments to pass to the request. + **kwargs: Additional keyword arguments to pass to the request. Returns: The response body. @@ -4299,7 +4299,7 @@ def put( body: The body to send. params: The query parameters to pass to the endpoint. timeout: The request timeout in seconds. - kwargs: Additional keyword arguments to pass to the request. + **kwargs: Additional keyword arguments to pass to the request. Returns: The response body. @@ -4513,7 +4513,7 @@ def _list_resources( Args: route: The resource REST API route to use. response_model: Model to use to serialize the response body. - filters: Filter parameters to use in the query. + **filters: Filter parameters to use in the query. Returns: List of retrieved resources matching the filter criteria. diff --git a/src/zenml/zen_stores/schemas/api_key_schemas.py b/src/zenml/zen_stores/schemas/api_key_schemas.py index dc43e90cbb9..2eb70e79cdc 100644 --- a/src/zenml/zen_stores/schemas/api_key_schemas.py +++ b/src/zenml/zen_stores/schemas/api_key_schemas.py @@ -126,8 +126,6 @@ def to_model( include_resources: Whether the resources will be filled. **kwargs: Keyword arguments to allow schema specific logic - **kwargs: Keyword arguments to filter models. - Returns: The created APIKeyResponse. """ diff --git a/src/zenml/zen_stores/schemas/base_schemas.py b/src/zenml/zen_stores/schemas/base_schemas.py index cd8d3f3a7bd..5dbdd1a7b5f 100644 --- a/src/zenml/zen_stores/schemas/base_schemas.py +++ b/src/zenml/zen_stores/schemas/base_schemas.py @@ -45,6 +45,9 @@ def to_model( include_resources: Whether the resources will be filled. **kwargs: Keyword arguments to allow schema specific logic + Returns: + The corresponding model instance. + Raises: NotImplementedError: When the base class fails to implement this. """ diff --git a/src/zenml/zen_stores/schemas/code_repository_schemas.py b/src/zenml/zen_stores/schemas/code_repository_schemas.py index 6bd4511edf2..78c6b910da6 100644 --- a/src/zenml/zen_stores/schemas/code_repository_schemas.py +++ b/src/zenml/zen_stores/schemas/code_repository_schemas.py @@ -216,8 +216,6 @@ def to_model( include_resources: Whether the resources will be filled. **kwargs: Keyword arguments to allow schema specific logic - kwargs: Additional keyword arguments. - Returns: The converted model. """ diff --git a/src/zenml/zen_stores/schemas/service_schemas.py b/src/zenml/zen_stores/schemas/service_schemas.py index 7cd522f64d1..52002ca635b 100644 --- a/src/zenml/zen_stores/schemas/service_schemas.py +++ b/src/zenml/zen_stores/schemas/service_schemas.py @@ -128,7 +128,7 @@ def to_model( Args: include_metadata: Whether to include metadata in the response. include_resources: Whether to include resources in the response. - kwargs: Additional keyword arguments. + **kwargs: Additional keyword arguments. Returns: The created `ServiceResponse`. diff --git a/src/zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py b/src/zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py index 3af1ee8ad85..32c68b2a1a6 100644 --- a/src/zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py +++ b/src/zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py @@ -59,6 +59,7 @@ class HashiCorpVaultSecretsStoreConfiguration(SecretsStoreConfiguration): vault_namespace: The Vault Enterprise namespace. mount_point: The mount point to use for all secrets. max_versions: The maximum number of secret versions to keep. + model_config: The model configuration. """ type: SecretsStoreType = SecretsStoreType.HASHICORP diff --git a/src/zenml/zen_stores/sql_zen_store.py b/src/zenml/zen_stores/sql_zen_store.py index 91db8cdad9c..c3cb16cd4c2 100644 --- a/src/zenml/zen_stores/sql_zen_store.py +++ b/src/zenml/zen_stores/sql_zen_store.py @@ -2692,10 +2692,6 @@ def create_artifact_version( Returns: The created artifact version. - - Raises: - EntityExistsError: if an artifact with the same name and version - already exists. """ with Session(self.engine) as session: # Check if an artifact with the given name and version exists @@ -5051,7 +5047,7 @@ def get_or_create_run( # noqa: DAR401 Raises: ValueError: If the request does not contain an orchestrator run ID. - EntityExistsError: If a run with the same name already exists. + create_error: If a run with the same name already exists. RuntimeError: If the run fetching failed unexpectedly. Returns: @@ -5559,6 +5555,9 @@ def _set_secret_values( backup: Whether to back up the values in the backup secrets store, if configured. + Raises: + Exception: If the values could not be set in the secrets store. + # noqa: DAR401 """ @@ -5638,6 +5637,10 @@ def _get_secret_values( Returns: The values of the secret. + Raises: + Exception: If the values could not be retrieved from the secrets + store. + # noqa: DAR401 """ try: @@ -5724,6 +5727,9 @@ def _update_secret_values( Returns: The updated values. + Raises: + Exception: If the values could not be updated in the secrets store. + # noqa: DAR401 """ try: @@ -5813,6 +5819,10 @@ def _delete_secret_values( delete_backup: Whether to delete the backup values of the secret from the backup secrets store, if configured. + Raises: + Exception: If the values could not be deleted from the + secrets store. + # noqa: DAR401 """ @@ -6109,10 +6119,11 @@ def backup_secrets( this flag effectively moves all secrets from the primary secrets store to the backup secrets store. - # noqa: DAR401 Raises: BackupSecretsStoreNotConfiguredError: if no backup secrets store is configured. + Exception: if the values could not be backed up to the backup + secrets store. """ if not self.backup_secrets_store: raise BackupSecretsStoreNotConfiguredError( @@ -6175,10 +6186,11 @@ def restore_secrets( this flag effectively moves all secrets from the backup secrets store to the primary secrets store. - # noqa: DAR401 Raises: BackupSecretsStoreNotConfiguredError: if no backup secrets store is configured. + Exception: if the values could not be restored to the primary + secret store. """ if not self.backup_secrets_store: raise BackupSecretsStoreNotConfiguredError( @@ -6889,7 +6901,7 @@ def _populate_connector_type( field is left as is. Args: - service_connectors: The service connectors to populate. + *service_connectors: The service connectors to populate. """ for service_connector in service_connectors: if not service_connector_registry.is_registered( @@ -7231,7 +7243,6 @@ def create_stack(self, stack: StackRequest) -> StackResponse: ValueError: If the full stack creation fails, due to the corrupted input. Exception: If the full stack creation fails, due to unforeseen - errors. """ with Session(self.engine) as session: # For clean-up purposes, each created entity is tracked here @@ -7813,6 +7824,9 @@ def get_stack_deployment_info( Args: provider: The stack deployment provider. + Returns: + Information about the stack deployment provider. + Raises: NotImplementedError: Stack deployments are not supported by the local ZenML deployment. @@ -7834,6 +7848,9 @@ def get_stack_deployment_config( stack_name: The name of the stack. location: The location where the stack should be deployed. + Returns: + The stack deployment configuration. + Raises: NotImplementedError: Stack deployments are not supported by the local ZenML deployment. @@ -7857,6 +7874,9 @@ def get_stack_deployment_stack( location: The location where the stack should be deployed. date_start: The date when the deployment started. + Returns: + The deployed stack if found, otherwise None. + Raises: NotImplementedError: Stack deployments are not supported by the local ZenML deployment. @@ -8924,9 +8944,6 @@ def get_user( Returns: The requested user, if it was found. - - Raises: - KeyError: If the user does not exist. """ with Session(self.engine) as session: if user_name_or_id is None: @@ -9929,7 +9946,7 @@ def create_model_version( Raises: ValueError: If `number` is not None during model version creation. - EntityExistsError: If a workspace with the given name already exists. + e: If a model version with this name already exists. """ if model_version.number is not None: raise ValueError( diff --git a/tests/harness/deployment/base.py b/tests/harness/deployment/base.py index 4e9382836dc..fac107b3d16 100644 --- a/tests/harness/deployment/base.py +++ b/tests/harness/deployment/base.py @@ -282,7 +282,7 @@ def connect( custom_password: Custom password to use for the connection. Yields: - A ZenML Client configured to connect to this deployment. + Client: A ZenML Client configured to connect to this deployment. Raises: RuntimeError: If the deployment is disabled. diff --git a/tests/harness/environment.py b/tests/harness/environment.py index ef177069f67..8b51cab3cd0 100644 --- a/tests/harness/environment.py +++ b/tests/harness/environment.py @@ -165,10 +165,7 @@ def mandatory_components( Returns: A dictionary mapping component types to a list of mandatory - components. - - Raises: - AssertionError: If the components have not been collected yet. + components. """ if self._mandatory_components is not None: return self._mandatory_components @@ -433,11 +430,12 @@ def setup( provisioned on entry, it will not be deprovisioned. Yields: - A ZenML client connected to the environment. + Client: A ZenML client connected to the environment. Raises: RuntimeError: If the environment is disabled. - Exception: The exception caught during provisioning. + e: The exception caught during provisioning. + e1: The exception caught during cleanup. """ if self.is_disabled: raise RuntimeError( diff --git a/tests/harness/harness.py b/tests/harness/harness.py index 0357f681709..e6b6a15c3c9 100644 --- a/tests/harness/harness.py +++ b/tests/harness/harness.py @@ -402,7 +402,7 @@ def setup_test_stack( cleanup: Whether to clean up the stack after the test. Yields: - The active stack that the test should use. + Stack: The active stack that the test should use. """ test_config = self._get_test_module_requirements(module) if test_config is None: diff --git a/tests/harness/model/config.py b/tests/harness/model/config.py index a649ad319b9..0c62e4ec4cd 100644 --- a/tests/harness/model/config.py +++ b/tests/harness/model/config.py @@ -70,8 +70,6 @@ def config_validator( ValidationError: if you try to validate through a JSON string. You need to provide a config_file path when you create a FileSyncModel. - AssertionError: if the raw input does not include a config_file - path for the configuration file. """ # Disable json validation if info.mode == "json": diff --git a/tests/harness/model/test.py b/tests/harness/model/test.py index da4706e672b..bc14a1dbc3a 100644 --- a/tests/harness/model/test.py +++ b/tests/harness/model/test.py @@ -124,7 +124,7 @@ def setup_test_stack( cleanup: Whether to clean up the stack after the test. Yields: - The active stack that the test should use. + Stack: The active stack that the test should use. Raises: RuntimeError: If the stack requirements are not met or if multiple diff --git a/tests/harness/utils.py b/tests/harness/utils.py index 6ec7e38fadb..16b1c487768 100644 --- a/tests/harness/utils.py +++ b/tests/harness/utils.py @@ -93,7 +93,8 @@ def environment_session( deprovisioned on exit. Yields: - The active environment and a client connected with it. + Tuple[TestEnvironment, Client]: A tuple containing the active + environment and a client connected with it. """ # set env variables os.environ[ENV_ZENML_DEBUG] = "true" @@ -147,7 +148,7 @@ def clean_repo_session( cleanup: Whether to clean up the repository on exit. Yields: - A ZenML client connected to the repository. + Client: A ZenML client connected to the repository. """ # original working directory orig_cwd = os.getcwd() @@ -191,7 +192,7 @@ def clean_workspace_session( workspace. Yields: - A ZenML client configured to use the workspace. + Client: A ZenML client configured to use the workspace. """ from zenml.utils.string_utils import random_str @@ -233,7 +234,7 @@ def clean_default_client_session( tmp_path_factory: A pytest fixture that provides a temporary directory. Yields: - A clean ZenML client. + Client: A clean ZenML client. """ # save the current global configuration and client singleton instances # to restore them later, then reset them @@ -318,7 +319,7 @@ def setup_test_stack_session( clean_repo: bool = False, check_requirements: bool = True, no_cleanup: bool = False, -) -> Generator[Stack, None, None]: +) -> Generator["Stack", None, None]: """Context manager to configure a stack adapted to the requirements of the current test module. Args: @@ -337,7 +338,7 @@ def setup_test_stack_session( no_cleanup: Whether to skip cleaning up the test stack on exit. Yields: - An active ZenML stack matching the requirements of the test module. + Stack: An active ZenML stack matching the requirements of the test module. Raises: ValueError: If `tmp_path_factory` is not provided when `clean_repo`