From b6830a1f1d1d6642c838f3021dbd4e3cad5c5435 Mon Sep 17 00:00:00 2001 From: Ivan Yordanov Date: Fri, 28 Jun 2024 16:57:36 +0300 Subject: [PATCH] Add docstrings in API --- kpops/api/__init__.py | 88 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/kpops/api/__init__.py b/kpops/api/__init__.py index 826307308..79fe0ccd8 100644 --- a/kpops/api/__init__.py +++ b/kpops/api/__init__.py @@ -37,6 +37,17 @@ def generate( environment: str | None = None, verbose: bool = False, ) -> Pipeline: + """Generate enriched pipeline representation. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :return: Generated `Pipeline` object. + """ kpops_config = KpopsConfig.create( config, dotenv, @@ -68,6 +79,17 @@ def manifest( environment: str | None = None, verbose: bool = False, ) -> list[Resource]: + """Generate pipeline, return final resource representations for each step. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :return: Resources. + """ pipeline = kpops.generate( pipeline_path=pipeline_path, dotenv=dotenv, @@ -95,6 +117,18 @@ def deploy( verbose: bool = True, parallel: bool = False, ): + """Deploy pipeline steps. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param dry_run: Whether to dry run the command or execute it. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :param parallel: Enable or disable parallel execution of pipeline steps. + """ pipeline = kpops.generate( pipeline_path=pipeline_path, dotenv=dotenv, @@ -131,6 +165,18 @@ def destroy( verbose: bool = True, parallel: bool = False, ): + """Destroy pipeline steps. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param dry_run: Whether to dry run the command or execute it. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :param parallel: Enable or disable parallel execution of pipeline steps. + """ pipeline = kpops.generate( pipeline_path=pipeline_path, dotenv=dotenv, @@ -169,6 +215,18 @@ def reset( verbose: bool = True, parallel: bool = False, ): + """Reset pipeline steps. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param dry_run: Whether to dry run the command or execute it. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :param parallel: Enable or disable parallel execution of pipeline steps. + """ pipeline = kpops.generate( pipeline_path=pipeline_path, dotenv=dotenv, @@ -206,6 +264,18 @@ def clean( verbose: bool = True, parallel: bool = False, ): + """Clean pipeline steps. + + :param pipeline_path: Path to pipeline definition yaml file. + :param dotenv: Paths to dotenv files. + :param config: Path to the dir containing config.yaml files. + :param steps: Set of steps (components) to apply the command on. + :param filter_type: Whether `steps` should include/exclude the steps. + :param dry_run: Whether to dry run the command or execute it. + :param environment: The environment to generate and deploy the pipeline to. + :param verbose: Enable verbose printing. + :param parallel: Enable or disable parallel execution of pipeline steps. + """ pipeline = kpops.generate( pipeline_path=pipeline_path, dotenv=dotenv, @@ -236,6 +306,12 @@ def init( path: Path, config_include_opt: bool = False, ): + """Initiate a default empty project. + + :param path: Directory in which the project should be initiated. + :param conf_incl_opt: Whether to include non-required settings + in the generated config file. + """ if not path.exists(): path.mkdir(parents=False) elif next(path.iterdir(), False): @@ -249,6 +325,13 @@ def create_pipeline( kpops_config: KpopsConfig, environment: str | None, ) -> Pipeline: + """Create pipeline. + + :param pipeline_path: Path to pipeline definition yaml file. + :param config: KPOps Config. + :param environment: The environment to generate and deploy the pipeline to. + :return: Created `Pipeline` object. + """ registry = Registry() if kpops_config.components_module: registry.find_components(kpops_config.components_module) @@ -260,6 +343,11 @@ def create_pipeline( def setup_handlers(config: KpopsConfig) -> ComponentHandlers: + """Set up handlers for a component. + + :param config: KPOps config. + :return: Handlers for a component. + """ schema_handler = SchemaHandler.load_schema_handler(config) connector_handler = KafkaConnectHandler.from_kpops_config(config) proxy_wrapper = ProxyWrapper(config.kafka_rest)