Skip to content

Commit

Permalink
Merge branch 'changes/enable_env_vars' into 'master'
Browse files Browse the repository at this point in the history
Handled environment variables to be consistent

See merge request caimira/caimira!486
  • Loading branch information
lrdossan committed Mar 8, 2024
2 parents 60f255d + 9ec51a0 commit 10ce133
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ $ oc create secret generic \

The CERN data service collects data from various sources and expose them via a REST API endpoint.

To enable the service set the environment variable `DATA_SERVICE_ENABLED` as `True`.
The service is enabled when the environment variable `DATA_SERVICE_ENABLED` is set to 1.

## Update configuration

Expand Down
3 changes: 2 additions & 1 deletion app-config/calculator-app/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ if [[ "$APP_NAME" == "calculator-app" ]]; then

export "EXTRA_PAGES"="$EXTRA_PAGES"

export "DATA_SERVICE_ENABLED"="${DATA_SERVICE_ENABLED:=False}"
export "DATA_SERVICE_ENABLED"="${DATA_SERVICE_ENABLED:=0}"
export "CAIMIRA_PROFILER_ENABLED"="${CAIMIRA_PROFILER_ENABLED:=0}"

echo "Starting the caimira webservice with: python -m caimira.apps.calculator ${args[@]}"
python -m caimira.apps.calculator "${args[@]}"
Expand Down
6 changes: 4 additions & 2 deletions app-config/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ services:
- APPLICATION_ROOT=/
- CAIMIRA_CALCULATOR_PREFIX=/calculator-cern
- CAIMIRA_THEME=caimira/apps/templates/cern
- DATA_SERVICE_ENABLED=False
- DATA_SERVICE_ENABLED=0
- CAIMIRA_PROFILER_ENABLED=0
user: ${CURRENT_UID}

calculator-open-app:
Expand All @@ -30,7 +31,8 @@ services:
- APP_NAME=calculator-app
- APPLICATION_ROOT=/
- CAIMIRA_CALCULATOR_PREFIX=/calculator-open
- DATA_SERVICE_ENABLED=False
- DATA_SERVICE_ENABLED=0
- CAIMIRA_PROFILER_ENABLED=0
user: ${CURRENT_UID}

auth-service:
Expand Down
8 changes: 6 additions & 2 deletions app-config/openshift/deploymentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@
key: ARVE_API_KEY
name: arve-api
- name: DATA_SERVICE_ENABLED
value: 'True'
value: '0'
- name: CAIMIRA_PROFILER_ENABLED
value: '1'
image: '${PROJECT_NAME}/calculator-app'
ports:
- containerPort: 8080
Expand Down Expand Up @@ -363,7 +365,9 @@
- name: CAIMIRA_CALCULATOR_PREFIX
value: /calculator-open
- name: DATA_SERVICE_ENABLED
value: 'True'
value: '0'
- name: CAIMIRA_PROFILER_ENABLED
value: '1'
image: '${PROJECT_NAME}/calculator-app'
ports:
- containerPort: 8080
Expand Down
5 changes: 2 additions & 3 deletions caimira/apps/calculator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,8 @@ def make_app(

data_registry = DataRegistry()
data_service = None
data_service_enabled = os.environ.get("DATA_SERVICE_ENABLED", "False")
is_enabled = data_service_enabled.lower() == "true"
if is_enabled: data_service = DataService.create()
data_service_enabled = os.environ.get('DATA_SERVICE_ENABLED', 0)
if data_service_enabled: data_service = DataService.create()

return Application(
urls,
Expand Down
6 changes: 3 additions & 3 deletions caimira/tests/apps/calculator/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_app(self):
@tornado.testing.gen_test(timeout=_TIMEOUT)
def test_report(self):
requests = [
self.http_client.fetch(self.get_url('/calculator/baseline-model/result')),
self.http_client.fetch(self.get_url('/calculator/baseline-model/result'), request_timeout=_TIMEOUT),
# At the same time, request a non-report page (to check whether the report is blocking).
self.http_client.fetch(self.get_url('/calculator/')),
]
Expand Down Expand Up @@ -69,7 +69,7 @@ def get_app(self):

@tornado.testing.gen_test(timeout=_TIMEOUT)
def test_report(self):
response = yield self.http_client.fetch(self.get_url('/calculator/baseline-model/result'))
response = yield self.http_client.fetch(self.get_url('/calculator/baseline-model/result'), request_timeout=_TIMEOUT)
self.assertEqual(response.code, 200)
assert 'expected number of new cases is' in response.body.decode()

Expand All @@ -80,7 +80,7 @@ def get_app(self):

@tornado.testing.gen_test(timeout=_TIMEOUT)
def test_report(self):
response = yield self.http_client.fetch(self.get_url('/mycalc/baseline-model/result'))
response = yield self.http_client.fetch(self.get_url('/mycalc/baseline-model/result'), request_timeout=_TIMEOUT)
self.assertEqual(response.code, 200)

def test_calculator_404(self):
Expand Down

0 comments on commit 10ce133

Please sign in to comment.