Skip to content

Commit 29ae4fc

Browse files
authored
Chore: AutoFix formatting and update slash commands (#13)
1 parent dd3084d commit 29ae4fc

File tree

79 files changed

+1491
-1620
lines changed

Some content is hidden

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

79 files changed

+1491
-1620
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: On-Demand PR Auto-Fix
1+
name: On-Demand AutoFix
22

33
on:
44
workflow_dispatch:

.github/workflows/python_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ jobs:
8282
files: "airbyte_cdk/**/*.py"
8383
- name: Run mypy on changed files
8484
if: steps.changed-py-files.outputs.any_changed == 'true'
85-
run: mypy ${{ steps.changed-py-files.outputs.all_changed_files }} --config-file mypy.ini --install-types --non-interactive
85+
run: poetry run mypy ${{ steps.changed-py-files.outputs.all_changed_files }} --config-file mypy.ini --install-types --non-interactive

.github/workflows/slash_command_dispatch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
dispatch-type: workflow
2121
issue-type: pull-request
2222
commands: |
23-
fix-pr
24-
test-pr
23+
autofix
24+
test
2525
poetry-lock
2626
static-args: |
2727
pr=${{ github.event.issue.number }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: On-Demand PR Test
1+
name: On-Demand Test
22

33
on:
44
workflow_dispatch:

airbyte_cdk/connector.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ def check(self, logger: logging.Logger, config: TConfig) -> AirbyteConnectionSta
9696

9797
class _WriteConfigProtocol(Protocol):
9898
@staticmethod
99-
def write_config(config: Mapping[str, Any], config_path: str) -> None:
100-
...
99+
def write_config(config: Mapping[str, Any], config_path: str) -> None: ...
101100

102101

103102
class DefaultConnectorMixin:
@@ -108,5 +107,4 @@ def configure(self: _WriteConfigProtocol, config: Mapping[str, Any], temp_dir: s
108107
return config
109108

110109

111-
class Connector(DefaultConnectorMixin, BaseConnector[Mapping[str, Any]], ABC):
112-
...
110+
class Connector(DefaultConnectorMixin, BaseConnector[Mapping[str, Any]], ABC): ...

airbyte_cdk/connector_builder/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def handle_request(args: List[str]) -> str:
7474
command, config, catalog, state = get_config_and_catalog_from_args(args)
7575
limits = get_limits(config)
7676
source = create_source(config, limits)
77-
return orjson.dumps(AirbyteMessageSerializer.dump(handle_connector_builder_request(source, command, config, catalog, state, limits))).decode() # type: ignore[no-any-return] # Serializer.dump() always returns AirbyteMessage
77+
return orjson.dumps(
78+
AirbyteMessageSerializer.dump(handle_connector_builder_request(source, command, config, catalog, state, limits))
79+
).decode() # type: ignore[no-any-return] # Serializer.dump() always returns AirbyteMessage
7880

7981

8082
if __name__ == "__main__":

airbyte_cdk/destinations/destination.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def parse_args(self, args: List[str]) -> argparse.Namespace:
8585
return parsed_args
8686

8787
def run_cmd(self, parsed_args: argparse.Namespace) -> Iterable[AirbyteMessage]:
88-
8988
cmd = parsed_args.command
9089
if cmd not in self.VALID_CMDS:
9190
raise Exception(f"Unrecognized command: {cmd}")

airbyte_cdk/destinations/vector_db_based/embedder.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,19 @@ def __init__(self, config: OpenAIEmbeddingConfigModel, chunk_size: int):
109109
class AzureOpenAIEmbedder(BaseOpenAIEmbedder):
110110
def __init__(self, config: AzureOpenAIEmbeddingConfigModel, chunk_size: int):
111111
# Azure OpenAI API has — as of 20230927 — a limit of 16 documents per request
112-
super().__init__(OpenAIEmbeddings(openai_api_key=config.openai_key, chunk_size=16, max_retries=15, openai_api_type="azure", openai_api_version="2023-05-15", openai_api_base=config.api_base, deployment=config.deployment, disallowed_special=()), chunk_size) # type: ignore
112+
super().__init__(
113+
OpenAIEmbeddings(
114+
openai_api_key=config.openai_key,
115+
chunk_size=16,
116+
max_retries=15,
117+
openai_api_type="azure",
118+
openai_api_version="2023-05-15",
119+
openai_api_base=config.api_base,
120+
deployment=config.deployment,
121+
disallowed_special=(),
122+
),
123+
chunk_size,
124+
) # type: ignore
113125

114126

115127
COHERE_VECTOR_SIZE = 1024
@@ -167,7 +179,13 @@ def __init__(self, config: OpenAICompatibleEmbeddingConfigModel):
167179
self.config = config
168180
# Client is set internally
169181
# Always set an API key even if there is none defined in the config because the validator will fail otherwise. Embedding APIs that don't require an API key don't fail if one is provided, so this is not breaking usage.
170-
self.embeddings = LocalAIEmbeddings(model=config.model_name, openai_api_key=config.api_key or "dummy-api-key", openai_api_base=config.base_url, max_retries=15, disallowed_special=()) # type: ignore
182+
self.embeddings = LocalAIEmbeddings(
183+
model=config.model_name,
184+
openai_api_key=config.api_key or "dummy-api-key",
185+
openai_api_base=config.base_url,
186+
max_retries=15,
187+
disallowed_special=(),
188+
) # type: ignore
171189

172190
def check(self) -> Optional[str]:
173191
deployment_mode = os.environ.get("DEPLOYMENT_MODE", "")
@@ -254,7 +272,6 @@ def create_from_config(
254272
],
255273
processing_config: ProcessingConfigModel,
256274
) -> Embedder:
257-
258275
if embedding_config.mode == "azure_openai" or embedding_config.mode == "openai":
259276
return cast(Embedder, embedder_map[embedding_config.mode](embedding_config, processing_config.chunk_size))
260277
else:

airbyte_cdk/models/airbyte_protocol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class AirbyteGlobalState:
6262
class AirbyteStateMessage:
6363
type: Optional[AirbyteStateType] = None # type: ignore [name-defined]
6464
stream: Optional[AirbyteStreamState] = None
65-
global_: Annotated[
66-
AirbyteGlobalState | None, Alias("global")
67-
] = None # "global" is a reserved keyword in python ⇒ Alias is used for (de-)serialization
65+
global_: Annotated[AirbyteGlobalState | None, Alias("global")] = (
66+
None # "global" is a reserved keyword in python ⇒ Alias is used for (de-)serialization
67+
)
6868
data: Optional[Dict[str, Any]] = None
6969
sourceStats: Optional[AirbyteStateStats] = None # type: ignore [name-defined]
7070
destinationStats: Optional[AirbyteStateStats] = None # type: ignore [name-defined]

airbyte_cdk/sources/connector_state_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def _extract_from_state_message(
113113
else:
114114
streams = {
115115
HashableStreamDescriptor(
116-
name=per_stream_state.stream.stream_descriptor.name, namespace=per_stream_state.stream.stream_descriptor.namespace # type: ignore[union-attr] # stream has stream_descriptor
116+
name=per_stream_state.stream.stream_descriptor.name,
117+
namespace=per_stream_state.stream.stream_descriptor.namespace, # type: ignore[union-attr] # stream has stream_descriptor
117118
): per_stream_state.stream.stream_state # type: ignore[union-attr] # stream has stream_state
118119
for per_stream_state in state
119120
if per_stream_state.type == AirbyteStateType.STREAM and hasattr(per_stream_state, "stream") # type: ignore # state is always a list of AirbyteStateMessage if is_per_stream is True

0 commit comments

Comments
 (0)