Skip to content

Commit

Permalink
Merge pull request #77 from scailfin/dev-0.7.2
Browse files Browse the repository at this point in the history
Dev 0.7.2
  • Loading branch information
heikomuller authored Feb 3, 2021
2 parents 529d9db + 4639b77 commit 136677d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
24 changes: 21 additions & 3 deletions flowserv/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"""

from __future__ import annotations
from pathlib import Path
from appdirs import user_cache_dir
from typing import Any, Dict, Optional

import os

import flowserv.error as err


# --
# -- Environment variables and default values
Expand Down Expand Up @@ -50,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:
Expand Down Expand Up @@ -98,6 +103,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
Expand Down
2 changes: 1 addition & 1 deletion flowserv/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
future
appdirs>=1.4.4
gitpython
passlib
python-dateutil
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

install_requires = [
'future',
'appdirs>=1.4.4',
'gitpython',
'passlib',
'python-dateutil',
Expand Down
12 changes: 12 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pytest

import flowserv.config as config
import flowserv.error as err


@pytest.mark.parametrize(
Expand Down Expand Up @@ -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()

0 comments on commit 136677d

Please sign in to comment.