The step of the sorting hat is a step that names the alerts of astronomical survey. The flow of the step is showing in the following image:
- Internal cross-match: Using a cKDTree we found the closest objects in the batch. Practically the step make an adjacency matrix and mark the neighbours in
1.5arcsec. This cone search allows to obtain the same objects in the batch and thus perform fewer operations in the database. It also allows you to avoid concurrency problems when naming objects that are the same. - Find object id in the database: The first query to the database is get the known
oidby survey. If exists thisoidin database, the step retrieve theaidand assign it to the alert. - Cone-search to the database: If the first query hasn't response, the step ask to historical database for nearest objects. If exists the nearest object with a radius of
1.5arcsec If exists the nearest object with a radius of1.5arcsec, the step assign thisaidto the alert. - If there is no
oidor a nearby object in the database, a newaidis created for the alert.
If you make any changes to this repository, run these commands to test your changes (please install coverage, pytest and pytest-docker with pip):
- Unit tests: Test functionalities with mock of services (kafka, mongo and zookeeper).
coverage run --source sorting_hat_step -m pytest -x tests/unittest/You can then call coverage report to check the coverage.
- Integration tests: Run the step in an environment with kafka, mongo and zookeeper. This test is useful for developing without setting up a complex environment.
python -m pytest -x -s tests/integration/Poetry is configured to manage all dependencies in three groups: main, dev and test.
- Install poetry:
pip install poetry - If you want to set create
.venvenvironment in the project folder:poetry config virtualenvs.in-project true - Create environment with all dependencies (main, dev and test):
poetry install - To install only main dependencies:
poetry install --only main - Show tree of dependencies:
poetry show --tree - Add a new dependency
poetry add PACKAGEpoetry add -G dev PACKAGEpoetry add -G test PACKAGE
- Run all tests :
poetry run pytest - Run only unit test:
poetry run pytest tests/unittest - Run only integration tests:
poetry run pytest tests/integration
- Run step:
poetry run step