Skip to content

Commit

Permalink
8693587bv: load all env vars into the frontend to be used / viewed wh…
Browse files Browse the repository at this point in the history
…en needed
  • Loading branch information
tomolopolis committed Nov 17, 2023
1 parent a27d12f commit 69a6fd4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions envs/env
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ DB_BACKUP_DIR=/home/api/db-backup

# Resubmit all on startup
RESUBMIT_ALL_ON_STARTUP=1

# Front end env vars
LOAD_NUM_DOC_PAGES=10
4 changes: 4 additions & 0 deletions envs/env-prod
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ DB_BACKUP_DIR=/home/api/db-backup

# Resubmit all on startup
RESUBMIT_ALL_ON_STARTUP=1

# Front end env vars
LOAD_NUM_DOC_PAGES=10

5 changes: 5 additions & 0 deletions webapp/api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ class OPCSCodeViewSet(viewsets.ModelViewSet):
filterset_fields = ['code', 'id']


@api_view(http_method_names=['GET'])
def get_anno_tool_conf(_):
return Response({k: v for k,v in os.environ.items()})


@api_view(http_method_names=['POST'])
def prepare_documents(request):
# Get the user
Expand Down
2 changes: 1 addition & 1 deletion webapp/api/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
]

# BG TASKS
MAX_ATTEMPTS = 1
MAX_ATTEMPTS = 1
MAX_RUN_TIME = 60*60*10
BACKGROUND_TASK_RUN_ASYNC = True
BACKGROUND_TASK_ASYNC_THREADS = 4
Expand Down
1 change: 1 addition & 0 deletions webapp/api/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

urlpatterns = [
path('api/', include(router.urls)),
path('api/anno-conf/', api.views.get_anno_tool_conf),
path('api/search-concepts/', api.views.search_solr),
path('api/prepare-documents/', api.views.prepare_documents),
path('api/api-token-auth/', auth_views.obtain_auth_token),
Expand Down
10 changes: 8 additions & 2 deletions webapp/frontend/src/views/TrainAnnotations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const CONCEPT_IRRELEVANT = 'Irrelevant'
const TASK_VALUES = [CONCEPT_CORRECT, CONCEPT_REMOVED, CONCEPT_KILLED, CONCEPT_ALTERNATIVE, CONCEPT_IRRELEVANT]
const LOAD_NUM_DOC_PAGES = 10 // 30 docs per page, 300 documents
let LOAD_NUM_DOC_PAGES = 10 // 100 docs per page, 1000 documents
export default {
name: 'TrainAnnotations',
Expand Down Expand Up @@ -341,9 +341,15 @@ export default {
}
},
created () {
this.fetchData()
this.fetchAnnoConf()
},
methods: {
fetchAnnoConf () {
this.$http.get(`/api/anno-conf/`).then(resp => {
LOAD_NUM_DOC_PAGES = resp.data['LOAD_NUM_DOC_PAGES'] || LOAD_NUM_DOC_PAGES
this.fetchData()
})
},
fetchData () {
this.$http.get(`/api/project-annotate-entities/?id=${this.projectId}`).then(resp => {
if (resp.data.count === 0) {
Expand Down

0 comments on commit 69a6fd4

Please sign in to comment.