-
Notifications
You must be signed in to change notification settings - Fork 4.5k
🐙 octavia-cli: apply
connections
#10881
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
Conversation
self.source_id, | ||
self.destination_id, | ||
self.status, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor but add all param names when call the function
namespace_format=self.namespace_format, | ||
prefix=self.prefix, | ||
operations_ids=self.operation_ids, | ||
sync_catalog=self.sync_catalog, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you waiting to receive the sync catalog or is it possible to send a dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure yet, I'd like to test with a generated config to check if the API client is flexible enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM if works with the simple call to the API is done, if not need to review again.
@@ -414,13 +494,15 @@ def factory(api_client: airbyte_api_client.ApiClient, workspace_id: str, configu | |||
NotImplementedError: Raised if the definition type found in the YAML is not a supported resource. | |||
|
|||
Returns: | |||
Union[Source, Destination]: The resource object created from the YAML config. | |||
Union[Source, Destination, Connection]: The resource object created from the YAML config. | |||
""" | |||
with open(configuration_path, "r") as f: | |||
local_configuration = yaml.load(f, yaml.FullLoader) | |||
if local_configuration["definition_type"] == "source": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if local_configuration["definition_type"] == "source": | |
if local_configuration["definition_type"] == DEFINITION_TYPE.source: |
wdyt creating a enum class for definitions? I think there is other places to be used.
only small suggestion though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a future improvement we could make for this file but also in octavia_cli/generate/definitions.py
def _get_comparable_configuration( | ||
self, | ||
): # pragma: no cover | ||
if not self.was_created: | ||
raise NonExistingResourceError("Can't find a comparable configuration as the remote resource does not exists.") | ||
else: | ||
return copy.deepcopy(self.remote_resource) | ||
|
||
@property | ||
def was_created(self): | ||
return True if self.remote_resource else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw other places where the self.was_created is invoked and throw errors. What do you think doing this directly in the was_created
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean raising the error in was_created
? I'd like to use was_created
as a boolean to know if the resource was created or not, I don't want it to throw an error if the resource was not created but simply return false
. But maybe you meant running copy.deepcopy(self.remote_resource)
in was_created
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only the error handling in the was_created
because is also invoked in connection generation command too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe implement something like self.remote_resource.raise_if_not_created()
?
CHECK_RETURN_TYPE = True | ||
APPLY_PRIORITY = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add comments about what those two variables are used for?
def _get_comparable_configuration(self): | ||
"""Get the object to which local configuration will be compared to. | ||
|
||
Returns: | ||
dict: Remote source configuration. | ||
""" | ||
comparable_configuration = super()._get_comparable_configuration() | ||
return comparable_configuration.connection_configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be done in BaseResource and only be overwritten by Connection object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I duplicated this on purpose as this is really specific to source and destination and not something common to the other potential resources. I was thinking of adding a parent class for Source
and Destination
(SourceOrDestination(BaseResource)
🤔 ) but thought it was too much for this PR.
prefix=self.configuration["prefix"], | ||
schedule=self.configuration["schedule"], | ||
resource_requirements=self.configuration["resourceRequirements"], | ||
_check_type=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_check_type=False, | |
_check_type=self.CHECK_RETURN_TYPE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_check_type=False
:We disable the validation of type at model instanciation.
_check_return_type=False
:We disable the validation of type of the API response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a bit of refacto to make it a bit more readable: 6ec2dd4
""" | ||
comparable_configuration = super()._get_comparable_configuration() | ||
comparable_configuration.pop("connectionId") | ||
comparable_configuration.pop("operationIds") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today octavia-cli can't work with normalization right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I remove the operationIds
in case the user change the transformation in the UI, so we exclude operationIds from the diff computation.
What
We want to be able to apply YAML configuration for connections.
How
Create
Connection
resource inheriting fromBaseResource
.The factory will do its magic, no edit should be required in
command.py