Fixes #18104 : change parse_obj and assertEquals which was deprecated (#18105)

* change deprecationwarning

* fix format python

* fix replace module

* change : java function name
This commit is contained in:
Ethan 2024-10-07 16:02:41 +09:00 committed by GitHub
parent 69318d3e67
commit 49fceb4674
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 28 additions and 28 deletions

View File

@ -49,9 +49,11 @@ class DatalakeGcsClient(DatalakeBaseClient):
if hasattr(config.securityConfig, "gcpConfig") and isinstance(
config.securityConfig.gcpConfig.projectId, MultipleProjectId
):
gcs_config.securityConfig.gcpConfig.projectId = SingleProjectId.parse_obj(
gcs_config.securityConfig.gcpConfig.projectId = (
SingleProjectId.model_validate(
gcs_config.securityConfig.gcpConfig.projectId.root[0]
)
)
if not gcs_config.securityConfig:
raise RuntimeError("GCSConfig securityConfig can't be None.")
@ -89,8 +91,8 @@ class DatalakeGcsClient(DatalakeBaseClient):
gcs_config = deepcopy(config)
if hasattr(gcs_config.securityConfig, "gcpConfig"):
gcs_config.securityConfig.gcpConfig.projectId = SingleProjectId.parse_obj(
database_name
gcs_config.securityConfig.gcpConfig.projectId = (
SingleProjectId.model_validate(database_name)
)
self._client = self.get_gcs_client(gcs_config)

View File

@ -240,7 +240,7 @@ class DatalakeSource(DatabaseServiceSource):
verbose=False,
)
content = json.loads(metadata_config_response)
metadata_entry = StorageContainerConfig.parse_obj(content)
metadata_entry = StorageContainerConfig.model_validate(content)
except ReadException:
metadata_entry = None
if self.source_config.includeTables:

View File

@ -87,7 +87,7 @@ class GcsSource(StorageServiceSource):
def create(
cls, config_dict, metadata: OpenMetadata, pipeline_name: Optional[str] = None
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
connection: GcsConnection = config.serviceConnection.root.config
if not isinstance(connection, GcsConnection):
raise InvalidSourceException(
@ -451,7 +451,7 @@ class GcsSource(StorageServiceSource):
verbose=False,
)
content = json.loads(response_object)
metadata_config = StorageContainerConfig.parse_obj(content)
metadata_config = StorageContainerConfig.model_validate(content)
return metadata_config
except ReadException:
logger.warning(

View File

@ -333,24 +333,22 @@ class OMetaCustomAttributeTest(TestCase):
for custom_property in custom_properties:
if expected_custom_property["name"] == custom_property["name"]:
actual_custom_properties.append(custom_property)
self.assertEquals(
self.assertEqual(
custom_property["name"], expected_custom_property["name"]
)
self.assertEquals(
self.assertEqual(
custom_property["description"],
expected_custom_property["description"],
)
self.assertEquals(
self.assertEqual(
custom_property.get("customPropertyConfig"),
expected_custom_property.get("customPropertyConfig"),
)
self.assertEquals(
self.assertEqual(
custom_property["propertyType"]["name"],
expected_custom_property["propertyType"]["name"],
)
self.assertEquals(
len(actual_custom_properties), len(EXPECTED_CUSTOM_PROPERTIES)
)
self.assertEqual(len(actual_custom_properties), len(EXPECTED_CUSTOM_PROPERTIES))
def test_add_custom_property_table(self):
"""

View File

@ -102,7 +102,7 @@ def test_source_config(parameters, expected, monkeypatch):
)
source = TestSuiteSource(
OpenMetadataWorkflowConfig.parse_obj(workflow_config), mock_metadata
OpenMetadataWorkflowConfig.model_validate(workflow_config), mock_metadata
)
test_cases = list(source._iter())[0].right.test_cases
assert [t.name.root for t in test_cases] == expected

View File

@ -284,7 +284,7 @@ class TestAthenaService(unittest.TestCase):
def __init__(self, methodName, test_connection) -> None:
super().__init__(methodName)
test_connection.return_value = False
self.config = OpenMetadataWorkflowConfig.parse_obj(mock_athena_config)
self.config = OpenMetadataWorkflowConfig.model_validate(mock_athena_config)
self.athena_source = AthenaSource.create(
mock_athena_config["source"],
self.config.workflowConfig.openMetadataServerConfig,

View File

@ -37,7 +37,7 @@ class TopologyContextManagerTest(TestCase):
def test_main_thread_is_set_correctly(self):
"""Asserts self.main_thread is set accordingly."""
self.assertEquals(self.manager.main_thread, MAIN_THREAD)
self.assertEqual(self.manager.main_thread, MAIN_THREAD)
def test_get_returns_correct_context(self):
"""Asserts get and get_global returns the correct context even on a different thread."""
@ -49,8 +49,8 @@ class TopologyContextManagerTest(TestCase):
self.manager.get_global().database = MOCK_DATABASE_NAME
self.assertEquals(self.manager.get().database, None)
self.assertEquals(self.manager.get_global().database, MOCK_DATABASE_NAME)
self.assertEqual(self.manager.get().database, None)
self.assertEqual(self.manager.get_global().database, MOCK_DATABASE_NAME)
def test_thread_is_created_correctly(self):
"""Asserts copy_from copies correctly the context from parent thread."""
@ -64,7 +64,7 @@ class TopologyContextManagerTest(TestCase):
self.manager.copy_from(MAIN_THREAD)
# Check we are retrieving the right thread
self.assertEquals(self.manager.get().database, MOCK_DATABASE_NAME)
self.assertEqual(self.manager.get().database, MOCK_DATABASE_NAME)
def test_pop_removes_the_correct_thread(self):
"""Asserts pop removes the correct thread and not another one."""
@ -72,10 +72,10 @@ class TopologyContextManagerTest(TestCase):
with patch("threading.get_ident", return_value=OTHER_THREAD):
self.manager.copy_from(MAIN_THREAD)
self.assertEquals(
self.assertEqual(
list(self.manager.contexts.keys()), [MAIN_THREAD, OTHER_THREAD]
)
self.manager.pop(OTHER_THREAD)
self.assertEquals(list(self.manager.contexts.keys()), [MAIN_THREAD])
self.assertEqual(list(self.manager.contexts.keys()), [MAIN_THREAD])

View File

@ -64,7 +64,7 @@ def create(
config_dict: dict,
metadata_config: OpenMetadataConnection
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)
@ -79,7 +79,7 @@ def create(
metadata_config: OpenMetadataConnection,
pipeline_name: Optional[str] = None
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)

View File

@ -65,7 +65,7 @@ def create(
config_dict: dict,
metadata_config: OpenMetadataConnection
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)
@ -80,7 +80,7 @@ def create(
metadata_config: OpenMetadataConnection,
pipeline_name: Optional[str] = None
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)

View File

@ -65,7 +65,7 @@ def create(
config_dict: dict,
metadata_config: OpenMetadataConnection
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)
@ -80,7 +80,7 @@ def create(
metadata_config: OpenMetadataConnection,
pipeline_name: Optional[str] = None
):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
config: WorkflowSource = WorkflowSource.model_validate(config_dict)
.....
.....
return cls(config, metadata_config)