Skip to content
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
2 changes: 2 additions & 0 deletions app_lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from apps.routes.v1.lsst.skymap.api import ns as ns_skymap
from apps.routes.v1.lsst.statistics.api import ns as ns_stats
from apps.routes.v1.lsst.tags.api import ns as ns_tags
from apps.routes.v1.lsst.blocks.api import ns as ns_blocks

config = extract_configuration("config.yml")

Expand Down Expand Up @@ -89,6 +90,7 @@ def after_request(response):
api.add_namespace(ns_skymap)
api.add_namespace(ns_stats)
api.add_namespace(ns_tags)
api.add_namespace(ns_blocks)

# Register blueprint
app.register_blueprint(blueprint)
Expand Down
Empty file.
29 changes: 29 additions & 0 deletions apps/routes/v1/lsst/blocks/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2026 AstroLab Software
# Author: Julien Peloton
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import jsonify
from flask_restx import Namespace, Resource

from apps.routes.v1.lsst.blocks.utils import extract_blocks

ns = Namespace("api/v1/blocks", "Get blocks definition")


@ns.route("")
class Blocks(Resource):
def get(self):
"""Retrieve block definition"""
tags, descriptions = extract_blocks(True)
out = {k: v for k, v in zip(tags, descriptions)}
return jsonify(out)
45 changes: 45 additions & 0 deletions apps/routes/v1/lsst/blocks/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2026 AstroLab Software
# Author: Julien Peloton
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import fink_filters.rubin.blocks as fblocks
import importlib


def extract_blocks(with_description=False):
"""Extract user-defined blocks

Parameters
----------
with_description: bool
If True, returns block names and descriptions.
Otherwise, returns only block names.

Returns
-------
block_names: list of str
List of block names
descriptions: list of str, optional
Long descriptions for blocks
"""
# User-defined blocks
block_names = [prop for prop in dir(fblocks) if prop.startswith("b_")]

if with_description:
module_name = importlib.import_module(fblocks.__name__)
descriptions = [
getattr(module_name, block).__doc__.split("\n")[0] for block in block_names
]
return block_names, descriptions

return block_names
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ flask
flask-restx
pandas
numpy
fink-filters==7.12
fink-utils==0.51.0
#fink-filters==7.15-rc0
git+https://github.com/astrolabsoftware/fink-filters@7.15-rc0
fink-utils==0.52.0
line_profiler
requests
pyarrow
Expand Down