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

Fixed reverted PR: Choose optimal sync modes by default on UI #12770

Merged
merged 14 commits into from
May 31, 2022

Conversation

dizel852
Copy link
Contributor

What

Revert => Revert "Choose optimal sync modes by default on UI (#12411)" (#12583)

  • Fixed issue when sync modes were overrided in EditMode
  • Changed the order of available sync modes accordingly to the optimal sync mode strategy

image

Original description

Closes #9625
Set the optimal sync modes for Source and Destination by default on UI.

How

Choosing the mode by priority:

Incremental(cursor defined) => Append Dedup
Full Refresh => Overwrite
Incremental => Append
Full Refresh => Append

165590947-772872a0-8a83-4cfc-b641-cfb65fe4ea47

@dizel852 dizel852 added area/frontend area/platform issues related to the platform labels May 11, 2022
@dizel852 dizel852 marked this pull request as ready for review May 11, 2022 14:29
@dizel852 dizel852 requested a review from a team as a code owner May 11, 2022 14:29
Copy link
Contributor

@krishnaglick krishnaglick left a comment

Choose a reason for hiding this comment

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

Does seem to preserve sync settings now! 🙌

@dizel852 dizel852 self-assigned this May 12, 2022
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

I tested this by creating a new connection and editing the sync modes in the connection.

});

