Skip to main content

Plotly Dash-based broker app for the TOM Toolkit

Project description

pypi run-tests Codacy Badge Coverage Status

tom_alerts_dash

This module supplements the tom_alerts module with Plotly Dash support for more responsive broker views.

Installation

Install the module into your TOM environment:

pip install tom-alerts-dash

Add tom_alerts_dash and django_plotly_dash.apps.DjangoPlotlyDashConfig to the INSTALLED_APPS in your TOM's settings.py:

    INSTALLED_APPS = [
        'django.contrib.admin',
        ...
        'tom_dataproducts',
        'tom_alerts_dash',
        'django_plotly_dash.apps.DjangoPlotlyDashConfig'
    ]

Add STATIC_ROOT = os.path.join(BASE_DIR, '_static') and the following STATICFILES_FINDERS configuration to your settings.py, ideally in the Static files (CSS, JavaScript, Images) section:

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, '_static')
    MEDIA_ROOT = os.path.join(BASE_DIR, 'data')
    MEDIA_URL = '/data/'

    STATICFILES_FINDERS = [

        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',

        'django_plotly_dash.finders.DashAssetFinder',
        'django_plotly_dash.finders.DashComponentFinder',
        'django_plotly_dash.finders.DashAppDirectoryFinder',
    ]

Add django_plotly_dash.middleware.BaseMiddleware to MIDDLEWARE in your settings.py:

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        ...
        'django_plotly_dash.middleware.BaseMiddleware',
        'tom_common.middleware.Raise403Middleware',
        ...
    ]

Add the following Django Plotly Dash configuration to your settings.py:

# django-plotly-dash configuration

X_FRAME_OPTIONS = 'SAMEORIGIN'

PLOTLY_COMPONENTS = [
    # Common components
    'dash_core_components',
    'dash_html_components',
    'dash_renderer',

    # django-plotly-dash components
    'dpd_components',
    # static support if serving local assets
    # 'dpd_static_support',

    # Other components, as needed
    'dash_bootstrap_components',
    'dash_table'
]

Add the following two new paths to your base urls.py:

    url_patterns = [
        path('alerts/', include('tom_alerts_dash.urls', namespace='tom_alerts_dash')),
        path('', include('tom_common.urls')),
        path('django_plotly_dash/', include('django_plotly_dash.urls')),
    ]

Please note that the path with the namespace tom_alerts_dash MUST be placed above the tom_common.urls in order to properly override the default tom_alerts paths.

Finally, run the following to run the django-plotly-dash migrations:

    ./manage.py migrate

Using SCIMMA with tom_alerts_dash

The tom_scimma repo also includes tom_alerts_dash support. To install it into a TOM with tom_alerts_dash configured, the following steps are required.

Install tom_alerts_dash with the tom_scimma dependency, in either of the following fashions:

    pip install tom_alerts_dash tom_scimma

or:

    pip install tom_alerts_dash[scimma]

Add the TOM_ALERT_DASH_CLASSES setting to your settings.py, along with the brokers that you want to include in your TOM:

    TOM_ALERT_DASH_CLASSES = [
        'tom_alerts_dash.brokers.mars.MARSDashBroker',
        'tom_alerts_dash.brokers.alerce.ALeRCEDashBroker',
        'tom_alerts_dash.brokers.scimma.SCIMMADashBroker'
    ]

Add the SCIMMA settings specified in the tom_scimma README:

    TOM_ALERT_CLASSES = [
        ...
        'tom_scimma.scimma.SCIMMABroker'
    ]
    BROKERS = {
        ...
        'SCIMMA': {
            'url': 'http://skip.dev.hop.scimma.org',
            'api_key': os.getenv('SKIP_API_KEY', ''),
            'hopskotch_url': 'dev.hop.scimma.org',
            'hopskotch_username': os.getenv('HOPSKOTCH_USERNAME', ''),
            'hopskotch_password': os.getenv('HOPSKOTCH_PASSWORD', ''),
            'default_hopskotch_topic': ''
        }
    }

Creating a custom Dash broker module

For information on writing your own Dash broker module, please see the TOM Toolkit documentation on Dash broker modules.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tom-alerts-dash-0.1.2.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

tom_alerts_dash-0.1.2-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file tom-alerts-dash-0.1.2.tar.gz.

File metadata

  • Download URL: tom-alerts-dash-0.1.2.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for tom-alerts-dash-0.1.2.tar.gz
Algorithm Hash digest
SHA256 74b3c2cad93da854bcee4152f5fe2fd2cbcb844a60eddf08e1c2fcd40dcc346f
MD5 cf12b1b5d499df4e4dd2638c172997c7
BLAKE2b-256 8e09b24a34a37861666788c2301a4f08b0d1ff552698cdd9aca8e0ce8430cf07

See more details on using hashes here.

File details

Details for the file tom_alerts_dash-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tom_alerts_dash-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for tom_alerts_dash-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba7ec790fb7e7f7d87557e3ad2938f51140961e4c1c8e6cf53a4d932e7bc36d7
MD5 f0b2cd403f9d1aaa5137e4aab1688498
BLAKE2b-256 4c5bd604696a6276a3206ccb28c3fb28cd53303923d1316895b6ea55e48d1f15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page