Skip to main content

User-defined filters for the Fink broker.

Project description

pypi

Fink filters

This repository contains filters used to define which information will be sent to the community.

Step 0: Fork this repository

Fork and clone the repository, and create a new folder in fink_filters. The name of the new folder does not matter much, but try to make it meaningful as much as possible! Let's call it filter_rrlyr for the sake of this example.

Step 1: Define your filter

A filter is typically a Python routine that selects which alerts need to be sent based on user-defined criteria. Criteria are based on the alert entries: position, flux, properties, ... You can find what's in alert here [link to be added].

In this example, let's imagine you want to receive all alerts flagged as RRLyr by the xmatch module. You would create a file called filter.py and define a simple routine (see full template in the repo):

@pandas_udf(BooleanType(), PandasUDFType.SCALAR) # <- mandatory
def rrlyr(cross_match_alerts_per_batch: Any) -> pd.Series:
    """ Return alerts identified as RRLyr by the xmatch module.

    Parameters
    ----------
    cross_match_alerts_per_batch: Spark DataFrame Column
        Alert column containing the cross-match values

    Returns
    ----------
    out: pandas.Series of bool
        Return a Pandas DataFrame with the appropriate flag: 
        false for bad alert, and true for good alert.

    """
    # Here goes your logic
    mask = cross_match_alerts_per_batch.values == "RRLyr"

    return pd.Series(mask)

Remarks:

  • Note the use of the decorator is mandatory. It is a decorator for Apache Spark, and it specifies the output type as well as the type of operation. Just copy and paste it for simplicity.
  • The name of the routine will be used as the name of the Kafka topic. So once the filter loaded, you would subscribe to the topic rrlyr to receive alerts from this filter. Hence choose a meaningful name!
  • The name of the input argument must match the name of an alert entry. Here cross_match_alerts_per_batch is one column added by the xmatch module.
  • You can have several input columns. Just add them one after the other:
@pandas_udf(BooleanType(), PandasUDFType.SCALAR) # <- mandatory
def filter_w_several_input(acol: Any, anothercol: Any) -> pd.Series:
    """ Documentation """
    pass

Step 3: Open a pull request

Once your filter is done, we will review it. The criteria for acceptance are:

  • The filter works ;-)
  • The volume of data to be transfered is tractable on our side. Keep in mind, LSST incoming stream is 10 million alerts per night, or ~1TB/night. Hence your filter must focus on a specific aspect of the stream, to reduce the outgoing volume of alerts. Based on your submission, we will provide estimate of the volume to be transfered.

Step 4: Play!

If your filter is accepted, it will be plugged in the broker, and you will be able to receive your alerts in real-time using the fink-client. Note that we do not keep alerts forever available in the broker. While the retention period is not yet defined, you can expect emitted alerts to be available no longer than one week.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

fink-filters-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fink_filters-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file fink-filters-0.1.1.tar.gz.

File metadata

  • Download URL: fink-filters-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for fink-filters-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b89e3b981e6f6410386d3f615e617e32a7208eced6c28079167eefaa16a9094a
MD5 39e793ec6d469486cbb3e1ab9a73722b
BLAKE2b-256 ddc73bc8815b098b5861fc980d00ddcd91b6031a1e6c7337ec4b44104b32d52d

See more details on using hashes here.

File details

Details for the file fink_filters-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fink_filters-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for fink_filters-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3264a40c7ea4c78a50c302bee9ca2a70847331fa399d03fc4d46fc46cbab6187
MD5 deff0b9a6aecae8e0b5bd8659f9fd050
BLAKE2b-256 47dc7fb8a64ef61b2e111d1758d27ba006f7dc3d2cdeb4587b9f6d7473c68189

See more details on using hashes here.

Supported by

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