From 75c9793eacf81af6bd72a924c9067ce544d9a827 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 9 Dec 2018 17:58:24 -0800 Subject: [PATCH] Remove central config file as it's more trouble than it's worth Simpler and easier for testing to stick to configuration via CLI args. We'll worry about deployment later. --- README.md | 7 ------- common/common.py | 31 +++++-------------------------- config.example.yaml | 6 ------ downloader/Dockerfile | 5 +---- 4 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 config.example.yaml diff --git a/README.md b/README.md index f6f5d74..6ffcffe 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,3 @@ but a brief overview of the components: All components are built as docker images. Components which access the disk expect a shared directory mounted at `/mnt`. - -#### Configuration - -Configuration is built into the docker images, and set during build by specifying a -YAML file `config.yaml` in the repository root directory. - -See the provided example file for documentation of options. diff --git a/common/common.py b/common/common.py index dfce51e..96a1cf1 100644 --- a/common/common.py +++ b/common/common.py @@ -5,37 +5,16 @@ import datetime import dateutil.parser -import yaml -class Config(object): - def load(self, - run_start_time, - ): - # PyYAML tries to...ugh...be clever, and parse timestamps if it can work out how. - # So we should only try to parse if it's not datetime already. - if not isinstance(run_start_time, datetime.datetime): - run_start_time = dateutil.parser.parse(run_start_time) - self.run_start_time = run_start_time +def dt_to_bustime(start, dt): + """Convert a datetime to bus time. Bus time is seconds since the given start point.""" + return (dt - start).total_seconds() -CONF = Config() - - -def load_config(path="/etc/wubloader.yaml"): - with open(path) as f: - CONF.load(**yaml.safe_load(f)) - - -def dt_to_bustime(dt): - """Convert a datetime to bus time. Bus time is seconds since the start of the run - as defined in the config file.""" - return (dt - CONF.run_start_time).total_seconds() - - -def bustime_to_dt(bustime): +def bustime_to_dt(start, bustime): """Convert from bus time to a datetime""" - return CONF.run_start_time + datetime.timedelta(seconds=bustime) + return start + datetime.timedelta(seconds=bustime) def format_bustime(bustime, round="millisecond"): diff --git a/config.example.yaml b/config.example.yaml deleted file mode 100644 index 03045aa..0000000 --- a/config.example.yaml +++ /dev/null @@ -1,6 +0,0 @@ - -# The timestamp of the beginning of the run. -# This defines 00:00 bustime. -# Should be in format YYYY-MM-DD hh:mm:ss. -# Example: 2018-11-09 18:00:00 -run_start_time: 1970-01-01 00:00:00 diff --git a/downloader/Dockerfile b/downloader/Dockerfile index d06b496..bce25c4 100644 --- a/downloader/Dockerfile +++ b/downloader/Dockerfile @@ -9,7 +9,4 @@ RUN pip install /tmp/common && rm -r /tmp/common COPY downloader /tmp/downloader RUN pip install /tmp/downloader && rm -r /tmp/downloader -# Add config file last as it changes most -COPY config.yaml /etc/wubloader.yaml - -CMD python2 -m downloader +ENTRYPOINT python2 -m downloader --base-dir /mnt