From 405a02131e622a421e8379665b6296a848a3c403 Mon Sep 17 00:00:00 2001 From: Robbe Sneyders Date: Fri, 23 Jun 2023 10:40:34 +0200 Subject: [PATCH] Make pipeline argument positional and relative to cwd (#227) --- .../pipelines/controlnet-interior-design/pipeline.py | 12 +----------- .../pipelines/finetune_stable_diffusion/pipeline.py | 7 +------ fondant/cli.py | 6 +++--- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/examples/pipelines/controlnet-interior-design/pipeline.py b/examples/pipelines/controlnet-interior-design/pipeline.py index 561d25e83..33b4d9054 100644 --- a/examples/pipelines/controlnet-interior-design/pipeline.py +++ b/examples/pipelines/controlnet-interior-design/pipeline.py @@ -1,6 +1,4 @@ """Pipeline used to create a stable diffusion dataset from a set of initial prompts.""" -# pylint: disable=import-error -import argparse import logging import sys @@ -8,19 +6,13 @@ from pipeline_configs import PipelineConfigs -from fondant.pipeline import ( - ComponentOp, - Pipeline, - Client, -) +from fondant.pipeline import ComponentOp, Pipeline logger = logging.getLogger(__name__) # General configs pipeline_name = "controlnet-pipeline" pipeline_description = "Pipeline that collects data to train ControlNet" -client = Client(host=PipelineConfigs.HOST) - # Define component ops generate_prompts_op = ComponentOp( component_spec_path="components/generate_prompts/fondant_component.yaml", @@ -83,5 +75,3 @@ pipeline.add_op(caption_images_op, dependencies=download_images_op) pipeline.add_op(segment_images_op, dependencies=caption_images_op) pipeline.add_op(write_to_hub_controlnet, dependencies=segment_images_op) - -client.compile_and_run(pipeline=pipeline) diff --git a/examples/pipelines/finetune_stable_diffusion/pipeline.py b/examples/pipelines/finetune_stable_diffusion/pipeline.py index 5ad9f0a70..ae52603e7 100644 --- a/examples/pipelines/finetune_stable_diffusion/pipeline.py +++ b/examples/pipelines/finetune_stable_diffusion/pipeline.py @@ -1,5 +1,4 @@ """Pipeline used to create a stable diffusion dataset from a set of given images.""" -import argparse import logging import sys @@ -7,15 +6,13 @@ from pipeline_configs import PipelineConfigs -from fondant.pipeline import ComponentOp, Pipeline, Client +from fondant.pipeline import ComponentOp, Pipeline logger = logging.getLogger(__name__) # General configs pipeline_name = "Test fondant pipeline" pipeline_description = "A test pipeline" -client = Client(host=PipelineConfigs.HOST) - load_component_column_mapping = {"image": "images_data", "text": "captions_data"} write_component_column_mapping = { @@ -97,5 +94,3 @@ pipeline.add_op(download_images_op, dependencies=laion_retrieval_op) pipeline.add_op(caption_images_op, dependencies=download_images_op) pipeline.add_op(write_to_hub, dependencies=caption_images_op) - -client.compile_and_run(pipeline=pipeline) diff --git a/fondant/cli.py b/fondant/cli.py index c72eeebf8..3f1ee7b01 100644 --- a/fondant/cli.py +++ b/fondant/cli.py @@ -17,6 +17,7 @@ import importlib import logging import shutil +import sys import typing as t from fondant.compiler import DockerCompiler @@ -34,6 +35,7 @@ def entrypoint(): + sys.path.append(".") args = cli.parse_args() args.func(args) @@ -168,10 +170,8 @@ def pipeline_from_string(import_string: str) -> Pipeline: help="Compile a fondant pipeline", args=[ argument( - "--pipeline", - "-p", + "pipeline", help="Path to the fondant pipeline: path.to.module:instance", - required=True, type=pipeline_from_string, ), argument(