Skip to content
Snippets Groups Projects
Commit 26286305 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Merge branch 'host-ponos-data-dir' into 'master'

Different path on host for Ponos data volume

See merge request !262
parents 79b5f719 268d04ed
No related branches found
No related tags found
1 merge request!262Different path on host for Ponos data volume
......@@ -202,13 +202,20 @@ def ponos_data_dir_check(*args, **kwargs):
Checks the Ponos working directory exists
"""
from django.conf import settings
errors = []
if not os.path.isdir(settings.PONOS_DATA_DIR):
return [Error(
errors.append(Error(
'Ponos working directory does not exist',
hint='settings.PONOS_DATA_DIR = "{}"'.format(settings.PONOS_DATA_DIR),
id='arkindex.E010',
)]
return []
))
if not os.path.isdir(settings.HOST_PONOS_DATA_DIR):
errors.append(Error(
'Ponos working directory does not exist on host',
hint='settings.HOST_PONOS_DATA_DIR = "{}"'.format(settings.HOST_PONOS_DATA_DIR),
id='arkindex.E010',
))
return errors
@register()
......
......@@ -86,6 +86,7 @@ if os.environ.get('PONOS_TASK'):
# In a ponos docker task
PONOS_RECIPE = None
PONOS_DATA_DIR = '/data'
HOST_PONOS_DATA_DIR = '/data'
ML_CLASSIFIERS_DIR = '/arkindex/classifiers'
MEDIA_ROOT = '/arkindex/staging'
LOCAL_IMAGESERVER_ROOT = '/arkindex/iiif'
......@@ -93,6 +94,7 @@ if os.environ.get('PONOS_TASK'):
else:
# As scheduler or dev
PONOS_DATA_DIR = os.environ.get('PONOS_DATA_DIR', os.path.join(BASE_DIR, '../../ponos/data'))
HOST_PONOS_DATA_DIR = os.environ.get('HOST_PONOS_DATA_DIR', PONOS_DATA_DIR)
PONOS_RECIPE = {
'volumes': {
# Always expose host configuration
......
......@@ -250,12 +250,19 @@ class ChecksTestCase(TestCase):
self.assertListEqual(ponos_data_dir_check(), [])
isdir_mock.return_value = False
with self.settings(PONOS_DATA_DIR="/oh/no"):
self.assertListEqual(ponos_data_dir_check(), [Error(
'Ponos working directory does not exist',
hint='settings.PONOS_DATA_DIR = "/oh/no"',
id='arkindex.E010',
)])
with self.settings(PONOS_DATA_DIR="/oh/no", HOST_PONOS_DATA_DIR="/no/oh"):
self.assertListEqual(ponos_data_dir_check(), [
Error(
'Ponos working directory does not exist',
hint='settings.PONOS_DATA_DIR = "/oh/no"',
id='arkindex.E010',
),
Error(
'Ponos working directory does not exist on host',
hint='settings.HOST_PONOS_DATA_DIR = "/no/oh"',
id='arkindex.E010',
),
])
@override_settings()
def test_internal_group_check(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment