Skip to content
Snippets Groups Projects
Commit 58191300 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

update package to load articles in ms

parent ea47dd60
No related branches found
No related tags found
1 merge request!224Resolve "Rework references"
Pipeline #123578 waiting for manual action with stages
in 8 minutes and 7 seconds
......@@ -237,6 +237,29 @@ def update_systems(
index.update_typo_tolerance({"enabled": False})
def update_articles(
host: str,
key: str,
file: Path,
document: str,
):
client = meilisearch.Client(host, key)
index = client.index(document.lower())
with open(file, "r") as jsonfile:
json_object = json.load(jsonfile)
for obj in json_object:
obj["ms_id"] = obj["id"].replace("/", "_")
tasks = index.add_documents_in_batches(json_object, primary_key="ms_id")
for task in tasks:
print(task)
pagination_settings_task = index.update_pagination_settings(
{"maxTotalHits": 100000}
)
print(pagination_settings_task)
def split_on_comma(str_val: str) -> List[str]:
for val in str_val.split(","):
yield val.strip()
......@@ -2,7 +2,12 @@ import typer
import meilisearch
from typing_extensions import Annotated
from pathlib import Path
from df_wiki_cli.meilisearch import update_refseq, update_structure, update_systems
from df_wiki_cli.meilisearch import (
update_articles,
update_refseq,
update_structure,
update_systems,
)
from enum import Enum
from types import SimpleNamespace
from rich.console import Console
......@@ -17,6 +22,7 @@ class Documents(str, Enum):
refseq = "refseq"
structure = "structure"
systems = "systems"
article = "article"
@app.callback()
......@@ -61,6 +67,8 @@ def update(
update_structure(ctx.obj.host, ctx.obj.key, file, document)
if document == "systems":
update_systems(ctx.obj.host, ctx.obj.key, file, document)
if document == "article":
update_articles(ctx.obj.host, ctx.obj.key, file, document)
@app.command()
......
[tool.poetry]
name = "df-wiki-cli"
version = "0.1.5"
version = "0.1.6"
description = ""
authors = ["Remi PLANEL <rplanel@pasteur.fr>"]
readme = "README.md"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment