Skip to content

Commit

Permalink
Centralize logging configuration (#229)
Browse files Browse the repository at this point in the history
I was getting double logs with the local runner and was never a fan of
the `configure_logging` utility function which had to be called by the
user. This sets the logging format and level centrally in a way that
doesn't overwrite already configured handlers and can easily be
overwritten for each separate logger by the user.
  • Loading branch information
RobbeSneyders authored Jun 23, 2023
1 parent 50a2796 commit 684613e
Show file tree
Hide file tree
Showing 23 changed files with 5 additions and 88 deletions.
2 changes: 0 additions & 2 deletions components/caption_images/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from transformers import BatchEncoding, BlipForConditionalGeneration, BlipProcessor

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/download_images/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
from resizer import Resizer

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/embedding_based_laion_retrieval/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from clip_client import ClipClient, Modality

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/filter_comments/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from utils.text_extraction import get_comments_to_code_ratio

from fondant.component import DaskTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/filter_line_length/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import dask.dataframe as dd

from fondant.component import DaskTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/image_cropping/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from PIL import Image

from fondant.component import DaskTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/image_embedding/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from transformers import CLIPProcessor, CLIPVisionModelWithProjection

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/image_resolution_extraction/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import pandas as pd

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/image_resolution_filtering/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import dask.dataframe as dd

from fondant.component import DaskTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/load_from_hf_hub/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import dask.dataframe as dd

from fondant.component import LoadComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/pii_redaction/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pii_redaction import redact_pii

from fondant.component import DaskTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/prompt_based_laion_retrieval/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from clip_client import ClipClient, Modality

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/segment_images/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from transformers import AutoModelForSemanticSegmentation, BatchFeature, SegformerImageProcessor

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions components/write_to_hf_hub/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from PIL import Image

from fondant.component import WriteComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import pandas as pd

from fondant.component import LoadComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)

interior_styles = [
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelines/controlnet-interior-design/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
Pipeline,
Client,
)
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)
# General configs
pipeline_name = "controlnet-pipeline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
from spacy.symbols import nsubj, VERB

from fondant.component import PandasTransformComponent
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions examples/pipelines/datacomp/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

from fondant.compiler import DockerCompiler
from fondant.pipeline import ComponentOp, Pipeline, Client
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)

# Initialize pipeline and client
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelines/finetune_stable_diffusion/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pipeline_configs import PipelineConfigs

from fondant.pipeline import ComponentOp, Pipeline, Client
from fondant.logger import configure_logging

configure_logging()
logger = logging.getLogger(__name__)
# General configs
pipeline_name = "Test fondant pipeline"
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelines/starcoder/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from pipeline_configs import PipelineConfigs

from fondant.compiler import DockerCompiler
from fondant.logger import configure_logging
from fondant.pipeline import ComponentOp, Pipeline

configure_logging()
logger = logging.getLogger(__name__)


Expand Down
5 changes: 5 additions & 0 deletions fondant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import logging

logging.basicConfig(
format="[%(asctime)s | %(name)s | %(levelname)s] %(message)s", level=logging.INFO
)
23 changes: 0 additions & 23 deletions fondant/logger.py

This file was deleted.

25 changes: 0 additions & 25 deletions tests/test_logger.py

This file was deleted.

0 comments on commit 684613e

Please sign in to comment.