Skip to content

Commit

Permalink
Added some commments to /query, remove collections from constants, ad…
Browse files Browse the repository at this point in the history
…d dev dp02
  • Loading branch information
stvoutsin committed Sep 25, 2024
1 parent 49b70a9 commit 10778d1
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/vosiav2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pydantic_settings import BaseSettings, SettingsConfigDict
from safir.logging import LogLevel, Profile

from .constants import COLLECTIONS
from .models.data_collections import DataCollection
from .models.query_engines import QueryEngines

Expand Down Expand Up @@ -45,7 +44,7 @@ class Config(BaseSettings):
data_collections: Annotated[
list[DataCollection],
Field(title="Data collections"),
] = COLLECTIONS
] = []
"""Configuration for the query engine."""

slack_webhook: Annotated[
Expand Down
17 changes: 0 additions & 17 deletions src/vosiav2/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,11 @@

__all__ = [
"RESPONSEFORMATS",
"COLLECTIONS",
"RESULT_NAME",
]

from .models.data_collections import DataCollection

RESPONSEFORMATS = {"votable", "application/x-votable"}
"""List of supported response formats for the SIAv2 service."""

RESULT_NAME = "result"
"""The name of the result file."""

COLLECTIONS = [
DataCollection(
config="https://raw.githubusercontent.com/lsst-dm/dax_obscore"
"/253b157fccdb8d9255bb4afbe9bf729618cdb367/configs/dp02.yaml",
label="LSST.DP02",
repository=(
"https://data-dev.lsst.cloud/api/butler/repo/dp02/butler.yaml"
),
default=True,
),
]

"""Configuration for a query engine."""
53 changes: 53 additions & 0 deletions src/vosiav2/data/dp02-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
facility_name: Rubin-LSST
obs_collection: LSST.DP02
collections: ["2.2i/runs/DP0.2"]
use_butler_uri: false
dataset_types:
raw:
dataproduct_type: image
dataproduct_subtype: lsst.raw
calib_level: 1
obs_id_fmt: "{records[exposure].obs_id}-{records[detector].full_name}"
o_ucd: phot.count
access_format: application/x-votable+xml;content=datalink
datalink_url_fmt: "https://data-dev.lsst.cloud/api/datalink/links?ID=butler%3A//dp02/{id}"
calexp:
dataproduct_type: image
dataproduct_subtype: lsst.calexp
calib_level: 2
obs_id_fmt: "{records[visit].name}-{records[detector].full_name}"
o_ucd: phot.count
access_format: application/x-votable+xml;content=datalink
datalink_url_fmt: "https://data-dev.lsst.cloud/api/datalink/links?ID=butler%3A//dp02/{id}"
deepCoadd_calexp:
dataproduct_type: image
dataproduct_subtype: lsst.deepCoadd_calexp
calib_level: 3
obs_id_fmt: "{skymap}-{tract}-{patch}"
o_ucd: phot.count
access_format: application/x-votable+xml;content=datalink
datalink_url_fmt: "https://data-dev.lsst.cloud/api/datalink/links?ID=butler%3A//dp02/{id}"
goodSeeingCoadd:
dataproduct_type: image
dataproduct_subtype: lsst.goodSeeingCoadd
calib_level: 3
obs_id_fmt: "{skymap}-{tract}-{patch}"
o_ucd: phot.count
access_format: image/fits
datalink_url_fmt: "https://data-dev.lsst.cloud/api/datalink/links?ID=butler%3A//dp02/{id}"
goodSeeingDiff_differenceExp:
dataproduct_type: image
dataproduct_subtype: lsst.goodSeeingDiff_differenceExp
calib_level: 3
obs_id_fmt: "{records[visit].name}-{records[detector].full_name}"
o_ucd: phot.count
access_format: application/x-votable+xml;content=datalink
datalink_url_fmt: "https://data-dev.lsst.cloud/api/datalink/links?ID=butler%3A//dp02/{id}"

spectral_ranges:
"u": [330.0e-9, 400.0e-9]
"g": [402.0e-9, 552.0e-9]
"r": [552.0e-9, 691.0e-9]
"i": [691.0e-9, 818.0e-9]
"z": [818.0e-9, 922.0e-9]
"y": [970.0e-9, 1060.0e-9]
8 changes: 6 additions & 2 deletions src/vosiav2/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,26 @@ def query(
# Get the Butler collection configuration.
# If many collections are provided, for now just look at the first one.
# This needs to be updated to handle multiple collections.

collection = (
get_data_collection(label=params.collection[0], config=config)
if params.collection is not None and len(params.collection) > 0
else get_default_collection(config=config)
)

# Create the query engine and execute the query.
# Create the query engine
query_engine = query_engine_factory.create_query_engine(
token=delegated_token, label=collection.label, config=collection.config
)

# Get the query params in the right format
query_params = param_factory.create_params(
siav2_params=params
).to_engine_parameters()

# Execute the query
table_as_votable = query_engine.siav2_query(query_params)

# Convert the result to a string
result = VOTableConverter(table_as_votable).to_string()

# For the moment only VOTable is supported, so we can hardcode the
Expand Down

0 comments on commit 10778d1

Please sign in to comment.