-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d84fa1f
commit 0d6aec2
Showing
8 changed files
with
116 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from app.cli.main import main | ||
|
||
if __name__ == "__main__": | ||
main() |
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,64 @@ | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def import_data( | ||
input_path: Path = typer.Argument( | ||
..., | ||
exists=True, | ||
file_okay=True, | ||
dir_okay=False, | ||
help="Path of the JSONL data file", | ||
), | ||
num_processes: int = typer.Option( | ||
default=2, | ||
help="How many import processes to run in parallel" | ||
), | ||
num_items: Optional[int] = typer.Option(default=None, help="How many items to import"), | ||
): | ||
"""Import data into Elasticsearch.""" | ||
import time | ||
from app.utils import get_logger | ||
from app.cli.perform_import import perform_import | ||
|
||
logger = get_logger() | ||
|
||
start_time = time.perf_counter() | ||
perform_import( | ||
input_path, | ||
num_items, | ||
num_processes, | ||
start_time, | ||
) | ||
end_time = time.perf_counter() | ||
logger.info("Import time: %s seconds", end_time - start_time) | ||
|
||
|
||
|
||
@app.command() | ||
def write_to_redis(): | ||
import time | ||
|
||
from redis import Redis | ||
|
||
redis = Redis( | ||
host="searchredis", | ||
port=6379, | ||
decode_responses=True, | ||
) | ||
key_name = "search_import_queue" | ||
while True: | ||
code = input("Please enter a product code:\n") | ||
start_time = time.perf_counter() | ||
|
||
redis.rpush(key_name, code) | ||
end_time = time.perf_counter() | ||
print(f"Time: {end_time - start_time} seconds") | ||
|
||
def main() -> None: | ||
app() |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ redis==5.0.0 | |
uvicorn==0.23.2 | ||
tqdm==4.66.1 | ||
cachetools==5.3.1 | ||
typer==0.9.0 |