Skip to content

Commit

Permalink
Now return the translator names in entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 7, 2025
1 parent 37c5741 commit 991283f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "lsst-obs-lsst"
obs_lsst = "lsst.obs.lsst.cli:get_cli_subcommands"

[project.entry-points.astro_metadata_translators]
obs_lsst = "lsst.obs.lsst.translators:_force_load"
obs_lsst = "lsst.obs.lsst.translators:_register_translators"

[tool.ruff]
line-length = 110
Expand Down
26 changes: 21 additions & 5 deletions python/lsst/obs/lsst/translators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,24 @@
from .lsstCamSim import *


def _force_load():
# This function exists solely to be loaded by the
# astro_metadata_translators entry point. The function
# will not be called.
pass
def _register_translators() -> list[str]:
"""Ensure that the translators are loaded.
When this function is imported we are guaranteed to also import the
translators which will automatically register themselves.
Returns
-------
translators : `list` [ `str` ]
The names of the translators provided by this package.
"""
return [
LsstCamTranslator.name,
LatissTranslator.name,
LsstComCamTranslator.name,
LsstComCamSimTranslator.name,
LsstCamSimTranslator.name,
LsstCamImSimTranslator.name,
LsstUCDCamTranslator.name,
LsstCamPhoSimTranslator.name,
]

0 comments on commit 991283f

Please sign in to comment.