Skip to content

feat(cdk): handle include_files from configured catalog #512

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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

aldogonzalez8
Copy link
Contributor

@aldogonzalez8 aldogonzalez8 commented Apr 26, 2025

What

There is a scenario where the user may not want to include files from a file stream, so they will only get metadata. We were not handling this.

How

Read value from the stream configured catalog and check the include_files value, if false/none use NoopWriter, if true, it is fine to use the FileSystemWriter.

This only happens for read operations.

Summary by CodeRabbit

  • New Features
    • Added support for controlling file inclusion during uploads based on stream configuration.
  • Bug Fixes
    • Improved file upload handling to respect stream-level file inclusion settings.
  • Tests
    • Expanded test coverage for file upload scenarios, covering different file inclusion flags and message emission behaviors.
@aldogonzalez8 aldogonzalez8 self-assigned this Apr 26, 2025
@github-actions github-actions bot added the enhancement New feature or request label Apr 26, 2025
@aldogonzalez8 aldogonzalez8 requested a review from maxi297 April 27, 2025 15:43
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally, it seems good. I have one design concern. Let me know what you think

@@ -229,7 +230,9 @@ def connection_checker(self) -> ConnectionChecker:
f"Expected to generate a ConnectionChecker component, but received {check_stream.__class__}"
)

