Skip to content

Commit 4a37e25

Browse files
Merge branch 'main' into refactor_lint_fixes_B_PERF_RUF_C4
2 parents f648a1b + d34e0f2 commit 4a37e25

File tree

112 files changed

+368
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+368
-281
lines changed

src/conductor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.10"
1+
__version__ = "1.1.10"

src/conductor/client/ai/integrations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
from abc import ABC, abstractmethod
5-
5+
from typing import Optional
66

77
class IntegrationConfig(ABC):
88
@abstractmethod
@@ -26,7 +26,7 @@ def to_dict(self) -> dict:
2626

2727
class OpenAIConfig(IntegrationConfig):
2828

29-
def __init__(self, api_key: str = None) -> None:
29+
def __init__(self, api_key: Optional[str] = None) -> None:
3030
if api_key is None:
3131
api_key = os.getenv('OPENAI_API_KEY')
3232
self.api_key = api_key
@@ -52,7 +52,7 @@ def to_dict(self) -> dict:
5252

5353
class PineconeConfig(IntegrationConfig):
5454

55-
def __init__(self, api_key: str = None, endpoint: str = None, environment: str = None, project_name: str = None) -> None:
55+
def __init__(self, api_key: Optional[str] = None, endpoint: Optional[str] = None, environment: Optional[str] = None, project_name: Optional[str] = None) -> None:
5656
if api_key is None:
5757
self.api_key = os.getenv('PINECONE_API_KEY')
5858
else:

src/conductor/client/ai/orchestrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def add_ai_integration(self, ai_integration_name: str, provider: LLMProvider, mo
7373
if existing_integration_api is None or overwrite:
7474
self.integration_client.save_integration_api(ai_integration_name, model, api_details)
7575

76-
def add_vector_store(self, db_integration_name: str, provider: VectorDB, indices: List[str],config: IntegrationConfig,
77-
description: str = None,overwrite : bool = False):
76+
def add_vector_store(self, db_integration_name: str, provider: VectorDB, indices: List[str], config: IntegrationConfig,
77+
description: Optional[str] = None, overwrite: bool = False):
7878
vector_db = IntegrationUpdate()
7979
vector_db.configuration = config.to_dict()
8080
vector_db.type = provider.value

src/conductor/client/authorization_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from abc import ABC, abstractmethod
23
from typing import Dict, List, Optional
34
from conductor.client.orkes.models.metadata_tag import MetadataTag

src/conductor/client/automator/task_handler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from __future__ import annotations
12
import importlib
23
import logging
34
import os
4-
from multiprocessing import Process, freeze_support, Queue, set_start_method, get_context
5+
from multiprocessing import Process, freeze_support, Queue, set_start_method
56
from sys import platform
6-
from typing import List
7+
from typing import List, Optional
78

89
from conductor.client.automator.task_runner import TaskRunner
910
from conductor.client.configuration.configuration import Configuration
@@ -45,11 +46,11 @@ def register_decorated_fn(name: str, poll_interval: int, domain: str, worker_id:
4546
class TaskHandler:
4647
def __init__(
4748
self,
48-
workers: List[WorkerInterface] = None,
49-
configuration: Configuration = None,
50-
metrics_settings: MetricsSettings = None,
49+
workers: Optional[List[WorkerInterface]] = None,
50+
configuration: Optional[Configuration] = None,
51+
metrics_settings: Optional[MetricsSettings] = None,
5152
scan_for_annotated_workers: bool = True,
52-
import_modules: List[str] = None
53+
import_modules: Optional[List[str]] = None
5354
):
5455
workers = workers or []
5556
self.logger_process, self.queue = _setup_logging_queue(configuration)
@@ -62,8 +63,6 @@ def __init__(
6263
logger.info(f'loading module {module}')
6364
importlib.import_module(module)
6465

65-
if workers is None:
66-
workers = []
6766
elif not isinstance(workers, list):
6867
workers = [workers]
6968
if scan_for_annotated_workers is True:

src/conductor/client/automator/task_runner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,13 @@ def __set_worker_properties(self) -> None:
229229
if polling_interval:
230230
try:
231231
self.worker.poll_interval = float(polling_interval)
232-
except Exception as e:
232+
except Exception:
233233
logger.error(f'error reading and parsing the polling interval value {polling_interval}')
234234
self.worker.poll_interval = self.worker.get_polling_interval_in_seconds()
235235

236236
if polling_interval:
237237
try:
238238
self.worker.poll_interval = float(polling_interval)
239-
polling_interval_initialized = True
240239
except Exception as e:
241240
logger.error("Exception in reading polling interval from environment variable: {0}.".format(str(e)))
242241

src/conductor/client/automator/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
import dataclasses
23
import datetime
34
import inspect
@@ -43,7 +44,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
4344
if data is None:
4445
return data
4546

46-
if type(data) == cls:
47+
if isinstance(data, cls):
4748
return data
4849

4950
if dataclasses.is_dataclass(cls):
@@ -53,7 +54,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
5354
if not ((str(typ).startswith('dict[') or
5455
str(typ).startswith('typing.Dict[') or
5556
str(typ).startswith('requests.structures.CaseInsensitiveDict[') or
56-
typ == dict or str(typ).startswith('OrderedDict['))):
57+
typ is dict or str(typ).startswith('OrderedDict['))):
5758
data = {}
5859

5960
members = inspect.signature(cls.__init__).parameters
@@ -79,7 +80,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
7980
elif (str(typ).startswith('dict[') or
8081
str(typ).startswith('typing.Dict[') or
8182
str(typ).startswith('requests.structures.CaseInsensitiveDict[') or
82-
typ == dict or str(typ).startswith('OrderedDict[')):
83+
typ is dict or str(typ).startswith('OrderedDict[')):
8384

