Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GmailConnector create_label : do not raise error if user try t… #176

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions melusine/_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module which handles the package configuration.
"""

import copy
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions melusine/backend/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
BaseTransformerBackend,
]
"""

from abc import ABC, abstractmethod
from typing import Any, Callable, List, Optional

Expand Down
1 change: 1 addition & 0 deletions melusine/backend/pandas_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
PandasBackend,
]
"""

from typing import Any, Callable, List, Optional, Tuple, Union

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions melusine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MelusineFeatureEncoder
]
"""

from __future__ import annotations

import copy
Expand Down
12 changes: 10 additions & 2 deletions melusine/connectors/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from tqdm import tqdm

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -158,8 +159,15 @@ def create_label(self, label_name: str) -> Dict[str, str]:
Returns:
Dict[str, str]: return from the api with label and its informations
"""
label = self.service.users().labels().create(userId="me", body=dict(name=label_name)).execute()
logger.info(f"Label {label_name} has been created.")
try:
label = self.service.users().labels().create(userId="me", body=dict(name=label_name)).execute()
logger.info(f"Label {label_name} has been created.")
except HttpError as error:
if error.resp.status == 409: # Conflict error if label already exists
logger.error(f"Label '{label_name}' already exists.")
return {}
else:
raise
return label

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions melusine/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ReplyDetector, TransferDetector, RecipientsDetector]

"""

from typing import Any, Dict, List, Tuple

from melusine.base import MelusineDetector, MelusineItem, MelusineRegex
Expand Down
1 change: 1 addition & 0 deletions melusine/io/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Contained classes: [IoMixin]
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions melusine/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Implemented classes: [Message]
"""

import re
from datetime import datetime
from typing import Iterable, List, Optional, Tuple
Expand Down
1 change: 1 addition & 0 deletions melusine/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Implemented classes: [PipelineConfigurationError, MelusinePipeline]
"""

from __future__ import annotations

import copy
Expand Down
2 changes: 1 addition & 1 deletion melusine/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Cleaner,
]
"""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -1901,7 +1902,6 @@ def clean(self, text: str) -> str:


class DateProcessor(MelusineTransformer):

"""
Parse string date to iso format string date
"""
Expand Down
1 change: 1 addition & 0 deletions melusine/regex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The melusine.regex module includes tools for handling regexes.
"""

from melusine.regex.emergency_regex import EmergencyRegex
from melusine.regex.reply_regex import ReplyRegex
from melusine.regex.thanks_regex import ThanksRegex
Expand Down
1 change: 1 addition & 0 deletions melusine/testing/pipeline_testing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module that contains utility functions for tests (in /tests).
"""

from typing import Any, Dict

from melusine.base import MelusineTransformer
Expand Down
1 change: 1 addition & 0 deletions melusine/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The melusine.utils module includes utils functionalitites.
"""

from melusine.utils.show_versions import show_versions

__all__ = ["show_versions"]
1 change: 1 addition & 0 deletions tests/detectors/test_reply_detector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit tests of the ReplyDetector.
"""

import pandas as pd
import pytest
from pandas import DataFrame
Expand Down
1 change: 1 addition & 0 deletions tests/detectors/test_thanks_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit test of the ThanksDetector.

"""

from tempfile import TemporaryDirectory

import pandas as pd
Expand Down
1 change: 0 additions & 1 deletion tests/detectors/test_transfer_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Unit tests of the TransferDetector.
"""


import pandas as pd
import pytest
from pandas import DataFrame
Expand Down
1 change: 1 addition & 0 deletions tests/detectors/test_vacation_reply_detector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit tests of the VacationReplyDetector
"""

import pandas as pd
import pytest
from pandas import DataFrame
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_emails_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
}
========================================================================================
"""

import pytest

testcase_initial_cleaning_1 = dict(
Expand Down
1 change: 1 addition & 0 deletions tests/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit test for pipeline.py
"""

import pandas as pd
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/pipeline/test_pipeline_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example script to fit a minimal preprocessing pipeline
"""

import pandas as pd
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/processors/test_processors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit test for processors.py
"""

import pytest

from melusine.processors import (
Expand Down
Loading