def streams(self, config: Mapping[str, Any]) -> List[Stream]:
def streams(
self, config: Mapping[str, Any], catalog: Optional[ConfiguredAirbyteCatalog] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit ambivalent on modifying this interface because now, it does not align with the parent interface so it seems like we are breaking compatibility and it'll be hard to maintain with doing isinstance before calling which means that we will lose most of the benefits of inheritance.

Could we pass the catalog at ModelToComponentFactory.__init__ as a mandatory field? It seems like we are already passing the information here. This would avoid the interface problem, the problem of managing an optional catalog and the problem of passing include_files through kwargs. We might want to do it here too if it's not too much trouble.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense in order to keep the signature of the interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied changes to pass it through ModelToComponentFactory.init

Base automatically changed from ac8/file-api/connector-builder-support-3 to main April 28, 2025 20:36
Copy link
Contributor

coderabbitai bot commented Apr 28, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new mechanism for handling file uploads in Airbyte's declarative sources by making the file uploader behavior conditional based on a new include_files flag in the stream configuration. The constructors of ManifestDeclarativeSource and ConcurrentDeclarativeSource are updated to pass the catalog to the component factory, which now uses this catalog to determine whether files should be included for each stream. The file uploader logic in ModelToComponentFactory is enhanced to respect this flag, using a no-operation writer when file inclusion is disabled. Comprehensive tests are added and updated to verify the new behaviors.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/concurrent_declarative_source.py Updated the ConcurrentDeclarativeSource constructor to pass the catalog argument to the ModelToComponentFactory during instantiation, allowing the factory to access the catalog for component creation. No changes to the constructor signature or other logic.
airbyte_cdk/sources/declarative/manifest_declarative_source.py Added an optional catalog parameter to the ManifestDeclarativeSource constructor and ensured it is passed to the ModelToComponentFactory if a custom factory is not provided. No other logic or control flow was changed.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Enhanced ModelToComponentFactory to accept a catalog parameter, build a stream name-to-stream mapping, and determine the include_files flag for each stream. Updated the file uploader creation logic to use this flag, selecting between a no-operation writer and a local file writer accordingly. Added methods for catalog lookup and flag retrieval. Updated method signatures to accommodate the new parameter and logic.
airbyte_cdk/test/catalog_builder.py Added a with_include_files method to ConfiguredAirbyteStreamBuilder to set the include_files flag in the stream configuration for testing purposes.
unit_tests/sources/declarative/file/test_file_stream.py Expanded and refactored the test suite for file stream handling. Added new tests to cover scenarios with include_files set to True, False, or omitted, and when emit_connector_builder_messages is enabled. Enhanced mocking and assertions to verify correct file writer usage and file reference metadata in all cases. Split and renamed existing tests for clarity and coverage.

Sequence Diagram(s)

sequenceDiagram
    participant Source as DeclarativeSource
    participant Factory as ModelToComponentFactory
    participant Catalog as ConfiguredAirbyteCatalog
    participant Stream as DeclarativeStream
    participant Uploader as FileUploader

    Source->>Factory: Instantiate with catalog
    Factory->>Catalog: Build stream name-to-stream mapping
    Source->>Factory: create_declarative_stream(stream_model, config)
    Factory->>Catalog: Lookup include_files for stream
    Factory->>Uploader: create_file_uploader(include_files)
    Uploader-->>Stream: Use NoopFileWriter if include_files is False, else LocalFileSystemFileWriter
    Stream-->>Source: Stream reads with correct file writer behavior
Loading

Would you like me to generate a more detailed sequence diagram focusing on the file uploader selection logic or a comparison of old vs new flows? Wdyt?

Possibly related PRs

  • feat(cdk): connector builder support for file uploader #503: The main PR extends ModelToComponentFactory to accept a catalog and conditionally disables local file writing based on an include_files flag, while the retrieved PR modifies ModelToComponentFactory's create_file_uploader method to wrap the uploader with ConnectorBuilderFileUploader when emit_connector_builder_messages is true, focusing on connector builder message support; both modify the same class and method related to file uploader creation but address different concerns, making their changes related at the code level.

Suggested reviewers

  • maxi297

Does this updated summary and structure look good to you? Would you like me to help draft any additional documentation or usage examples for the new include_files flag?


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2693d2 and c914bbd.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Analyze (python)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
unit_tests/sources/declarative/file/test_file_stream.py (1)

180-216: 💡 Verification agent

🧩 Analysis chain

Real file writes can leave artefacts on the test runner

test_get_article_attachments_and_file_is_uploaded exercises the real LocalFileSystemFileWriter and then checks Path(file_reference.staging_file_url).exists().
While this gives strong end-to-end confidence, it also:

  • creates files under /tmp/airbyte-file-transfer which may persist between test runs, pollute CI caches, or collide when tests run in parallel;
  • depends on the executing user having write permission to that location.

Could we isolate the side-effect? Two options:

-with HttpMocker() as http_mocker:
+with tempfile.TemporaryDirectory() as tmpdir, HttpMocker() as http_mocker, \
+     patch("airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.STAGING_DIR", tmpdir):

or mock the writer altogether and assert that the intended path would be created, avoiding disk I/O:

-with HttpMocker() as http_mocker:
+with HttpMocker() as http_mocker, \
+     patch("airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write") as mock_write:
+    mock_write.return_value = 12345

This keeps the test hermetic while preserving its behavioural check—what do you think?


#!/usr/bin/env bash
set -e

echo "Searching for LocalFileSystemFileWriter definition..."
rg "class LocalFileSystemFileWriter" -n .

echo
echo "Searching for STAGING_DIR constant..."
rg "STAGING_DIR" -n .

#!/usr/bin/env bash
set -e
# Locate the LocalFileSystemFileWriter implementation
rg "class LocalFileSystemFileWriter" -n .
# Locate the STAGING_DIR constant
rg "STAGING_DIR" -n .

Could we verify the locations of LocalFileSystemFileWriter and the STAGING_DIR constant to ensure our patch targets are correct? wdyt?


🏁 Script executed:

#!/usr/bin/env bash
set -e

echo "🔍 Searching for LocalFileSystemFileWriter definition..."
rg "class LocalFileSystemFileWriter" -n .

echo
echo "🔍 Searching for STAGING_DIR constant..."
rg "STAGING_DIR" -n .

Length of output: 757


Let’s peek inside the writer to see how it references the staging directory—so we can patch the right constant. wdyt?

#!/usr/bin/env bash
set -e
echo "📄 Showing the first 200 lines of LocalFileSystemFileWriter:"
sed -n '1,200p' airbyte_cdk/sources/declarative/retrievers/file_uploader/local_file_system_file_writer.py

Could we peek at how the writer picks its staging directory so we can patch the right constant or env var? wdyt?

#!/usr/bin/env bash
set -e
sed -n '1,200p' airbyte_cdk/sources/declarative/retrievers/file_uploader/local_file_system_file_writer.py

Could we inspect how the writer pulls in the staging directory constant so we know exactly what to patch? wdyt?

#!/usr/bin/env bash
set -e

echo "🔍 Looking for AIRBYTE_STAGING_DIRECTORY usage in LocalFileSystemFileWriter..."
rg "AIRBYTE_STAGING_DIRECTORY" -n airbyte_cdk/sources/declarative/retrievers/file_uploader/local_file_system_file_writer.py || true

echo
echo "🔍 Searching for any staging-dir imports or references..."
rg "files_directory" -n airbyte_cdk/sources/declarative/retrievers/file_uploader/local_file_system_file_writer.py || true

Isolate filesystem side-effects in this test

Real LocalFileSystemFileWriter writes to the default staging dir (/staging/files or /tmp/airbyte-file-transfer), which can leave artifacts, collide under parallel CI, or require extra permissions. How about we make the test hermetic by either:

• Overriding the staging directory constant to a temp folder:

-with HttpMocker() as http_mocker:
+with tempfile.TemporaryDirectory() as tmpdir, HttpMocker() as http_mocker, \
+     patch("airbyte_cdk.sources.utils.files_directory.AIRBYTE_STAGING_DIRECTORY", tmpdir):

• Or mocking the writer’s disk I/O entirely:

-with HttpMocker() as http_mocker:
+with HttpMocker() as http_mocker, \
+     patch("airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write") as mock_write:
+    mock_write.return_value = 12345

This keeps the behavioral check (we still assert on file_reference) without touching the real filesystem. Wdyt?

🧹 Nitpick comments (2)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1)

