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

fix: set interpolation macro/filter titles to match the actual function name #74

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

lmossman
Copy link
Contributor

@lmossman lmossman commented Nov 19, 2024

What

I am currently working on implementing the UI changes for this issue, to add a pop-up menu listing the various interpolation variables and functions that are available to the user.

Here is what the draft implementation currently looks like for variables:
Screenshot 2024-11-19 at 10 21 37 AM

The contents of this menu come from the interpolation section of the declarative component schema.

However, there is a problem: the titles of the macros and filters in that section do not match the actual function names, and the function names don't appear anywhere else in that section. So, the UI doesn't know what text to actually insert into the input when the user selects one of these.

How

This PR solves the issue by renaming the titles to match the actual function names themselves.

The UI can then use the title to populate the list and also to insert directly into the input upon selection, just like it does with the variables.

Open Questions

  • Does this change affect any other code? As far as I can tell, only the documentation uses this part of the YAML today to populate these docs, in which case this should be a safe change as it will just cause the titles of each section to match the function names themselves.

Summary by CodeRabbit

  • New Features

    • Introduced new components for authentication, pagination, and error handling, enhancing the flexibility and robustness of data extraction.
    • Added detailed schema definitions for various components, improving clarity and usability for developers.
  • Improvements

    • Expanded error handling capabilities with new error handler definitions.
    • Enhanced pagination strategies with new options for better data management.
    • Refined existing components for improved functionality and clarity.

@lmossman lmossman changed the title set interpolation macro/filter titles to match the actual function name fix: set interpolation macro/filter titles to match the actual function name Nov 19, 2024
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in the pull request involve significant updates to the declarative_component_schema.yaml file within the Airbyte CDK. These modifications introduce numerous new definitions related to authentication, pagination, error handling, and data extraction. The schema has been enhanced with detailed descriptions and requirements for each component, improving clarity and usability for developers. Additionally, existing components have been updated to reflect these changes, resulting in a more robust framework for defining declarative sources.

Changes

File Path Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Extensive modifications, including the addition of new definitions for AsyncJobStatusMap, AsyncRetriever, JwtAuthenticator, OAuthAuthenticator, OffsetIncrement, and PageIncrement, along with updates to Spec, DeclarativeStream, RecordSelector, and RecordFilter.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant AirbyteCDK
    participant DeclarativeSchema

    Developer->>AirbyteCDK: Define new declarative source
    AirbyteCDK->>DeclarativeSchema: Validate schema
    DeclarativeSchema-->>AirbyteCDK: Return validation results
    AirbyteCDK-->>Developer: Notify of success or errors
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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: 0

🧹 Outside diff range and nitpick comments (8)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (8)

2793-2800: The now_utc macro description could be more precise.

The description could benefit from clarifying that it returns a datetime object in UTC timezone, which can be formatted using strftime. Also, should we mention that the time component includes microseconds precision? wdyt?

-      description: Returns the current date and time in the UTC timezone.
+      description: Returns the current date and time as a datetime object in UTC timezone with microseconds precision. The returned object can be formatted using strftime.

2800-2807: The today_utc macro examples could be more comprehensive.

The examples show basic usage but could be enhanced to demonstrate more date formatting options that users might need. What do you think about adding an example with different date separators?

       examples:
         - "'{{ today_utc() }}' -> '2021-09-01'"
         - "'{{ today_utc().strftime('%Y/%m/%d')}}' -> '2021/09/01'"
+        - "'{{ today_utc().strftime('%Y-%m-%d')}}' -> '2021-09-01'"
+        - "'{{ today_utc().strftime('%d-%m-%Y')}}' -> '01-09-2021'"

Line range hint 2807-2818: The timestamp macro description could be clearer about timezone handling.

The description mentions "If no timezone is specified, the string is interpreted as UTC" but doesn't explicitly state what happens with timezone-aware inputs. Should we clarify this? Also, the examples could show more timezone variations, wdyt?

       description: |
-        Converts a number or a string representing a datetime (formatted as ISO8601) to a timestamp. If the input is a number, it is converted to an int. If no timezone is specified, the string is interpreted as UTC.
+        Converts a number or a string representing a datetime (formatted as ISO8601) to a Unix timestamp (seconds since epoch). 
+        - If the input is a number, it is converted to an integer
+        - If the input is a string without timezone, it is interpreted as UTC
+        - If the input is a string with timezone, the timezone offset is applied before conversion

2818-2826: The max macro description has a typo.

There's a small typo in the description - "or or". Also, should we add examples with different data types to show type handling? wdyt?

-      description: Returns the largest object of a iterable, or or two or more arguments.
+      description: Returns the largest object of an iterable, or two or more arguments.
       examples:
         - "'{{ max(2, 3) }}' -> 3"
         - "'{{ max([2, 3]) }}' -> 3"
+        - "'{{ max('a', 'b', 'c') }}' -> 'c'"
+        - "'{{ max([1.5, 2.1, 0.3]) }}' -> 2.1"

Line range hint 2826-2836: The day_delta macro has inconsistent datetime format in examples.

The examples show inconsistent datetime formats (some with 'T', some with ':'). Should we standardize them for clarity? Also, the description could mention the default format when none is specified.

       examples:
