From 1f687695158e1a73c45fd88b8979d0f90443b956 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Fri, 21 Jun 2024 11:14:58 +0200 Subject: [PATCH] update Makefile, compose.sample.yml and __main__.py --- Makefile | 3 +-- compose.sample.yml | 1 - memorymarker/__main__.py | 30 ++++++++++++++++++------------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 1fb7645..962c5a2 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,7 @@ docker_ci: ## Run all checks in docker docker-smoketest: cp compose.sample.yml compose.smoketest.yml - perl -pi -e 's#YOUR_OUTPUT_DIR#./output#' compose.smoketest.yml - mkdir -p smoketest_output + perl -pi -e 's#YOUR_OUTPUT_DIR#./smoketest_output#' compose.smoketest.yml cp .env .env.smoketest echo "MAX_N=1" >> .env.smoketest diff --git a/compose.sample.yml b/compose.sample.yml index 6e1c06e..e507ac2 100644 --- a/compose.sample.yml +++ b/compose.sample.yml @@ -9,4 +9,3 @@ services: - OPENAI_API_KEY=${OPENAI_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - MAX_N=${MAX_N} - restart: unless-stopped diff --git a/memorymarker/__main__.py b/memorymarker/__main__.py index b483edf..f1cbe02 100644 --- a/memorymarker/__main__.py +++ b/memorymarker/__main__.py @@ -84,7 +84,22 @@ def typer_cli( only_new: bool = typer.Option( True, help="Only generate questions from highlights since last run" ), + log_level: str = typer.Option( + "INFO", + help="Log level", + case_sensitive=False, + show_default=True, + envvar="LOG_LEVEL", + ), ) -> None: + logging.basicConfig( + level=logging.INFO, + format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", + datefmt="%Y/&m/%d %H:%M:%S", + filename="main.log", + ) + coloredlogs.install(level=log_level) # type: ignore + output_dir.mkdir(exist_ok=True, parents=True) logging.info(f"MemoryMarker version {version('memorymarker')}") @@ -152,21 +167,12 @@ def typer_cli( # Write to disk logging.info("Writing questions to markdown...") - ( - Iter(questions) - .groupby(lambda _: _.source_document.title) - .map(lambda _: highlight_group_to_file(output_dir, _)) - ) + for group in questions.groupby(lambda _: _.source_document.title): + highlight_group_to_file(output_dir, group) + last_run_timestamper.update_timestamp() if __name__ == "__main__": load_dotenv() - logging.basicConfig( - level=logging.INFO, - format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", - datefmt="%Y/&m/%d %H:%M:%S", - filename="main.log", - ) - coloredlogs.install(level="DEBUG") # type: ignore app()