From a2ab1b7cbfb3973d0dbe1a6fb3d2b79f0908e63c Mon Sep 17 00:00:00 2001 From: Alan Cleary Date: Fri, 15 Sep 2023 09:57:39 -0600 Subject: [PATCH 1/4] Updated the redis_loader container entrypoint. The entrypoint now only runs scripts in the container's /docker-entrypoint-initdb.d/ directory if the database is empty AND there are no command-line arguments. --- redis_loader/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis_loader/entrypoint.sh b/redis_loader/entrypoint.sh index 4fd819ad..82716ec8 100755 --- a/redis_loader/entrypoint.sh +++ b/redis_loader/entrypoint.sh @@ -2,7 +2,7 @@ set -o errexit -if python < Date: Fri, 15 Sep 2023 10:00:29 -0600 Subject: [PATCH 2/4] Changed the default redis_loader load type to "new". --- redis_loader/redis_loader/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis_loader/redis_loader/__main__.py b/redis_loader/redis_loader/__main__.py index 4d63fa72..4beb534f 100755 --- a/redis_loader/redis_loader/__main__.py +++ b/redis_loader/redis_loader/__main__.py @@ -185,7 +185,7 @@ def parseArgs(): envvar=loadtype_envvar, type=str, choices=list(load_types.keys()), - default="append", + default="new", help=f""" How the data should be loaded into Redis:\n{loadtype_help} (can also be specified using the {loadtype_envvar} environment variable). From 7d3573029f5811eb656acfbe5ea98cfe1f95e9a3 Mon Sep 17 00:00:00 2001 From: Alan Cleary Date: Fri, 15 Sep 2023 10:53:28 -0600 Subject: [PATCH 3/4] Updated the redis_loader README. --- redis_loader/README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/redis_loader/README.md b/redis_loader/README.md index 22dd104f..57f20b53 100644 --- a/redis_loader/README.md +++ b/redis_loader/README.md @@ -35,6 +35,12 @@ The loading script can be run as follows $ python -m redis_loader +By default, the loading script will only load new databases, i.e. no data will be loaded if the indexes it creates already exist. +This behavior can be changed using the `--load-type` flag. +For example, the following command will create a new database or append data to an existing database: + + $ python -m redis_loader --load-type append + For more information about the script and additional commands and arguments, run $ python -m redis_loader --help @@ -43,8 +49,11 @@ If the program was built as a docker container, it can be run as follows $ docker run redis_loader -Any `*.sh` scripts in the container /docker-entrypoint-initdb.d directory will be processed if the `REDIS_DB` (default 0) at `REDIS_HOST` (default 'localhost') on port `REDIS_PORT` (default 6379) is empty: +When the loading script is run without any arguments AND the target Redis database is empty, any `*.sh` scripts in the container's `/docker-entrypoint-initdb.d/` directory will be executed in alphabetical order. +Custom `*sh` scripts can be put in the container's `/docker-entrypoint-initdb/` directory using [volumes](https://docs.docker.com/storage/volumes/): + + $ docker run -v /path/to/local/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:rw redis_loader - $ docker run -e REDIS_HOST=my-redis-db-host -v $PWD/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d redis_loader +These scripts should use the Python command above to load data. -See [gcv-docker-compose](https://github.com/legumeinfo/gcv-docker-compose#redis_loader) instructions for running in the context of the system for which the service was conceived (example with actual data given there!). +See the [gcv-docker-compose instructions](https://github.com/legumeinfo/gcv-docker-compose#loading-data) for examples of using the loading script. From 6bfed069d61e0f78dcf563a65f7f23bd02225af8 Mon Sep 17 00:00:00 2001 From: Alan Cleary Date: Fri, 15 Sep 2023 10:55:09 -0600 Subject: [PATCH 4/4] Bumped the redis_loader version to 1.3.0. --- redis_loader/redis_loader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis_loader/redis_loader/__init__.py b/redis_loader/redis_loader/__init__.py index 371ebf6f..4d9cfe97 100644 --- a/redis_loader/redis_loader/__init__.py +++ b/redis_loader/redis_loader/__init__.py @@ -5,7 +5,7 @@ def int_or_str(value): return value -__version__ = "1.2.3" +__version__ = "1.3.0" VERSION = tuple(map(int_or_str, __version__.split("."))) __schema_version__ = "1.1.0"