const supportedSyncModes = streamNode.stream.supportedSyncModes;
export const calculateInitialCatalog = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is resolving the initial schema, not necessarily calculating the initial catalog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, that also confused me.
As I understood(if we look at the comments I removed) sometimes we can get supportedSyncModes: []
That's why we need to check the edit and creation modes supportedSyncModes.
I don't know how we can get empty supportedSyncModes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an example where we get empty supportedSyncModes and we have to handle it and set FULL_REFRESH as a default value
Screenshot at Apr 20 22-31-17

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Changes 👍🏼

): SyncSchema => ({
streams: schema.streams.map<SyncSchemaStream>((apiNode, id) => {
const nodeWithId: SyncSchemaStream = { ...apiNode, id: id.toString() };
const nodeStream = verifySupportedSyncModes(nodeWithId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the only place I am still a tiny bit concerned around. This method could change the existing Sync Mode when opening a connection in edit mode, if the previously set sync mode isn't available anymore. In that case the user would see a different sync mode in the UI, than the DB actually has, and also they would not be able to save it(??) because it's still the default values of the form?

@sherifnada Is there any case were a connector (e.g. due to an update) could lose a sync mode on an existing/saved connection's stream that was earlier supported? Is this something we'd need to cater for int he UI, or should that anyway never happen?

cc @edmundito @dizel852

Copy link
Contributor

Choose a reason for hiding this comment

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

@timroes

Is there any case were a connector (e.g. due to an update) could lose a sync mode on an existing/saved connection's stream that was earlier supported?

This is not defined behavior but I can't think of a case where there would be a good reason this edge case is needed. Is it possible to explicitly throw an error if that happens, or just leave it empty so the user has to fill it in?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is nothing we anticipate happening, I'd suggest we simply leave it empty and force the user to select a new one. @dizel852 Do you think we could still change that logic not to jump to full refresh overwrite if the actual configured sync doesn't exist, but leave the select box empty and invalid and force the user to select? (And ideally also add a unit test case for that scenario :D) Thanks

Copy link
Contributor Author

@dizel852 dizel852 May 18, 2022

Choose a reason for hiding this comment

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

@timroes Yes, we can omit supportedSyncMode checking for edit mode.
But what should we verify it in creation mode?
If we will leave supportedSyncMode checking just for creation we will get a behavior:
https://www.loom.com/share/062406b7dd26417580a914ec6ffef0c6

As you can see, available sync modes rely on at least one (or default) value in 'supportedSyncMode'.

IMO One of the solutions - does not verify supportedSyncMode at all, neither in creation nor edit modes.
Do we get empty empty supportedSyncMode? - Okay, that means that our connection form is invalid since there are no available sync modes. So we just do not allow the user to create a connection.

Advantages: We don't try somehow fix the backend's response. Another question is why do we get such a response?
Disadvantages: More fixes 😅 Need to update our form validations and tests.

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dizel852 I agree with the part: that we should not try to fix a broken connector (like the end-2-end one) in the FE by overwriting it's available sync modes. I think we should simply not adjust them, and in this case not being able to create a connection with that connector. Otherwise we'd allow users to create a connection with a configuration the backend told us is invalid, which does not sound like a good idea.

Despite being more work I think we should make sure that we error the form in this case, i.e. allow for an undefined value in case there is no valid syncCode, check for that in our validation code, and make sure we're setting undefined if there's no valid configuration (either in getOptimalSyncMode or rather add another method call to calculateInitialCatalog for that.

With that said, we should still make sure our end-to-end testing connectors will not result in an invalid configuration that other connectors in practise can't end up. @sherifnada would you maybe able to take that to the connector team? Also if we change the UI here, without fixing the connectors I am not sure if we actually still can run end-to-end tests, thus it would be good if we could solve that somehow in the near future if possible :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite being more work I think we should make sure that we error the form in this case, i.e. allow for an undefined value in case there is no valid syncCode, check for that in our validation code, and make sure we're setting undefined if there's no valid configuration (either in getOptimalSyncMode or rather add another method call to calculateInitialCatalog for that.

Ok, got it. Will update the implementation. 👍

Copy link
Collaborator

@timroes timroes left a comment

Choose a reason for hiding this comment

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

I've tested it locally and looked through the code. Everything seems to be working (creation or editing) for me. I've tested with the GitHub source and postgres destination. I changed some values when creating the connection and validated that editing it, it will still be the same. I have one open question that I pinged Sherif on, that I'd like to get clarified before approving this.

@teallarson
Copy link
Contributor

teallarson commented May 18, 2022

Wondering if we want to hold off on this until this issue is resolved: #12728
It appears to be different from the bug we saw prior to resolving the previous "optimal previous sync mode" bug, but in that same area of the code.

@dizel852
Copy link
Contributor Author

dizel852 commented May 23, 2022

Finally resolved all merge conflicts 🤪 That was something...
Reminder: We agreed on our weekly sync not to change the logic regarding checking supportedSyncModes and leave it as is. At least for now. I will create an issue for that case. airbytehq/airbyte-internal-issues#637

@tealjulia If you don't mind, can we merge the PR before #12728
It's pretty hard to keep PR in sync with the master...

cc: @timroes

@teallarson
Copy link
Contributor

I'm fine with that if it's been tested locally by others! I was more just curious if there might be an interaction between the two.

@dizel852 dizel852 added area/frontend Related to the Airbyte webapp and removed area/platform issues related to the platform labels May 24, 2022
Copy link
Contributor

@teallarson teallarson left a comment

Choose a reason for hiding this comment

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

I've tested it locally and it works as expected on Connection creation and editing (tested using Github source, changed sync modes, namespace format, turned streams off, etc.). I'm not sure where we're at with the questions above for the Connectors team, and given that this form has been finicky lately, this probably deserves a second approval before merging.

@dizel852
Copy link
Contributor Author

@tealjulia agree.
@timroes the last word is yours 😄

@edmundito edmundito requested a review from timroes May 27, 2022 12:27
@github-actions github-actions bot added the area/platform issues related to the platform label May 31, 2022
Copy link
Collaborator

@timroes timroes left a comment

Choose a reason for hiding this comment

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

Code LGTM. Tested several scenarios, and it seems to work as we agreed on.

@dizel852 dizel852 merged commit ff4b789 into master May 31, 2022
@dizel852 dizel852 deleted the vlad/fixed-optimal-sync-mode-after-revert branch May 31, 2022 13:36
jscottpolevault pushed a commit to jscottpolevault/airbyte that referenced this pull request Jun 1, 2022
…ehq#12770)

* Revert "Revert "Choose optimal sync modes by default on UI (airbytehq#12411)" (airbytehq#12583)"

This reverts commit 9789ffd.

* get optimal sync mode only in creation mode

* sort sync mode options by priority

* add tests for calculateInitialCatalog

* remove duplicated tests

* fixed one-line 'if'

* move calculationInitialCatalog function to file and export it as default

* - fix merge conflicts
- fix Type

* update tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choose optimal sync modes by default on UI
6 participants