Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RETURN_SCENARIO env variables #671

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ALLOWED_HOSTS=localhost

#Anylogic
AL_API_KEY=al_api_key
RETURN_SCENARIO=True # setting that is used in the HOLON view to determine whether to send back the used scenario (through the serializer) or not

#DATABASE
DATABASE=postgres
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This repo contains the webapp part of the HOLON project. This includes the NextJ
- [Deployment](#deployment)
- [Datamodel](#datamodel)
- [Development on datamodel](#development-on-datamodel)
- [Datamodel scenario feedback in any environment](#datamodel-scenario-feedback-in-any-environment)
- [Resetting database and building project](#resetting-database-and-building-project)

## Environments
Expand Down Expand Up @@ -195,6 +196,14 @@ Refer to the datamodel readme: [datamodel.readme.md](src/holon/datamodel.readme.

Use convenience `migrate_and_create_fixture.sh` before every commit to make sure that the fixtures or present datamodels survive the changes you are making to the datamodel.

### Datamodel scenario feedback in any environment

A feature to help debug AnyLogic model results. This setting is used in the `/wt/api/nextjs/v2/holon/` endpoint to determine whether to send back the used scenario (through the serializer) or not. This should ideally not be set to true in production since it will impact performance.

```conf
RETURN_SCENARIO=True
```

# Resetting database and building project

When you first start the project, fixtures will be automatically loaded via the .devcontainer/docker-entrypoint.sh script.
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- WAGTAIL_API_URL=http://python:8000/wt/
- NEXT_PUBLIC_WAGTAIL_API_URL=https://pizzaoven.holontool.nl/wt/api/nextjs
- NEXT_PUBLIC_BASE_URL=https://pizzaoven.holontool.nl/wt
- RETURN_SCENARIO=True

python:
build:
Expand Down
6 changes: 3 additions & 3 deletions src/holon/services/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from holon.models import Scenario
from holon.serializers import ScenarioSerializer
from pipit.settings import get_env_bool


class Results:
Expand Down Expand Up @@ -59,9 +60,8 @@ def to_dict(self):
return result

def __include_scenario(self):
"""Only include modified scenario if request is done locally or on acceptatie"""
uri = self.request.build_absolute_uri()
return "localhost" in uri or "acceptatie" in uri or "pizzaoven" in uri
"""Only include modified scenario if env variable is set"""
return get_env_bool("RETURN_SCENARIO", False)


def calculate_holon_kpis(anylogic_outcomes: dict) -> dict:
Expand Down