3859-3861: Integration with stream creation process

These lines integrate the include_files logic into the file uploader creation during stream setup. The changes respect the PR's goal of controlling file inclusion based on stream configuration.

Could this be extended in the future to handle other per-stream configuration settings using a similar pattern? Wdyt?

unit_tests/sources/declarative/file/test_file_stream.py (1)

217-276: Heavy duplication—parameterise to keep tests tidy?

test_get_article_attachments_with_filename_extractor (and several siblings) repeat ~40 lines of HTTP stubbing, patch set-ups, and catalog construction that differ only by include_files and expectation flags. That repetition:

  • inflates the file to ~500 lines, making maintenance harder;
  • risks divergence when one test is updated but its twins are not.

Would a parameterised test using pytest.mark.parametrize (or a helper fixture if you must stay in unittest) reduce noise? Sketch:

@parameterized.expand([
    (True, True),   # include_files, expect_fs_writer
    (False, False), # ...
])
def test_article_attachments_writer_selection(self, include_files, expect_fs_writer):
    # shared arrange ...
    with patch(...) as fs_write, patch(...) as noop_write:
        ...
        catalog = CatalogBuilder().with_stream(
            ConfiguredAirbyteStreamBuilder()
            .with_name("article_attachments")
            .with_include_files(include_files)
        ).build()
        output = read(self._config(), catalog, yaml_file=...)
        self.assertEqual(bool(fs_write.called), expect_fs_writer)
        self.assertEqual(bool(noop_write.called), not expect_fs_writer)

Fewer lines, one place to update—wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a5dee2 and 5fb3f0f.

📒 Files selected for processing (5)
  • airbyte_cdk/sources/declarative/concurrent_declarative_source.py (1 hunks)
  • airbyte_cdk/sources/declarative/manifest_declarative_source.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (7 hunks)
  • airbyte_cdk/test/catalog_builder.py (1 hunks)
  • unit_tests/sources/declarative/file/test_file_stream.py (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
airbyte_cdk/sources/declarative/concurrent_declarative_source.py (2)
airbyte_cdk/test/entrypoint_wrapper.py (1)
  • catalog (113-117)
unit_tests/sources/test_source.py (1)
  • catalog (70-93)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (2)
unit_tests/sources/test_source.py (3)
  • catalog (70-93)
  • streams (58-61)
  • streams (148-150)
airbyte_cdk/sources/declarative/declarative_stream.py (2)
  • name (93-97)
  • name (100-102)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)
🔇 Additional comments (8)
airbyte_cdk/test/catalog_builder.py (1)

44-50: Nice addition of the with_include_files method!

This method clearly follows the existing builder pattern and has good documentation. It will support the new feature for handling file inclusion preferences, making it easy to construct test catalogs with the include_files flag set.

airbyte_cdk/sources/declarative/concurrent_declarative_source.py (1)

91-91: LGTM! Catalog parameter is now properly forwarded.

The change ensures that the catalog is passed to the component factory, which allows the factory to respect stream-specific include_files flags.

airbyte_cdk/sources/declarative/manifest_declarative_source.py (2)

95-95: Good addition of the optional catalog parameter.

Making this parameter optional preserves backward compatibility while adding support for the new feature. This aligns with the related change in ConcurrentDeclarativeSource.


122-122: Properly forwarding the catalog parameter to the component factory.

This ensures consistent behavior between ManifestDeclarativeSource and ConcurrentDeclarativeSource for handling file inclusion preferences.

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (4)

579-599: New catalog parameter enables stream configuration lookup

The constructor now accepts a ConfiguredAirbyteCatalog parameter and initializes a mapping from stream names to their configured streams. This sets the foundation for supporting per-stream configuration settings such as the include_files flag.


3605-3606: Added include_files parameter to the file uploader creation method

The create_file_uploader method now accepts an include_files boolean to determine whether files should be included for a stream. This nicely decouples the decision from the implementation details.


3626-3627: File writer selection now respects include_files flag

This change implements the core functionality - using a NoopWriter when include_files is false, effectively skipping file inclusion while still processing metadata. The approach maintains compatibility with the existing behavior for connector builder mode.


