-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] Metadata: Remove leading underscore (#29024)
* DNC * Add test models * Add model test * Remove underscore from metadata files * Regenerate models * Add test to check for key transformation * Allow additional fields on metadata * Delete transform
- Loading branch information
Showing
376 changed files
with
1,671 additions
and
1,545 deletions.
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
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
62 changes: 62 additions & 0 deletions
62
airbyte-ci/connectors/metadata_service/lib/metadata_service/models/transform.py
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import json | ||
from pydantic import BaseModel | ||
|
||
def _apply_default_pydantic_kwargs(kwargs: dict) -> dict: | ||
"""A helper function to apply default kwargs to pydantic models. | ||
Args: | ||
kwargs (dict): the kwargs to apply | ||
Returns: | ||
dict: the kwargs with defaults applied | ||
""" | ||
default_kwargs = { | ||
"by_alias": True, # Ensure that the original field name from the jsonschema is used in the event it begins with an underscore (e.g. ab_internal) | ||
"exclude_none": True, # Exclude fields that are None | ||
} | ||
|
||
return {**default_kwargs, **kwargs} | ||
|
||
def to_json_sanitized_dict(pydantic_model_obj: BaseModel, **kwargs) -> dict: | ||
"""A helper function to convert a pydantic model to a sanitized dict. | ||
Without this pydantic dictionary may contain values that are not JSON serializable. | ||
Args: | ||
pydantic_model_obj (BaseModel): a pydantic model | ||
Returns: | ||
dict: a sanitized dictionary | ||
""" | ||
|
||
return json.loads(to_json(pydantic_model_obj, **kwargs)) | ||
|
||
def to_json(pydantic_model_obj: BaseModel, **kwargs) -> str: | ||
"""A helper function to convert a pydantic model to a json string. | ||
Without this pydantic dictionary may contain values that are not JSON serializable. | ||
Args: | ||
pydantic_model_obj (BaseModel): a pydantic model | ||
Returns: | ||
str: a json string | ||
""" | ||
kwargs = _apply_default_pydantic_kwargs(kwargs) | ||
|
||
return pydantic_model_obj.json(**kwargs) | ||
|
||
def to_dict(pydantic_model_obj: BaseModel, **kwargs) -> dict: | ||
"""A helper function to convert a pydantic model to a dict. | ||
Without this pydantic dictionary may contain values that are not JSON serializable. | ||
Args: | ||
pydantic_model_obj (BaseModel): a pydantic model | ||
Returns: | ||
dict: a dict | ||
""" | ||
kwargs = _apply_default_pydantic_kwargs(kwargs) | ||
|
||
return pydantic_model_obj.dict(**kwargs) |
22 changes: 0 additions & 22 deletions
22
airbyte-ci/connectors/metadata_service/lib/metadata_service/utils.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.