-        - "'{{ day_delta(1) }}' -> '2021-09-02T00:00:00.000000+0000'"
-        - "'{{ day_delta(-1) }}' -> '2021-08-31:00:00.000000+0000'"
+        - "'{{ day_delta(1) }}' -> '2021-09-02T00:00:00.000000+0000'"
+        - "'{{ day_delta(-1) }}' -> '2021-08-31T00:00:00.000000+0000'"
         - "'{{ day_delta(25, format='%Y-%m-%d') }}' -> '2021-09-02'"

Line range hint 2836-2845: The duration macro has a typo in description.

There's a typo in "duratioin". Also, should we add more examples with different duration components? wdyt?

-      description: Converts an ISO8601 duratioin to datetime.timedelta.
+      description: Converts an ISO8601 duration to datetime.timedelta.
       examples:
         - "'{{ duration('P1D') }}' -> '1 day, 0:00:00'"
         - "'{{ duration('P6DT23H') }}' -> '6 days, 23:00:00'"
         - "'{{ (now_utc() - duration('P1D')).strftime('%Y-%m-%dT%H:%M:%SZ') }}' -> '2021-08-31T00:00:00Z'"
+        - "'{{ duration('PT1H30M') }}' -> '0 days, 1:30:00'"
+        - "'{{ duration('P1Y2M') }}' -> '428 days, 0:00:00'"

Line range hint 2857-2867: The hash filter could use more hash type examples.

The description mentions "Valid hash type" but doesn't list the supported types. Should we add examples with other common hash types like SHA-256? wdyt?

       examples:
         - "{{ 'Test client_secret' | hash() }} -> '3032d57a12f76b61a820e47b9a5a0cbb'"
         - "{{ 'Test client_secret' | hash('md5') }} -> '3032d57a12f76b61a820e47b9a5a0cbb'"
         - "{{ 'Test client_secret' | hash('md5', salt='salt') }} -> '5011a0168579c2d94cbbe1c6ad14327c'"
+        - "{{ 'Test client_secret' | hash('sha256') }} -> 'a88c23aa6a5e46d72bc6c5a737a848f3ca15c236872d5b05de47c784cf3aeb41'"

Line range hint 2879-2892: The string and regex_search filters could use more examples.

These filters might benefit from more diverse examples showing edge cases. For instance, string could show handling of special characters, and regex_search could demonstrate more complex patterns. What do you think?

       examples:
         - '{{ 1 | string }} -> "1"'
         - '{{ ["hello", "world" | string }} -> "["hello", "world"]"'
+        - '{{ None | string }} -> "None"'
+        - '{{ true | string }} -> "True"'

       examples:
         - '{{ "goodbye, cruel world" | regex_search("goodbye,\s(.*)$") }} -> "cruel world"'
+        - '{{ "[email protected]" | regex_search("(.+)@.+") }} -> "user"'
+        - '{{ "ID: 12345" | regex_search("ID:\s*(\d+)") }} -> "12345"'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 19afe5a and cabf557.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (6 hunks)

@github-actions github-actions bot added bug Something isn't working security labels Nov 19, 2024
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

🧹 Outside diff range and nitpick comments (1)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

Line range hint 2857-2886: The filter titles now correctly match their function names. Would you consider adding more examples?

The documentation looks great! To make it even more helpful for users, what do you think about adding examples for edge cases? For instance:

  • For hash: Example with different hash types (sha256, etc.)
  • For base64encode: Example with special characters
  • For regex_search: Example with multiple capture groups
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cabf557 and 420eba9.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (5 hunks)
🔇 Additional comments (2)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2)

Line range hint 2793-2845: LGTM! The macro titles now match their function names.

The documentation for each macro is well-structured with clear descriptions, arguments, return types, and helpful examples. This aligns perfectly with the PR objective of making titles match the actual function names.


Line range hint 2793-2886: Verify the usage of these macros and filters in the codebase

Let's ensure these changes don't affect existing usage patterns.

Copy link
Contributor

@aaronsteers aaronsteers left a comment

Choose a reason for hiding this comment

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

Approved for my part - based on my review of the code changes and the PR description explaining the input. Since I'm not deep on this part of the codebase, you may opt to wait for another pair of eyes. Your call, but to me it looks good. 🚀

@natikgadzhi
Copy link
Contributor

Happy to merge as is, but what's up with Chargebee here?

@lmossman
Copy link
Contributor Author

@natikgadzhi No idea - my PR did not touch it

@natikgadzhi
Copy link
Contributor

@lmossman good to merge — @maxi297 works on chargebee problem separately.

@aaronsteers @ChristoGrab we ready to merge and ship the CDK version? Will release work and publish to pypi, and publish SDM alongside it? ;)

@maxi297
Copy link
Contributor

maxi297 commented Nov 20, 2024

For chargebee, the fixes will be available on airbytehq/airbyte#48510 so that's fine

@lmossman lmossman merged commit a2aef16 into main Nov 20, 2024
23 of 24 checks passed
@lmossman lmossman deleted the lmossman/fix-interpolation-titles branch November 20, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants