-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
80 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from yente import settings | ||
from yente.logs import get_logger | ||
from yente.search.base import get_es, close_es | ||
from yente.data.manifest import Catalog | ||
|
||
log = get_logger(__name__) | ||
|
||
|
||
async def sync_dataset_versions(catalog: Catalog) -> None: | ||
es = await get_es() | ||
res = await es.indices.get_alias(name=settings.ENTITY_INDEX) | ||
for aliased_index in res.body.keys(): | ||
aliased_end: str = aliased_index[len(settings.ENTITY_INDEX) + 1 :] | ||
dataset_name, index_version = aliased_end.split("-", 1) | ||
version = index_version[len(settings.INDEX_VERSION) :] | ||
dataset = catalog.get(dataset_name) | ||
if dataset is None: | ||
log.warn("Dataset has index but no metadata: %s" % dataset_name) | ||
continue | ||
if version != dataset.version: | ||
log.info( | ||
"Dataset %s is outdated" % dataset_name, | ||
indexed=version, | ||
available=dataset.version, | ||
) | ||
dataset.index_version = version | ||
await close_es() |