From e9587217634b190288909788f46b1c73260010c1 Mon Sep 17 00:00:00 2001 From: Jarno Bakker Date: Thu, 1 Aug 2024 13:43:37 +0200 Subject: [PATCH] update changelog --- CHANGELOG.md | 2 ++ entrypoint.py | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ddd8e..ac3f6d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added - Added support for YAML configurations. - Allow specifying external config/rdf files. - Added support for trig files. - Import vocabularies every hour using cron. +- Added a configuration option for the refresh interval of vocabularies. ## [v2.15-1.1.0] diff --git a/entrypoint.py b/entrypoint.py index 288616c..417ac9c 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -32,9 +32,11 @@ def append_file(source: IO, dest: str): df.write(line) -if __name__ == "__main__": - time.sleep(10) - +def main() -> None: + """ + Main function. + :return: + """ data = os.environ["DATA"] if os.path.isfile(f'{data}/config.ttl'): @@ -62,15 +64,15 @@ def append_file(source: IO, dest: str): graph = get_graph(config) print(f"Graph: {graph}") - should_reload = False + reload = False if graph not in loaded_vocabs: - should_reload = True + reload = True elif vocab_config['config'].get('refresh', False): interval = vocab_config['config'].get('refreshInterval', 0) diff = (time.time() - loaded_vocabs[graph]) / 3600 - should_reload = diff > interval + reload = diff > interval - if should_reload: + if reload: print(f"Loading vocabulary {vocab}") load_vocabulary(vocab_config['source'], data, graph) if graph in loaded_vocabs: @@ -86,3 +88,8 @@ def append_file(source: IO, dest: str): print(f"Invalid configuration: {e}") print(f"Skipping vocab '{vocab}'") continue + + +if __name__ == "__main__": + time.sleep(10) + main()