-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Implements JSON-string connection representation generator #35723
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
from airflow.models.xcom_arg import XComArg | ||
from airflow.operators.empty import EmptyOperator | ||
from airflow.operators.python import PythonOperator | ||
from airflow.serialization.enums import DagAttributeTypes as DAT | ||
from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding | ||
from airflow.serialization.pydantic.dag import DagModelPydantic | ||
from airflow.serialization.pydantic.dag_run import DagRunPydantic | ||
from airflow.serialization.pydantic.job import JobPydantic | ||
|
@@ -213,6 +213,27 @@ def test_serialize_deserialize(input, encoded_type, cmp_func): | |
json.dumps(serialized) # does not raise | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"conn_uri", | ||
[ | ||
pytest.param("aws://", id="only-conn-type"), | ||
pytest.param("postgres://username:[email protected]:5432/the_database", id="all-non-extra"), | ||
pytest.param( | ||
"///?__extra__=%7B%22foo%22%3A+%22bar%22%2C+%22answer%22%3A+42%2C+%22" | ||
"nullable%22%3A+null%2C+%22empty%22%3A+%22%22%2C+%22zero%22%3A+0%7D", | ||
id="extra", | ||
), | ||
], | ||
) | ||
def test_backcompat_deserialize_connection(conn_uri): | ||
"""Test deserialize connection which serialised by previous serializer implementation.""" | ||
from airflow.serialization.serialized_objects import BaseSerialization | ||
|
||
conn_obj = {Encoding.TYPE: DAT.CONNECTION, Encoding.VAR: {"conn_id": "TEST_ID", "uri": conn_uri}} | ||
deserialized = BaseSerialization.deserialize(conn_obj) | ||
assert deserialized.get_uri() == conn_uri | ||
|
||
|
||
@pytest.mark.skipif(not _ENABLE_AIP_44, reason="AIP-44 is disabled") | ||
@pytest.mark.parametrize( | ||
"input, pydantic_class, encoded_type, cmp_func", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't that going to be backwards incompatible for older connections?
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.
It should be backward compatible.
If connection serialized by previous version, it should be deserialized by new one. I've also add test for that check.
I'm also not sure that we ever serialize connection in Airflow.
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.
Previous version serialize conn_id, description and uri new one every field except uri.
So this is basically two existed ways to create connection from constructor.