3719-3742: Added helper methods for catalog-aware stream configuration

The two new methods provide a clean way to:

  1. Create a lookup map from stream names to configured streams
  2. Determine whether a specific stream should include files

This encapsulates the logic nicely and keeps it maintainable. The implementation properly handles edge cases like missing streams or unspecified flags.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
unit_tests/sources/declarative/file/test_file_stream.py (1)

123-151: Good mocking approach for file writers.

The test now properly mocks both NoopFileWriter.write and LocalFileSystemFileWriter.write methods to verify that the correct writer is used based on the include_files flag. You're setting a mock file size to simulate the return value from the file system writer.

Would adding a docstring to this test method help clarify its purpose, similar to how you've documented the other test methods? Perhaps something like "Test that article attachments can be read and files are included when include_files is true"? wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fb3f0f and a0a2ea6.

📒 Files selected for processing (1)
  • unit_tests/sources/declarative/file/test_file_stream.py (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Analyze (python)
  • GitHub Check: SDM Docker Image Build
🔇 Additional comments (9)
unit_tests/sources/declarative/file/test_file_stream.py (9)

155-159: Explicit include_files flag in test configuration.

This change correctly adds the with_include_files(True) to the stream configuration, which is essential for testing the new functionality. This makes it clear that we want files to be included in this test case.


164-167: Good assertions for file writer usage.

These assertions validate that when include_files is set to True, only the FileSystemFileWriter is called while the NoopFileWriter is not used. This confirms the core functionality being tested in the PR.


180-216: LGTM! New test for actual file uploading verification.

This test specifically verifies that files are physically written to the staging directory when include_files=True, complementing the mock-based tests. The assertion for file existence is a strong verification of the functionality.


217-276: Well-structured test for filename extractor.

You've clearly separated the previously combined test logic to focus on the specific case of using a filename extractor with file inclusion enabled. The assertions verify both that the correct writer is used and that the file reference fields are properly populated.


277-327: Good test for explicit opt-out of file inclusion.

This test thoroughly verifies the behavior when include_files is explicitly set to False. The assertions confirm that in this case the NoopFileWriter is used instead of the FileSystemFileWriter, and the file size matches the NoopFileWriter's constant size.


328-373: Complete coverage with default behavior test.

Excellent test that verifies the default behavior when include_files is not specified at all. This confirms that the system treats unspecified include_files the same as explicitly setting it to False, using the NoopFileWriter as expected.


375-403: Good mocking in connector builder test.

The test now properly mocks both file writers and consistently uses NoopFileWriter's NOOP_FILE_SIZE for the file size. This is consistent with the other tests and makes the expected behavior clear.


418-422: LGTM! Consistent stream configuration in connector builder test.

Adding with_include_files(True) to the connector builder test is excellent, as it verifies that even when file inclusion is requested, the connector builder context always uses the NoopFileWriter. This ensures complete coverage of the feature behavior in all contexts.


428-431: Good assertions for connector builder behavior.

These assertions correctly verify that in the connector builder context, only the NoopFileWriter is used regardless of the include_files setting. This is important to confirm the expected behavior in this special case.

@aldogonzalez8 aldogonzalez8 requested a review from maxi297 April 30, 2025 14:28
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a small nit

@@ -583,6 +583,7 @@ def __init__(
disable_retries: bool = False,
disable_cache: bool = False,
disable_resumable_full_refresh: bool = False,
catalog: ConfiguredAirbyteCatalog = ConfiguredAirbyteCatalog(streams=[]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the default value here? Is there usage of ModelToComponent.__init__ that are public facing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't, I set it as None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we make in mandatory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say mandatory you mean something like:

class ModelToComponentFactory:
    EPOCH_DATETIME_FORMAT = "%s"

    def __init__(
        self,
        catalog: ConfiguredAirbyteCatalog, 
        ...

?

I think yes is possible, it will require us to update in different places like here for which probably we just need to pass a self.catalog that we keep.

Also, some need to update unit test that do things like something = ModelToComponentFactory(),

What are the advantages we get from doing it mandatory? Or have we observed downsides of the default approach we've doing for other fields?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever we reference catalog internally, we know it is available and properly populated so easier code to maintain and less cognitive load for the devs.

I agree unit tests are annoying to update. How widespread would be the impact?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less cognitive load for the devs.

Yes, we get confused with large context windows.

How widespread would be the impact?

Ok, probably a few places for UT

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what I see we would also need an update here that is called here where the catalog from get_config_and_catalog_from_args is optional.

The above has its own test, which will increase the impact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! As you wish. If you think this is worth, we can fix the test and move forward. Else, I'm fine with the current solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants