From 816fcd43445909725452a40dbad49889660952f4 Mon Sep 17 00:00:00 2001 From: Daniel Perrefort Date: Tue, 15 Aug 2023 14:43:24 -0400 Subject: [PATCH] Fix typos in documentation and log messages (#23) --- lmod_ingest/main.py | 13 +++++++------ lmod_ingest/utils.py | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lmod_ingest/main.py b/lmod_ingest/main.py index b9e258d..6c1d7bf 100755 --- a/lmod_ingest/main.py +++ b/lmod_ingest/main.py @@ -6,10 +6,10 @@ lmod_ingest --version Options: - -h --help Show this help text - Path of the log data to ingest - --sql Print migration SQL but do not execute it - --version Show the application version number + -h --help Show this help text + Path of the log data to ingest + --sql Print migration SQL but do not execute it + --version Show the application version number """ import logging @@ -42,9 +42,10 @@ def ingest(path: Path) -> None: """Ingest data from a log file into the application database Args: - path: Path of the lg file + path: Path of the log file """ + logging.info(f'Ingesting {path.resolve()}') db_engine = sa.engine.create_engine(url=fetch_db_url()) with db_engine.connect() as connection: data = parse_log_data(path) @@ -78,4 +79,4 @@ def main(): migrate(arguments['--sql']) except Exception as caught: - logging.error(str(caught)) + logging.error(caught) diff --git a/lmod_ingest/utils.py b/lmod_ingest/utils.py index ed22416..4b1e53b 100644 --- a/lmod_ingest/utils.py +++ b/lmod_ingest/utils.py @@ -14,7 +14,7 @@ def fetch_db_url() -> str: """Fetch DB connection settings from environment variables Returns: - A sqlalchemy compatible database URL + A SQLAlchemy compatible database URL Raises: RuntimeError: If the username or password is not defined in the environment @@ -37,7 +37,7 @@ def fetch_db_url() -> str: def parse_log_data(path: Path) -> pd.DataFrame: """Parse, format, and return data from an Lmod log file - The returned dataframe is formatted using the same data model assumed + The returned DataFrame is formatted using the same data model assumed by the ingestion database. Args: @@ -49,7 +49,7 @@ def parse_log_data(path: Path) -> pd.DataFrame: logging.info(f'Parsing log data') - # Expect columns to be seperated by whitespace and use ``=`` as a secondary + # Expect columns to be separated by whitespace and use ``=`` as a secondary # delimiter to automatically split up strings like "user=admin123" into two columns log_data = pd.read_table( path, @@ -60,7 +60,7 @@ def parse_log_data(path: Path) -> pd.DataFrame: engine='python' ) - # Convert UTC decimals to a MYSql compatible string format + # Convert UTC decimals to a MySQL compatible string format log_data['time'] = pd.to_datetime(log_data['time'], unit='s').dt.strftime('%Y-%m-%d %H:%M:%S.%f') # Split the module name into package names and versions