From 584887ee2ed3b4b011681940500c6e03b18b9ee7 Mon Sep 17 00:00:00 2001 From: Heiko Mueller Date: Wed, 3 Feb 2021 12:31:14 -0500 Subject: [PATCH 1/3] Bring back helper config.APP() required by flowapp --- flowserv/config.py | 15 +++++++++++++++ flowserv/version.py | 2 +- tests/test_config.py | 12 ++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/flowserv/config.py b/flowserv/config.py index 5498406c..5d9e56c0 100644 --- a/flowserv/config.py +++ b/flowserv/config.py @@ -18,6 +18,8 @@ import os +import flowserv.error as err + # -- # -- Environment variables and default values @@ -98,6 +100,19 @@ def API_URL(env: Dict) -> str: ROB_SUBMISSION = 'ROB_SUBMISSION' +def APP() -> str: + """Get the value for the FLOWSERV_APP variable from the environment. Raises + a missing configuration error if the value is not set. + Returns + ------- + string + """ + app_key = os.environ.get(FLOWSERV_APP) + if not app_key: + raise err.MissingConfigurationError('workflow identifier') + return app_key + + # -- Auth --------------------------------------------------------------------- """Names of environment variables that are used to configure the authentication diff --git a/flowserv/version.py b/flowserv/version.py index 16fb7df7..21a30df0 100644 --- a/flowserv/version.py +++ b/flowserv/version.py @@ -7,4 +7,4 @@ # terms of the MIT License; see LICENSE file for more details. """Information about the current version of the flowServ package.""" -__version__ = '0.7.1' +__version__ = '0.7.2' diff --git a/tests/test_config.py b/tests/test_config.py index b7f4cb1b..57100059 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -12,6 +12,7 @@ import pytest import flowserv.config as config +import flowserv.error as err @pytest.mark.parametrize( @@ -121,3 +122,14 @@ def test_config_url(): 'app-path/v1' ) assert config.API_URL(conf) == api_url + + +def test_env_app_identifier(): + """Test getting the workflow identifier and sbmission identifier from the + environment. + """ + os.environ[config.FLOWSERV_APP] = '0000' + assert config.APP() == '0000' + del os.environ[config.FLOWSERV_APP] + with pytest.raises(err.MissingConfigurationError): + config.APP() From 2421f8df0e3241909af6438d3fa7dd10152c60bc Mon Sep 17 00:00:00 2001 From: Heiko Mueller Date: Wed, 3 Feb 2021 12:53:09 -0500 Subject: [PATCH 2/3] Change default data directory to OS-specific user cache dir --- flowserv/config.py | 9 ++++++--- requirements.txt | 1 + setup.py | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/flowserv/config.py b/flowserv/config.py index 5d9e56c0..07e6e98c 100644 --- a/flowserv/config.py +++ b/flowserv/config.py @@ -13,7 +13,7 @@ """ from __future__ import annotations -from pathlib import Path +from appdirs import user_cache_dir from typing import Any, Dict, Optional import os @@ -52,14 +52,17 @@ def API_DEFAULTDIR() -> str: - """The default API base directory is a subfolder in the users HOME + """The default API base directory is a subfolder in the users data cache directory. + The default user cache directory is different for different OS's. We use + appdirs.user_cache_dir to get the directory. + Returns ------- string """ - return os.path.join(str(Path.home()), DEFAULT_DIR) + return os.path.join(user_cache_dir(appname=__name__.split('.')[0]), DEFAULT_DIR) def API_URL(env: Dict) -> str: diff --git a/requirements.txt b/requirements.txt index fdd423d0..f08d3ba7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ future +appdirs>=1.4.4 gitpython passlib python-dateutil diff --git a/setup.py b/setup.py index 2380d598..e43420fd 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ install_requires = [ 'future', + 'appdirs>=1.4.4', 'gitpython', 'passlib', 'python-dateutil', From 4639b77b8f2d5bbc11ca4fadf20f5c1185953f64 Mon Sep 17 00:00:00 2001 From: Heiko Mueller Date: Wed, 3 Feb 2021 12:55:16 -0500 Subject: [PATCH 3/3] Update changelog --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 7c29e6dc..701db7e8 100644 --- a/changelog.md +++ b/changelog.md @@ -111,3 +111,8 @@ * Ensure not to override *FLOWSERV_ASYNC* in `ClientAPI`. * Add CLI environment context to support entry points for `flowserv` and `rob`. * Extend serialized objects to contain additional resources (i.e., groups and runs) for authenticated users. + + +### 0.7.2 - 2021-02-03 + +* Change the location of the default data directory to be the OS-specific user cache directory.