From 597dfd1f4da13719f95793bde03fd6131a0f440a Mon Sep 17 00:00:00 2001 From: Markus Scheidgen <markus.scheidgen@gmail.com> Date: Wed, 5 Dec 2018 16:30:55 +0100 Subject: [PATCH] Added configurability on files and directory names. --- nomad/config.py | 8 ++++---- nomad/files.py | 4 ++-- tests/test_files.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nomad/config.py b/nomad/config.py index ac20c655bc..1f74299df2 100644 --- a/nomad/config.py +++ b/nomad/config.py @@ -22,7 +22,7 @@ import logging from collections import namedtuple FilesConfig = namedtuple( - 'FilesConfig', ['uploads_bucket', 'repository_bucket', 'archive_bucket', 'compress_archive']) + 'FilesConfig', ['uploads_bucket', 'raw_bucket', 'archive_bucket', 'compress_archive']) """ API independent configuration for the object storage. """ CeleryConfig = namedtuple('Celery', ['broker_url']) @@ -48,7 +48,7 @@ NomadServicesConfig = namedtuple('NomadServicesConfig', ['api_host', 'api_port', files = FilesConfig( uploads_bucket='uploads', - repository_bucket='repository', + raw_bucket=os.environ.get('NOMAD_FILES_RAW_BUCKET', 'raw'), archive_bucket='archive', compress_archive=True ) @@ -76,8 +76,8 @@ celery = CeleryConfig( ) fs = FSConfig( - tmp='.volumes/fs/tmp', - objects='.volumes/fs/objects' + tmp=os.environ.get('NOMAD_FILES_TMP_DIR', '.volumes/fs/tmp'), + objects=os.environ.get('NOMAD_FILES_OBJECTS_DIR', '.volumes/fs/objects') ) elastic = ElasticConfig( host=os.environ.get('NOMAD_ELASTIC_HOST', 'localhost'), diff --git a/nomad/files.py b/nomad/files.py index 9357f5a9a3..71ab0724c2 100644 --- a/nomad/files.py +++ b/nomad/files.py @@ -346,7 +346,7 @@ class UploadFile(ObjectFile): object_id = self.upload_hash() return ZippedDataContainer.create( - self._extract_dir, Objects._os_path(config.files.repository_bucket, object_id)) + self._extract_dir, Objects._os_path(config.files.raw_bucket, object_id)) @Decorators.handle_errors def remove_extract(self) -> None: @@ -404,7 +404,7 @@ class RepositoryFile(ObjectFile): """ def __init__(self, upload_hash: str) -> None: super().__init__( - bucket=config.files.repository_bucket, + bucket=config.files.raw_bucket, object_id=upload_hash, ext='zip') diff --git a/tests/test_files.py b/tests/test_files.py index f1d8d34049..4209c12163 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -141,7 +141,7 @@ class TestZippedDataContainer(TestBaggedDataContainer): def archive_config(monkeypatch, request): new_config = config.FilesConfig( config.files.uploads_bucket, - config.files.repository_bucket, + config.files.raw_bucket, config.files.archive_bucket, request.param) monkeypatch.setattr(config, 'files', new_config) -- GitLab