Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
sushi30 committed Jul 24, 2024
1 parent b8fae13 commit 53375f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ workflowConfig:
hostPort: http://localhost:8585/api
authProvider: openmetadata
securityConfig:
jwtToken: REPLACE_WITH_JWT_TOKEN
jwtToken: eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5MmotMDI0MmJrOTQzNTYiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzQm90IjpmYWxzZSwiaXNzIjoib3Blbi1tZXRhZGF0YS5vcmciLCJpYXQiOjE2NjM5Mzg0NjIsImVtYWlsIjoiYWRtaW5Ab3Blbm1ldGFkYXRhLm9yZyJ9.tS8um_5DKu7HgzGBzS1VTA5uUjKWOCU0B_j08WXBiEC0mr0zNREkqVfwFDD-d24HlNEbrqioLsBuFRiwIWKc1m_ZlVQbG7P36RUxhuv2vbSp80FKyNM-Tj93FDzq91jsyNmsQhyNv_fNr3TXfzzSPjHt8Go0FMMP66weoKMgW2PbXlhVKwEuXUHyakLLzewm9UMeQaEiRzhiTMU3UkLXcKbYEJJvfNFcLwSl9W8JCO_l0Yj3ud-qt_nQYEZwqW6u5nfdQllN133iikV4fM5QZsMCnm8Rq1mvLR0y9bmJiD7fwM1tmJ791TUWqmKaTnP49U493VanKpUAfzIiOiIbhg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from metadata.workflow.application import AppRunner
from metadata.ingestion.ometa.models import EntityList

from metadata.community.applications.OpenMetadataRetention.generated.config import OpenMetadataRetentionConfig
from metadata.community.applications.OpenMetadataRetention.generated.config import (
OpenMetadataRetentionConfig,
)

logger = logging.getLogger("openmetadata_retention")

Expand All @@ -33,8 +35,6 @@ def __iter__(self):
yield from self.page.entities




class OpenMetadataRetention(AppRunner):
"""
OpenMetadataRetention Application
Expand All @@ -46,15 +46,15 @@ def __init__(self, *args, **kwargs):
config = self.app_config.model_dump()
del config["type"]
self.app_config = OpenMetadataRetentionConfig.model_validate(config)

@property
def name(self) -> str:
return "MetadataRetention"

def run(self) -> None:
print(self.app_config)
now = datetime.datetime.now()
retention_period = datetime.timedelta(days=1)
retention_period = datetime.timedelta(seconds=self.app_config.retentionSeconds)
print(f"Running on {now} and deleting tables older than {retention_period}")
expire_after = (now.timestamp() - retention_period.total_seconds()) * 1000
version = self.metadata.get_server_version()
Expand All @@ -78,7 +78,7 @@ def close(self) -> None:

def expire(self, entity: Table, expire_after: int) -> None:
if entity.updatedAt.root < expire_after:
print(f"Deleting table {entity.fullyQualifiedName.root}")
self.metadata.delete_entity(type(entity).__class__, entity.id)
print(f"Deleting {type(entity).__name__}: {entity.fullyQualifiedName.root}")
self.metadata.delete(type(entity), entity.id)
else:
print(f"Entity {entity.fullyQualifiedName.root} is not due for deletion")

0 comments on commit 53375f0

Please sign in to comment.