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

⚡️ Speed up method StreamAvailabilityStrategy.check_availability by 12% in PR #45673 (async-job-salesforce/cdk-release) #45684

Open
wants to merge 1 commit into
base: async-job-salesforce/cdk-release
Choose a base branch
from

Conversation

codeflash-ai[bot]
Copy link

@codeflash-ai codeflash-ai bot commented Sep 19, 2024

⚡️ This pull request contains optimizations for PR #45673

If you approve this dependent PR, these changes will be merged into the original PR branch async-job-salesforce/cdk-release.

This PR will be automatically closed if the original PR is merged.


📄 StreamAvailabilityStrategy.check_availability() in airbyte-cdk/python/airbyte_cdk/sources/streams/concurrent/adapters.py

📈 Performance improved by 12% (0.12x faster)

⏱️ Runtime went down from 30.6 microseconds to 27.2 microseconds

Explanation and details

List of Optimizations.

Correctness verification

The new optimized code was tested for correctness. The results are listed below.

✅ 1 Passed − ⚙️ Existing Unit Tests

(click to show existing tests)
- sources/streams/concurrent/test_adapters.py

✅ 0 Passed − 🌀 Generated Regression Tests

(click to show generated tests)
# imports
# function to test
import logging
from abc import ABC, abstractmethod
from typing import Any, Optional
from unittest.mock import Mock

import pytest  # used for our unit tests
from airbyte_cdk.sources import Source
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.concurrent.adapters import \
    StreamAvailabilityStrategy
from airbyte_cdk.sources.streams.concurrent.availability_strategy import \
    AbstractAvailabilityStrategy

# unit tests

# Mock classes for testing
class MockStream(Stream):
    def __init__(self, check_availability=None, get_error_display_message=None):
        self._check_availability = check_availability
        self._get_error_display_message = get_error_display_message
        # Outputs were verified to be equal to the original implementation

    def check_availability(self, logger, source):
        if self._check_availability:
            return self._check_availability(logger, source)
        raise NotImplementedError
        # Outputs were verified to be equal to the original implementation

    def get_error_display_message(self, exception):
        if self._get_error_display_message:
            return self._get_error_display_message(exception)
        return None
        # Outputs were verified to be equal to the original implementation

class MockSource(Source):
    pass

class MockLogger(logging.Logger):
    def __init__(self):
        super().__init__("mock_logger")
        # Outputs were verified to be equal to the original implementation

# Basic Test Cases











🔘 (none found) − ⏪ Replay Tests

… 12% in PR #45673 (`async-job-salesforce/cdk-release`)

### List of Optimizations.
@codeflash-ai codeflash-ai bot added the ⚡️ codeflash Optimization PR opened by Codeflash AI label Sep 19, 2024
Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Sep 19, 2024 6:05pm

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@octavia-squidington-iii octavia-squidington-iii added CDK Connector Development Kit community labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit ⚡️ codeflash Optimization PR opened by Codeflash AI community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants