diff --git a/envipath/settings.py b/envipath/settings.py index d891bb07..29fcca60 100644 --- a/envipath/settings.py +++ b/envipath/settings.py @@ -260,6 +260,8 @@ CELERY_RESULT_BACKEND = 'redis://localhost:6379/1' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' +MODEL_BUILDING_ENABLED = os.environ.get('MODEL_BUILDING_ENABLED', 'False') == 'True' + DEFAULT_RF_MODEL_PARAMS = { 'base_clf': RandomForestClassifier( n_estimators=100, @@ -312,3 +314,12 @@ if SENTRY_ENABLED: # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info send_default_pii=True, ) + +# compile into digestible flags +FLAGS = { + 'MODEL_BUILDING': MODEL_BUILDING_ENABLED, + 'CELERY': FLAG_CELERY_PRESENT, + 'PLUGINS': PLUGINS_ENABLED, + 'SENTRY': SENTRY_ENABLED, + 'ENVIFORMER': ENVIFORMER_PRESENT, +} diff --git a/epdb/views.py b/epdb/views.py index e635fad6..1477b762 100644 --- a/epdb/views.py +++ b/epdb/views.py @@ -158,7 +158,7 @@ def get_base_context(request, for_user=None) -> Dict[str, Any]: 'writeable_packages': PackageManager.get_all_writeable_packages(current_user), 'available_groups': GroupManager.get_groups(current_user), 'available_settings': SettingManager.get_all_settings(current_user), - 'enabled_features': [], + 'enabled_features': s.FLAGS, 'debug': s.DEBUG, }, } @@ -572,11 +572,14 @@ def package_models(request, package_uuid): context['model_types'] = { 'ML Relative Reasoning': 'ml-relative-reasoning', 'Rule Based Relative Reasoning': 'rule-based-relative-reasoning', - 'EnviFormer': 'enviformer', } - for k, v in s.CLASSIFIER_PLUGINS.items(): - context['model_types'][v.display()] = k + if s.FLAGS.get('ENVIFORMER', False): + context['model_types']['EnviFormer'] = 'enviformer' + + if s.FLAGS.get('PLUGINS', False): + for k, v in s.CLASSIFIER_PLUGINS.items(): + context['model_types'][v.display()] = k return render(request, 'collections/objects_list.html', context) diff --git a/templates/actions/collections/model.html b/templates/actions/collections/model.html index a384080b..94d1a952 100644 --- a/templates/actions/collections/model.html +++ b/templates/actions/collections/model.html @@ -1,4 +1,4 @@ -{% if meta.can_edit %} +{% if meta.can_edit and meta.enabled_features.MODEL_BUILDING %}