mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 19:48:17 +00:00
Ingestion Pipeline deployed, Athena tests and pydantic extras (#8682)
* Always run python tests * Fix athena tests and types * Update deployed prop in IngestionPipeline * Fix #8554 * Format * Use true as default deployed migration * Remove repeated req * Pydantic wiggle room
This commit is contained in:
parent
6306c9ac8d
commit
34ba9d95c5
13
.github/workflows/py-tests.yml
vendored
13
.github/workflows/py-tests.yml
vendored
@ -15,17 +15,12 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- '0.[0-9]+.[0-9]+'
|
- '0.[0-9]+.[0-9]+'
|
||||||
paths:
|
paths-ignore:
|
||||||
- ingestion/**
|
- 'openmetadata-docs/**'
|
||||||
- openmetadata-service/**
|
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [labeled, opened, synchronize, reopened]
|
types: [labeled, opened, synchronize, reopened]
|
||||||
branches:
|
paths-ignore:
|
||||||
- main
|
- 'openmetadata-docs/**'
|
||||||
- '0.[0-9]+.[0-9]+'
|
|
||||||
paths:
|
|
||||||
- ingestion/**
|
|
||||||
- openmetadata-service/**
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@ -109,4 +109,11 @@ CREATE TABLE IF NOT EXISTS metadata_service_entity (
|
|||||||
deleted BOOLEAN GENERATED ALWAYS AS (json -> '$.deleted'),
|
deleted BOOLEAN GENERATED ALWAYS AS (json -> '$.deleted'),
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE (name)
|
UNIQUE (name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- We are starting to store the current deployed flag. Let's mark it as false by default
|
||||||
|
UPDATE ingestion_pipeline_entity
|
||||||
|
SET json = JSON_REMOVE(json ,'$.deployed');
|
||||||
|
|
||||||
|
UPDATE ingestion_pipeline_entity
|
||||||
|
SET json = JSON_INSERT(json ,'$.deployed', 'true');
|
||||||
|
|||||||
@ -136,3 +136,10 @@ CREATE TABLE IF NOT EXISTS metadata_service_entity (
|
|||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE (name)
|
UNIQUE (name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- We are starting to store the current deployed flag. Let's mark it as false by default
|
||||||
|
UPDATE ingestion_pipeline_entity
|
||||||
|
SET json = json::jsonb #- '{deployed}';
|
||||||
|
|
||||||
|
UPDATE ingestion_pipeline_entity
|
||||||
|
SET json = jsonb_set(json::jsonb, '{deployed}', 'true'::jsonb, true);
|
||||||
|
|||||||
@ -27,11 +27,11 @@ base_requirements = {
|
|||||||
"idna<3,>=2.5",
|
"idna<3,>=2.5",
|
||||||
"mypy_extensions>=0.4.3",
|
"mypy_extensions>=0.4.3",
|
||||||
"typing-inspect",
|
"typing-inspect",
|
||||||
"pydantic[email]==1.9.0",
|
"pydantic~=1.9.0",
|
||||||
|
"email-validator>=1.0.3",
|
||||||
"google>=3.0.0",
|
"google>=3.0.0",
|
||||||
"google-auth>=1.33.0",
|
"google-auth>=1.33.0",
|
||||||
"python-dateutil>=2.8.1",
|
"python-dateutil>=2.8.1",
|
||||||
"email-validator>=1.0.3",
|
|
||||||
"wheel~=0.36.2",
|
"wheel~=0.36.2",
|
||||||
"python-jose==3.3.0",
|
"python-jose==3.3.0",
|
||||||
"sqlalchemy>=1.4.0",
|
"sqlalchemy>=1.4.0",
|
||||||
|
|||||||
@ -464,7 +464,9 @@ def _(connection: AthenaConnection):
|
|||||||
url += ":"
|
url += ":"
|
||||||
url += f"@athena.{connection.awsConfig.awsRegion}.amazonaws.com:443"
|
url += f"@athena.{connection.awsConfig.awsRegion}.amazonaws.com:443"
|
||||||
|
|
||||||
url += f"?s3_staging_dir={quote_plus(connection.s3StagingDir)}"
|
staging_url = connection.s3StagingDir.scheme + "://" + str(connection.s3StagingDir)
|
||||||
|
|
||||||
|
url += f"?s3_staging_dir={quote_plus(staging_url)}"
|
||||||
if connection.workgroup:
|
if connection.workgroup:
|
||||||
url += f"&work_group={connection.workgroup}"
|
url += f"&work_group={connection.workgroup}"
|
||||||
if connection.awsConfig.awsSessionToken:
|
if connection.awsConfig.awsSessionToken:
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from pydantic import AnyUrl
|
||||||
|
|
||||||
from metadata.generated.schema.entity.services.connections.database.athenaConnection import (
|
from metadata.generated.schema.entity.services.connections.database.athenaConnection import (
|
||||||
AthenaConnection,
|
AthenaConnection,
|
||||||
AthenaScheme,
|
AthenaScheme,
|
||||||
@ -766,20 +768,20 @@ class SouceConnectionTest(TestCase):
|
|||||||
awsAccessKeyId="key", awsRegion="us-east-2", awsSecretAccessKey="secret_key"
|
awsAccessKeyId="key", awsRegion="us-east-2", awsSecretAccessKey="secret_key"
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_url = "awsathena+rest://key:secret_key@athena.us-east-2.amazonaws.com:443?s3_staging_dir=s3athena-postgres&work_group=primary"
|
expected_url = "awsathena+rest://key:secret_key@athena.us-east-2.amazonaws.com:443?s3_staging_dir=s3%3A%2F%2Fs3athena-postgres&work_group=primary"
|
||||||
athena_conn_obj = AthenaConnection(
|
athena_conn_obj = AthenaConnection(
|
||||||
awsConfig=awsCreds,
|
awsConfig=awsCreds,
|
||||||
s3StagingDir="s3athena-postgres",
|
s3StagingDir=AnyUrl("s3athena-postgres", scheme="s3"),
|
||||||
workgroup="primary",
|
workgroup="primary",
|
||||||
scheme=AthenaScheme.awsathena_rest,
|
scheme=AthenaScheme.awsathena_rest,
|
||||||
)
|
)
|
||||||
assert expected_url == get_connection_url(athena_conn_obj)
|
assert expected_url == get_connection_url(athena_conn_obj)
|
||||||
|
|
||||||
# connection arguments witho db
|
# connection arguments with db
|
||||||
expected_url = "awsathena+rest://key:secret_key@athena.us-east-2.amazonaws.com:443?s3_staging_dir=s3athena-postgres&work_group=primary"
|
expected_url = "awsathena+rest://key:secret_key@athena.us-east-2.amazonaws.com:443?s3_staging_dir=s3%3A%2F%2Fs3athena-postgres&work_group=primary"
|
||||||
athena_conn_obj = AthenaConnection(
|
athena_conn_obj = AthenaConnection(
|
||||||
awsConfig=awsCreds,
|
awsConfig=awsCreds,
|
||||||
s3StagingDir="s3athena-postgres",
|
s3StagingDir=AnyUrl("s3athena-postgres", scheme="s3"),
|
||||||
workgroup="primary",
|
workgroup="primary",
|
||||||
scheme=AthenaScheme.awsathena_rest,
|
scheme=AthenaScheme.awsathena_rest,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -45,8 +45,8 @@ import org.openmetadata.service.util.RestUtil;
|
|||||||
import org.openmetadata.service.util.ResultList;
|
import org.openmetadata.service.util.ResultList;
|
||||||
|
|
||||||
public class IngestionPipelineRepository extends EntityRepository<IngestionPipeline> {
|
public class IngestionPipelineRepository extends EntityRepository<IngestionPipeline> {
|
||||||
private static final String UPDATE_FIELDS = "owner,sourceConfig,airflowConfig,loggerLevel,enabled";
|
private static final String UPDATE_FIELDS = "owner,sourceConfig,airflowConfig,loggerLevel,enabled,deployed";
|
||||||
private static final String PATCH_FIELDS = "owner,sourceConfig,airflowConfig,loggerLevel,enabled";
|
private static final String PATCH_FIELDS = "owner,sourceConfig,airflowConfig,loggerLevel,enabled,deployed";
|
||||||
|
|
||||||
private static final String PIPELINE_STATUS_JSON_SCHEMA = "pipelineStatus";
|
private static final String PIPELINE_STATUS_JSON_SCHEMA = "pipelineStatus";
|
||||||
private static PipelineServiceClient pipelineServiceClient;
|
private static PipelineServiceClient pipelineServiceClient;
|
||||||
@ -230,6 +230,7 @@ public class IngestionPipelineRepository extends EntityRepository<IngestionPipel
|
|||||||
original.getOpenMetadataServerConnection(), updated.getOpenMetadataServerConnection());
|
original.getOpenMetadataServerConnection(), updated.getOpenMetadataServerConnection());
|
||||||
updateLogLevel(original.getLoggerLevel(), updated.getLoggerLevel());
|
updateLogLevel(original.getLoggerLevel(), updated.getLoggerLevel());
|
||||||
updateEnabled(original.getEnabled(), updated.getEnabled());
|
updateEnabled(original.getEnabled(), updated.getEnabled());
|
||||||
|
updateDeployed(original.getDeployed(), updated.getDeployed());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSourceConfig() throws JsonProcessingException {
|
private void updateSourceConfig() throws JsonProcessingException {
|
||||||
@ -266,6 +267,12 @@ public class IngestionPipelineRepository extends EntityRepository<IngestionPipel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDeployed(Boolean origDeployed, Boolean updatedDeployed) throws JsonProcessingException {
|
||||||
|
if (updatedDeployed != null && !origDeployed.equals(updatedDeployed)) {
|
||||||
|
recordChange("deployed", origDeployed, updatedDeployed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateEnabled(Boolean origEnabled, Boolean updatedEnabled) throws JsonProcessingException {
|
private void updateEnabled(Boolean origEnabled, Boolean updatedEnabled) throws JsonProcessingException {
|
||||||
if (updatedEnabled != null && !origEnabled.equals(updatedEnabled)) {
|
if (updatedEnabled != null && !origEnabled.equals(updatedEnabled)) {
|
||||||
recordChange("enabled", origEnabled, updatedEnabled);
|
recordChange("enabled", origEnabled, updatedEnabled);
|
||||||
|
|||||||
@ -170,7 +170,8 @@
|
|||||||
},
|
},
|
||||||
"deployed": {
|
"deployed": {
|
||||||
"description": "Indicates if the workflow has been successfully deployed to Airflow.",
|
"description": "Indicates if the workflow has been successfully deployed to Airflow.",
|
||||||
"type": "boolean"
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
},
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"description": "True if the pipeline is ready to be run in the next schedule. False if it is paused.",
|
"description": "True if the pipeline is ready to be run in the next schedule. False if it is paused.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user