-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: BI-5953 schema version attribute (#731)
* feat: BI-5953 schema version attribute * feat: BI-5953 schema_version crawler * feat: BI-5953 schema_version storage schema
- Loading branch information
1 parent
f7e591c
commit f18053b
Showing
5 changed files
with
51 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
lib/dl_maintenance/dl_maintenance/api/crawlers/schema_version_migration.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,39 @@ | ||
from typing import ( | ||
Any, | ||
AsyncIterable, | ||
Optional, | ||
) | ||
|
||
import attr | ||
|
||
from dl_core.us_entry import ( | ||
USEntry, | ||
USMigrationEntry, | ||
) | ||
from dl_core.us_manager.us_manager_async import AsyncUSManager | ||
from dl_maintenance.core.us_crawler_base import USEntryCrawler | ||
|
||
|
||
ALLOWED_ENTRY_SCOPES = ("connection", "dataset") | ||
|
||
|
||
@attr.s | ||
class SchemaVersionCrawler(USEntryCrawler): | ||
ENTRY_TYPE = USMigrationEntry | ||
|
||
entry_scope: str = attr.ib(kw_only=True, validator=attr.validators.in_(ALLOWED_ENTRY_SCOPES)) | ||
|
||
def get_raw_entry_iterator(self, crawl_all_tenants: bool = True) -> AsyncIterable[dict[str, Any]]: | ||
return self.usm.get_raw_collection( | ||
entry_scope=self.entry_scope, | ||
all_tenants=crawl_all_tenants, | ||
) | ||
|
||
async def process_entry_get_save_flag( | ||
self, entry: USEntry, logging_extra: dict[str, Any], usm: Optional[AsyncUSManager] = None | ||
) -> tuple[bool, str]: | ||
if entry.data.get("schema_version") is None: | ||
entry.data["schema_version"] = "1" | ||
return True, "Schema version is set" | ||
|
||
return False, "Entry skipped" |