8485
values = {}
8586
generic_type = object
@@ -89,7 +90,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
8990
v = data[member][k]
9091
values[k] = get_value(generic_type, v)
9192
kwargs[member] = values
92-
elif typ == inspect.Parameter.empty:
93+
elif typ is inspect.Parameter.empty:
9394
if inspect.Parameter.VAR_KEYWORD == members[member].kind:
9495
if type(data) in dict_types:
9596
kwargs.update(data)
@@ -114,7 +115,7 @@ def get_value(typ: type, val: object) -> object:
114115
values.append(converted)
115116
return values
116117
elif str(typ).startswith('dict[') or str(typ).startswith(
117-
'typing.Dict[') or str(typ).startswith('requests.structures.CaseInsensitiveDict[') or typ == dict:
118+
'typing.Dict[') or str(typ).startswith('requests.structures.CaseInsensitiveDict[') or typ is dict:
118119
values = {}
119120
for k in val:
120121
v = val[k]

src/conductor/client/configuration/configuration.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
12
import logging
23
import os
34
import time
5+
from typing import Optional
46

57
from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings
68

@@ -10,10 +12,10 @@ class Configuration:
1012

1113
def __init__(
1214
self,
13-
base_url: str = None,
15+
base_url: Optional[str] = None,
1416
debug: bool = False,
1517
authentication_settings: AuthenticationSettings = None,
16-
server_api_url: str = None,
18+
server_api_url: Optional[str] = None,
1719
auth_token_ttl_min: int = 45
1820
):
1921
if server_api_url is not None:
@@ -138,7 +140,7 @@ def ui_host(self):
138140
"""
139141
return self.__ui_host
140142

141-
def apply_logging_config(self, log_format : str = None, level = None):
143+
def apply_logging_config(self, log_format : Optional[str] = None, level = None):
142144
if log_format is None:
143145
log_format = self.logger_format
144146
if level is None:

src/conductor/client/configuration/settings/metrics_settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import annotations
12
import logging
23
import os
4+
from typing import Optional
35
from pathlib import Path
46

57
from conductor.client.configuration.configuration import Configuration
@@ -18,7 +20,7 @@ def get_default_temporary_folder() -> str:
1820
class MetricsSettings:
1921
def __init__(
2022
self,
21-
directory: str = None,
23+
directory: Optional[str] = None,
2224
file_name: str = 'metrics.log',
2325
update_interval: float = 0.1):
2426
if directory is None:

src/conductor/client/helpers/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __deserialize(self, data, klass):
7272
if data is None:
7373
return None
7474

75-
if type(klass) == str:
75+
if isinstance(klass, str):
7676
if klass.startswith('list['):
7777
sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
7878
return [self.__deserialize(sub_data, sub_kls)
@@ -91,11 +91,11 @@ def __deserialize(self, data, klass):
9191

9292
if klass in self.PRIMITIVE_TYPES:
9393
return self.__deserialize_primitive(data, klass)
94-
elif klass == object:
94+
elif klass is object:
9595
return self.__deserialize_object(data)
96-
elif klass == datetime.date:
96+
elif klass is datetime.date:
9797
return self.__deserialize_date(data)
98-
elif klass == datetime.datetime:
98+
elif klass is datetime.datetime:
9999
return self.__deserialize_datatime(data)
100100
else:
101101
return self.__deserialize_model(data, klass)
@@ -109,7 +109,7 @@ def __deserialize_primitive(self, data, klass):
109109
:return: int, long, float, str, bool.
110110
"""
111111
try:
112-
if klass == str and type(data) == bytes:
112+
if isinstance(klass, str) and isinstance(data, bytes):
113113
return self.__deserialize_bytes_to_str(data)
114114
return klass(data)
115115
except UnicodeEncodeError:

0 commit comments

Comments
 (0)